15 years ago
How to validate custom faults aganist schema?
Hi,
Topic Missing Matching Fault describes a warning message when you have not declared your faults in the WSDL.
I have been looking for a way to validate custom SOAP Faults against the WSDL Schema.
The actual problem is that the "Schema compliance" assertion will validate the response successfully even if the fault does not conform to it's declaration.
The reason for this is that custom faults are required to be transported wthin the details element of a SOAP Fault. Since this element can contain any element, a bugous fault will validate successfully.
Given the following sniplet from a WSDL-file:
The following returned fault does not conform to the schema but will pass the schema compliance assertion.
This naturally could be handled by xquery and xpath assertions, but that requires the soapui-developer not to do the same errors as the service developer.
Is there a better way to validate the fault?
Topic Missing Matching Fault describes a warning message when you have not declared your faults in the WSDL.
I have been looking for a way to validate custom SOAP Faults against the WSDL Schema.
The actual problem is that the "Schema compliance" assertion will validate the response successfully even if the fault does not conform to it's declaration.
The reason for this is that custom faults are required to be transported wthin the details element of a SOAP Fault. Since this element can contain any element, a bugous fault will validate successfully.
Given the following sniplet from a WSDL-file:
<schema targetNamespace="http://my.fault">
<complexType name="FaultStruct">
<sequence>
<element name="faultcode" minOccurs="1" type="string"/>
<element name="details" minOccurs="1" type="string"/>
</sequence>
</complexType>
<element name="declaredFault" type="FaultStruct" />
<schema>
<wsdl:message name="DeclaredFault">
<wsdl:part name="declaredFault" element="ns:declaredFault"/>
</wsdl:message>
<wsdl:portType name="MyPortType">
<wsdl:operation name="myOperation">
<wsdl:input ... />
<wsdl:output .../>
<wsdl:fault name="declaredFault" message="tns:DeclaredFault"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="MyBinding" type="tns:MyPortType">
<wsdl:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="myOperation">
<soap:operation soapAction="myOperation" style="document"/>
<wsdl:input .../>
<wsdl:output .../>
<wsdl:fault name="declaredFault">
<soap:fault name="declaredFault" use="literal" />
</wsdl:fault>
</wsdl:operation>
</wsdl:binding>
The following returned fault does not conform to the schema but will pass the schema compliance assertion.
<soapenv:Fault>
<faultcode>...</faultcode>
<faultstring>....</faultstring>
<faultactor>....</faultstring>
<detail>
<ns:delcaredFault xmlns:ns="http://my.fault"> <!-- typo -->
<!-- required element "faultcode" missing -->
<ns:details>Something happened</ns:details>
</ns:delcaredFault>
</detail>
</soapenv:Fault>
This naturally could be handled by xquery and xpath assertions, but that requires the soapui-developer not to do the same errors as the service developer.
Is there a better way to validate the fault?