cancel
Showing results for 
Search instead for 
Did you mean: 

Fetch SOAP Fault Message in Receiver in CPI

markbernabe
Active Participant

Hi experts,

My scenario is a simple SOAP call. In case of an error, the SOAP web service returns 500/Internal Server Error response. It's an XML containing the fault message. I want to catch this fault message and perform additonal processing on it like sending it over to a Message Mapping step. I want to do this instead of using ${exception.message} and ${exception.stacktrace} because the fault message contains more info about the error. However, I can't seem to fetch it. It's showing up when I enable the trace but it doesn't even go to the exception subprocess. I've tried ticking Return HTTP Response Code as Header in the adapter and also ${header.CamelHttpResponseCode} but to no avail.

Has anyone managed to accomplish this? Appreciate any tips and tricks. Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

fatihpense
Active Contributor

Hello Mark,

It seems that currently, the only option is using an HTTP receiver adapter.

  1. Change the receiver adapter type. Enter the connection details.
  2. Wrap your request message body in SOAP Envelope in a Content Modifier before calling the adapter.
  3. (optional) If your service requires, you may need to add the "SOAPAction" HTTP header accordingly.
  4. Add an exception subprocess to the flow and use the Groovy script in the documentation:

https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/a443efe1d5d2403fb95ee9def1a...

Regards,
Fatih

markbernabe
Active Participant
0 Kudos

Hi Fatih. your workaround worked. Thanks!

I wish SAP would also include SOAP fault handling in the SOAP adapter just like in SAP PI.

fatihpense
Active Contributor
0 Kudos

Hi Mark,

Glad it works. I thought the same about SOAP adapter handling. By the way, SAP recently announced a continuous influence program for CPI to get feedback. You may be interested in the program: https://influence.sap.com/sap/ino/#/campaign/2282/ideas

Answers (5)

Answers (5)

Former Member

I've looked up a solution for this exact problem and made a blog post about it.

Fetch SOAP Fault/Error Response from Receiver in SAP Cloud Platform Integration | SAP Blogs

With this script, there is no need anymore for a workaround with a HTTP Adapter.

Cheers
Dennis Sentler

rolfhoven
Explorer
0 Kudos

How did you do this ?

2. Wrap your request message body in SOAP Envelope in a Content Modifier before calling the adapter.


Regards,

Rolf

markbernabe
Active Participant

Hi Rolf,

It looks like this:

adityawsharma
Explorer
0 Kudos

Hi,

This can be handled by exception subprocess and writing a groovy script to capture exception class returned as mentioned in https://help.sap.com/viewer/368c481cd6954bdfa5d0435479fd4eaf/Cloud/en-US/a443efe1d5d2403fb95ee9def1a.... Once the class is captured, run the method ex.getDetail() and it will return you the full payload passed from SOAP Fault.

Thanks,

Aditya

Former Member
0 Kudos

Hello Aditya, did you manage to work with the object returned from ex.getDetail()? I was able to set this object to the message body. But in the next steps, I always received errors during processing, f.e.: XPath operations from Content Modifier didn't work for me.

Cheers
Dennis

adityawsharma
Explorer
0 Kudos

Hi Dennis,

Yes, I used the exact solution which is mentioned in the blog with just that I ended up converting to OutputStream byte array. However, if you are sending the payload a XML body as a response (which I have encountered earlier) the w3c.Dom Document works well with SOAP / HTTP adapters.

Hope this helps 🙂

Thanks,

Aditya

former_member198979
Participant
0 Kudos

Have you tried using trace and saw any values in the header/property?

former_member198979
Participant
0 Kudos

Try using request-reply to call this server and exception handling in the same integration process block with trace enabled, later restore the value of header/property which carries fault exception in the content modifier body inside exception sub-process, hoping after this step you use mapping to handle and let community knows your findings.

Thanks,

Chandan

markbernabe
Active Participant
0 Kudos

Hi Chanda, Thanks for responding. Yes my iFlow is exactly like this - 1 integration process with request-reply and an exception subprocess. What header/property should I use to get the fault exception? This is my problem. I already tried ${in.body}, ${exception.message} and even CamelHttpResponseCode, which I expect to be 500, doesn't go to the exception subprocess. It goes back to my question - how can I fetch and bring over the fault message returned by the SOAP receiver into the exception subprocess?