There are several blogs and discussions about capturing and handling SOAP faults. This blog leverages on these blogs and discussions to provide a solution about how SOAP faults in addition to the web service faults can be captured in SAP PO/PI when invoking a 3rd Party web service.
Requirement: A 3rd party web service returns errors as web service faults and SOAP fault. Web service faults can be handled easily by adding a fault message in the service interface and adding a fault mapping. However SOAP fault messages need to be explicitly captured in PO/PI.
1. In the SOAP receiver communication channel check do no use SOAP envelope. Doing this ensures that the entire SOAP message including Envelope, Body and Fault can be captured in PO/PI.
2. Create a simple XSLT mapping for adding the SOAP envelope (since this gets stripped off from the setting in step 1) and use this after the request mapping so that the request message has the necessary SOAP envelope when the web service is invoked.
3. Create a custom xsd which would have both the fault message and the response message. Sample message in external definition from imported XSD as below:
4. Use the above external message as the response message in the service interfaces and the response mapping.
5. If there are namespaces in the response message e.g. “WebServiceFault” has a namespace attached to it these can be removed by using the XMLAnonymizerBean in the receiver SOAP communication channel.
6. Also in the receiver SOAP communication channel set the parameter XMBWS.NoSOAPIgnoreStatusCode = true so that the receiver SOAP adapter ignores the HTTP Status code when “Do not user SOAP envelope” is used.
7. When the web service scenario is tested with the above settings, all the fault messages can be captured in PO/PI and you can decide on the further course of action.
Note: Since the response and fault will be returned to the response mapping, you can further split this here or customise the mapping based on specific requirements.
Sample error message returned by the web service with the above solution:
Sample response message returned by the web service with the above solution: