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
In this example test_rrs is the directory where the package.json file resides.
First we need to add var xml2js = require('xml2js'); at the top of our implementation.
This is the tricky part, we need to create a JSON like this.
' $ ' means that we want to add attributes to the XML element.
' _ ' means that we want to have something inside that element.
The last thing we have to do is to create a xml2js.Builder object and execute buildObject method using the json object we have just create. The result of this method is the body we are going to send.
After the implementation is done we just have to put everything inside the zip file and upload it to MCS.
If you want to know more about xml2js click here.