Originally posted by Reid M. Pinchback:
If you are using JAX-RPC tools to create the WSDL instead of doing it by hand, ... That way identifying your fault is no different than identifying any Java exception.
That's true even if you create the WSDL manually; you just catch a Java exception. WSDL2Java will still do the mapping for you. The following code was based on the code generated by WSDL2Java. The fleshed out generated service template:
The client using the generated code:
The WSDL file FaultGenerator.wsdl
SOAP response for type 1 fault (XML Schema SimpleType)
Apparently Axis likes to sneak in additional information in the fault detail: ns2:exceptionName and ns3:hostname.
Also the first detail child element is named after the fault�s part name.
SOAP response for type 2 fault (XML Schema ComplexType)
For a complexType the first detail child element is named after the fault part�s element name.
SOAP response for type 3 fault (extended XML Schema ComplexType)
Oh, oh. Something went wrong here. That first detail child element should have been <ns1:accountInsufficientFundsFault>. And the client stub promptly complains about that: "org.xml.sax.SAXException: Invalid element in com.example.InsufficientFundsFault � account". Well, maybe some time in the future. If you don�t extend/inherit you are fine.
SOAP response for type 4 fault (distinct XML Schema ComplexType)