Use this example of a typical WSDL that contains fault messages to find out how SOAP faults are defined in a WSDL file.
The following example of a typical WSDL file contains a port type called “MathOps”. There is an operation called “div” that has three possible fault messages called “DivByZeroStruct”, “SpecialDetailStruct” and “OutOfBoundStruct”.
<wsdl:portType name="MathOps"> <wsdl:operation name="div"> <wsdl:input message="impl:divRequest" name="divRequest"/> <wsdl:output message="impl:divResponse" name="divResponse"/> <wsdl:fault message="impl:DivByZeroStruct" name="DivByZeroStruct"/> <wsdl:fault message="impl:SpecialDetailStruct" name="SpecialDetailStruct"/> <wsdl:fault message="impl:OutOfBoundStruct" name="OutOfBoundStruct"/> </wsdl:operation> </wsdl:portType>
The definition of these message structures is described earlier in the WSDL as follows:
<complexType name="OutOfBoundStruct"> <sequence> <element name="varString" nillable="true" type="xsd:string"/> <element name="varInt" type="xsd:int"/> <element name="specialDetail" nillable="true" type="impl:SpecialDetailStruct"/> </sequence> </complexType> <complexType name="SpecialDetailStruct"> <sequence> <element name="varString" nillable="true" type="xsd:string"/> </sequence> </complexType> <element name="OutOfBoundStruct" nillable="true" type="impl:OutOfBoundStruct"/> <complexType name="DivByZeroStruct"> <sequence> <element name="varString" nillable="true" type="xsd:string"/> <element name="varInt" type="xsd:int"/> <element name="varFloat" type="xsd:float"/> </sequence> </complexType>