1 16 package org.apache.axis.wsdl.symbolTable; 17 18 import org.apache.axis.constants.Use; 19 import org.apache.axis.utils.Messages; 20 21 import javax.wsdl.Fault; 22 import javax.wsdl.Message; 23 import javax.wsdl.Part; 24 import javax.wsdl.extensions.soap.SOAPHeaderFault; 25 import javax.xml.namespace.QName ; 26 import java.io.IOException ; 27 import java.util.Map ; 28 29 35 public class FaultInfo { 36 37 38 private Message message; 39 40 41 private QName xmlType; 42 43 44 private Use use; 45 46 47 private QName qName; 48 49 50 private String name; 51 52 67 public FaultInfo(Fault fault, Use use, String namespace, 68 SymbolTable symbolTable) { 69 70 this.message = fault.getMessage(); 71 this.xmlType = getFaultType(symbolTable, getFaultPart()); 72 this.use = (use != null) ? use : Use.LITERAL; 73 this.name = fault.getName(); 74 75 Part part = getFaultPart(); 76 77 if (part == null) { 78 this.qName = null; 79 } else if (part.getTypeName() != null) { 80 this.qName = new QName (namespace, part.getName()); 81 } else { 82 this.qName = part.getElementName(); 83 } 84 } 86 93 public FaultInfo(SOAPHeaderFault fault, SymbolTable symbolTable) 94 throws IOException { 95 96 MessageEntry mEntry = symbolTable.getMessageEntry(fault.getMessage()); 97 98 if (mEntry == null) { 99 throw new IOException ( 100 Messages.getMessage("noMsg", fault.getMessage().toString())); 101 } 102 103 this.message = mEntry.getMessage(); 104 105 Part part = message.getPart(fault.getPart()); 106 107 this.xmlType = getFaultType(symbolTable, part); 108 this.use = Use.getUse(fault.getUse()); 109 110 if (part == null) { 111 this.qName = null; 112 } else if (part.getTypeName() != null) { 113 this.qName = new QName (fault.getNamespaceURI(), part.getName()); 114 } else { 115 this.qName = part.getElementName(); 116 } 117 118 this.name = qName.getLocalPart(); 119 } 121 131 public FaultInfo( 132 QName faultMessage, String faultPart, String faultUse, String faultNamespaceURI, SymbolTable symbolTable) 133 throws IOException { 134 135 MessageEntry mEntry = symbolTable.getMessageEntry(faultMessage); 136 137 if (mEntry == null) { 138 throw new IOException (Messages.getMessage("noMsg", 139 faultMessage.toString())); 140 } 141 142 this.message = mEntry.getMessage(); 143 144 Part part = message.getPart(faultPart); 145 146 this.xmlType = getFaultType(symbolTable, part); 147 this.use = Use.getUse(faultUse); 148 149 if (part == null) { 150 this.qName = null; 151 } else if (part.getTypeName() != null) { 152 this.qName = new QName (faultNamespaceURI, part.getName()); 153 } else { 154 this.qName = part.getElementName(); 155 } 156 157 this.name = qName.getLocalPart(); 158 } 160 165 public Message getMessage() { 166 return message; 167 } 169 174 public QName getXMLType() { 175 return xmlType; 176 } 178 183 public Use getUse() { 184 return use; 185 } 187 200 public QName getQName() { 201 return qName; 202 } 204 211 public String getName() { 212 return name; 213 } 215 221 private Part getFaultPart() { 222 223 Map parts = message.getParts(); 225 226 if (parts.size() == 0) { 228 return null; 229 } else { 230 return (Part) parts.values().iterator().next(); 231 } 232 } 233 234 243 private QName getFaultType(SymbolTable st, Part part) { 244 245 if (part != null) { 246 if (part.getTypeName() != null) { 247 return part.getTypeName(); 248 } 249 250 TypeEntry entry = st.getElement(part.getElementName()); 252 253 if ((entry != null) && (entry.getRefType() != null)) { 254 return entry.getRefType().getQName(); 255 } 256 } 257 258 return null; 259 } 260 } 261 | Popular Tags |