Yasothar
Yasothar

Reputation: 453

IBM ESQL - Add a SOAP Envelop to XML Message

I have written simple message flow where HTTPInput node takes in a JSON message and sends back a SOAP message. I have added a HTTPInput, Compute and HTTPReply nodes. Compute node has the below ESQL.

BEGIN

        SET OutputRoot.SOAP.users[] =
        (SELECT I.id AS id,
        I.name AS name,
        I.userName AS username,
        I.email AS email
        FROM InputRoot.JSON.Data[]
        AS I);

        RETURN TRUE;
    END;

When I make a service call, with the below JSON

{
    "id": 1,
    "name": "lalala Graham",
    "username": "Bret",
    "email": "[email protected]",
    "address": {
      "street": "Kulas Light",
      "suite": "Apt. 556",
      "city": "Gwenborough",
      "zipcode": "92998-3874",
      "geo": {
        "lat": "-37.3159",
        "lng": "81.1496"
      }
    }
}

the XML response I get is

<SOAP_Domain_Msg>
   <users>
      <id>1</id>
      <name>lalala Graham</name>
      <email>[email protected]</email>
   </users>
</SOAP_Domain_Msg>

My issue is I want this response in a SOAP envelop. I tried adding a SOAP Envelop node before the HTTPReply node but I'm getting the below error.

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <SOAP-ENV:Body>
      <SOAP-ENV:Fault>
         <faultcode>SOAP-ENV:Server</faultcode>
         <faultstring>BIP3113E: Exception detected in message flow MFSamplej2s (integration node integration_server)</faultstring>
         <faultactor>http://localhost:7800/users</faultactor>
         <detail>
            <text>Exception. BIP2230E: Error detected whilst processing a message in node 'MFSamplej2s.SOAP Envelope'. : C:\ci\product-build\WMB\src\WebServices\WSLibrary\ImbSOAPEnvelopeNode.cpp: 280: ImbSOAPEnvelopeNode::evaluate: ComIbmSOAPEnvelopeNode: MFSamplej2s#FCMComposite_1_1
BIP3171E: A message using an incorrect parser ('SOAP') was detected in node: 'SOAP Envelope' : C:\ci\product-build\WMB\src\WebServices\WSLibrary\ImbSOAPEnvelopeNode.cpp: 613: ImbSOAPEnvelopeNode::getMessageBody: :</text>
         </detail>
      </SOAP-ENV:Fault>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Any help would be very much helpful.

Upvotes: 0

Views: 1133

Answers (2)

Yasothar
Yasothar

Reputation: 453

This worked with the following code.

SET OutputRoot.XMLNSC.ns1:citizen.ns1[] = 
    (SELECT I.username AS username,     
        I.personID AS personID, 
        I.familyName AS familyName, 
        I.title AS title, 
        I.dob AS dob 
        FROM InputRoot.JSON.Data[] AS I);

The SOAP had to be replaced by XMLNSC, then the SOAP response came. Actually this was in the link @Supun shared.

Upvotes: 1

Related Questions