cancel
Showing results for 
Search instead for 
Did you mean: 

Handle different messages (XML root elements) in sync HTTP response

alejandro_bindi
Active Contributor
0 Kudos

In a proxy to HTTP scenario, I'm sending some payload to an external HTTP service which replies an XML as response.

For the moment, I'm using receiver SOAP adapter with "No SOAP envelope" option enabled.

The problem I have is that the root element of the response message can vary. So, depending on sent data and service logic, I can have this kind of response: <Error>(Error XML subnodes)</Error>

Or this one: <Success>(Success XML subnodes)</Success>

What I tried so far:

Option 1 - I generated XSD files for both XMLs and imported them as External Definitions. Next, I tried using Success ED as Response and Error ED as Fault in the Service interface definition. I also generated separated Message Mappings for both and used them in the Operation Mapping.

On execution monitoring though, Success is mapped correctly, but I see that Fault message mapping is never used; even when receiving Error XML, the Success mapping is used (which of course ends up in empty mapping or system error, depending on occurrence settings).

On further searching I read that SOAP adapter doesn't support fault messages, others say it does but requires some tweaking, for example with some parameters on module configuration. Anyway I'm almost certain now it won't work because it requires either a SOAP:fault subelement or an HTTP error code 500 to trigger the fault condition, am I correct? Neither happen in my case.

Option 2 - I merged both EDs in a single definition with an enclosing root element ("<Response>"), having both Success / Error subelements as optional (0..1), but the mapping does nothing. I suppose because my added enclosing Response element is not there.

How is this situation normally handled? Is BPM mandatory in this case?

Any tips are greatly appreciated, as I'm beginning my journey into PI.

Many thanks

Accepted Solutions (1)

Accepted Solutions (1)

alejandro_bindi
Active Contributor
0 Kudos

I finally implemented option 2 with the additional help of the MessageTransformBean module and a simple XSLT. So no Fault message is used.

I'm not sure if it is the best approach, but it works and it's not complicated.

I'm closing the thread but any suggestions or alternatives are anyway welcomed.

Answers (0)