Issue with ![CDATA[ in SOAP inbound response

Naga23
Giga Expert

Hi All,

 

I am working on scripted soap api and after processing the incoming soap api request, I need to trigger response back to source application with custom response nodes.

Below is the same response format where I am facing issue.

 

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <SOAP-ENV:Body>
      <abc>
         <Message>The Call retrieved.</Message>
         <xyz><![CDATA[<result>some xml data format
                       </result>]]>
          </xyz>
      </abc>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

 

Where <xyz> is another xml that I am pushing in the response. and it is ended up by adding ![CDATA before xml value.

 

Please help me on this issue, thank you!

2 REPLIES 2

Hitoshi Ozawa
Giga Sage
Giga Sage

Probably not parsing the "<result>some xml data format</result>" so it's treated as a string instead of a xml document.

Need to see the code creating the content of reply xml.

Hitoshi Ozawa
Giga Sage
Giga Sage

Sample on how to append node to xml.

var str = '<abc><Message>The Call retrieved.</Message><xyz></xyz></abc>';
var xmlDoc = new XMLDocument2();
xmlDoc.parseXML(str);
var result = '<result>some xml data format</result>';

var xmlNode = xmlDoc.getNode("/abc/xyz");
xmlDoc.setCurrentElement(xmlNode);
xmlDoc.createElementWithTextValue("result", "some xml data format");

gs.info(xmlDoc);

Execution result:

*** Script: <?xml version="1.0" encoding="UTF-8"?><abc><Message>The Call retrieved.</Message><xyz><result>some xml data format</result></xyz></abc>