SOAP faults and Webservice faults from 3rd Party webservices
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.
Solution:
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:
References:
856597 – FAQ: XI 3.0 / PI 7.0/7.1/7.3 SOAP Adapter
http://scn.sap.com/people/alessandro.guarneri/blog/2011/01/10/soap-fault-in-sap-pi-hijack-it
Thanks a lot!!!
This helped me to solve an issue that I was struggeling for years...
To hell with SAP PI.
Hi Chandra
I hope this blog will solve my issue but please can you detail the step 3?
My wsdl has a request and response but no fault so in this case do I need to have response and fault as part of the soap response?
Hi Prabhu
Apologies for such a delayed reply. Step 3 is a single custom XSD to cater for the fault message and the response message, if you do not need to capture the fault message you do not need the custom xsd, you can directly use the WSDL response. Hope this clarifies.
Regards
Chandra
Hi Chandra
they have the complete example because I am with the same error and I can not solve it, could they send captures? operation mapping, Service Interface and Message Mapping , to see how they configured it. the scenario that I have is PROXY TO SOAP, the channel receiver that returns the fault.
regards,