Send CDATA through soapClient


My problem is that I have to call a webservice that needs to process some XML data. Before wM integration we used to call this webservice using CDATA in xml, something like this:

    <msgData><![CDATA[<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<request messageID="6d8259f2-f2be-11dd-b017-9b4c6a8d7079" messageDateTime="2009-02-04T14:19:17.330" requestersId="testId">

The problem is that I can’t make wM call the webservice not escpaing the reserved XML character in the tag, and the message being sent looks like this:

<schema:sendXmlMsgRequest >
<schema:msgData><![CDATA[<?xml version="1.0"?>
<request messageID="da42515a-f770-11dd-8771-f182a6d5e6d6" messageDateTime="2009-02-10T13:46:36.116" highPriorityRequest="true">

Is there some way to avoid escaping the XML characters?


One approach (the correct one IMO) is to escape the chars and remove the CDATA wrapper. Semantically both representations have the same meaning.

Another thing to look at: I assume you’re using documentToXMLString to convert the IS doc to an XML string. Set encode to false. Be careful with this because, if your XML fragment that you posted is part of a larger document, this will impact the entire XML string. So if another field has something like “Mr. & Mrs. John Smith” as content, the XML will be broken because the & will not be converted to a character entity. If you know for sure that no field will ever have an XML markup character as data, then setting encode to false is safe.