1 55 package org.jboss.axis.wsdl.symbolTable; 56 57 import org.jboss.axis.enums.Use; 58 import org.jboss.axis.utils.Messages; 59 60 import javax.wsdl.Fault; 61 import javax.wsdl.Message; 62 import javax.wsdl.Part; 63 import javax.wsdl.extensions.soap.SOAPHeaderFault; 64 import javax.xml.namespace.QName ; 65 import java.io.IOException ; 66 import java.util.Map ; 67 68 74 75 public class FaultInfo 76 { 77 private Message message; 78 private QName xmlType; 79 private Use use; 80 private QName qName; 81 private String name; 82 83 93 public FaultInfo(Fault fault, Use use, String namespace, 94 SymbolTable symbolTable) 95 { 96 this.message = fault.getMessage(); 97 this.xmlType = getFaultType(symbolTable, getFaultPart()); 98 this.use = use; 99 this.name = fault.getName(); 100 101 Part part = getFaultPart(); 102 if (part == null) 103 { 104 this.qName = null; 105 } 106 else if (part.getTypeName() != null) 107 { 108 this.qName = new QName (namespace, part.getName()); 109 } 110 else 111 { 112 this.qName = part.getElementName(); 113 } 114 } 116 119 public FaultInfo(SOAPHeaderFault fault, SymbolTable symbolTable) 120 throws IOException 121 { 122 MessageEntry mEntry = symbolTable.getMessageEntry(fault.getMessage()); 123 if (mEntry == null) 124 { 125 throw new IOException (Messages.getMessage("noMsg", 126 fault.getMessage().toString())); 127 } 128 this.message = mEntry.getMessage(); 129 Part part = message.getPart(fault.getPart()); 130 this.xmlType = getFaultType(symbolTable, part); 131 this.use = Use.getUse(fault.getUse()); 132 133 if (part == null) 134 { 135 this.qName = null; 136 } 137 else if (part.getTypeName() != null) 138 { 139 this.qName = new QName (fault.getNamespaceURI(), part.getName()); 140 } 141 else 142 { 143 this.qName = part.getElementName(); 144 } 145 this.name = qName.getLocalPart(); 146 147 } 149 public FaultInfo(QName faultMessage, String faultPart, String faultUse, String faultNamespaceURI, SymbolTable symbolTable) 150 throws IOException 151 { 152 MessageEntry mEntry = symbolTable.getMessageEntry(faultMessage); 153 if (mEntry == null) 154 { 155 throw new IOException (Messages.getMessage("noMsg", 156 faultMessage.toString())); 157 } 158 this.message = mEntry.getMessage(); 159 Part part = message.getPart(faultPart); 160 this.xmlType = getFaultType(symbolTable, part); 161 this.use = Use.getUse(faultUse); 162 163 if (part == null) 164 { 165 this.qName = null; 166 } 167 else if (part.getTypeName() != null) 168 { 169 this.qName = new QName (faultNamespaceURI, part.getName()); 170 } 171 else 172 { 173 this.qName = part.getElementName(); 174 } 175 this.name = qName.getLocalPart(); 176 177 } 179 public Message getMessage() 180 { 181 return message; 182 } 184 public QName getXMLType() 185 { 186 return xmlType; 187 } 189 public Use getUse() 190 { 191 return use; 192 } 194 205 public QName getQName() 206 { 207 return qName; 208 } 210 215 public String getName() 216 { 217 return name; 218 } 220 224 private Part getFaultPart() 225 { 226 Map parts = message.getParts(); 228 if (parts.size() == 0) 230 { 231 return null; 232 } 233 else 234 { 235 return (Part)parts.values().iterator().next(); 236 } 237 } 238 239 248 private QName getFaultType(SymbolTable st, Part part) 249 { 250 if (part != null) 251 { 252 if (part.getTypeName() != null) 253 { 254 return part.getTypeName(); 255 } 256 TypeEntry entry = st.getElement(part.getElementName()); 258 if (entry != null && entry.getRefType() != null) 259 { 260 return entry.getRefType().getQName(); 261 } 262 } 263 return null; 264 } 265 } 266 267 | Popular Tags |