MCS: Calling SOAP connector bypassing XML/JSON translator
In the MCS project we are working we have to create some SOAP Connectors to integrate with Siebel. A great thing of MCS is that although we are going to consume a SOAP web service, the XML payload is automatically translated into JSON. You can get more info in MCS Documentation.
I would like to thank Oracle Mobile PM team, specially Grant Ronald and Frédéric Desbiens for their great help and for sharing best practices about this issue.
As soon as we create a SOAP Connector and try to test it we can see that the body we have to provide is a JSON.
But there are some cases where the translator is not perfect. We had a problem with some services that had an XML structure like this:
The translator seems not to add the namespaces in the header therefore Siebel cannot parse the request.
The solution is to send a XML instead of a JSON, bypassing the translator.
We can test this in SOAP Connector tester. As we need the required XML, we can get it in any web service client tool like for example SoapUI.
We also have to set “Content-Type: application/xml;charset:UTF-8” and “Accept: application/xml” as header parameters.
If we test the Connector we can see that the web service call is working.
How do we implement the Custom API to send a XML payload to the connector?
The answer is to set the XML we want to send as the body of the request and set the header parameters we previously use to test the connector.
In order to implement this we have to follow some steps:
- Download and Install Node.js. link
- Install xml2js module.
- Add xml2js as a dependency in package.json