You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by vi...@bt.com on 2008/09/17 16:18:39 UTC

Axis/AXIOM - Create OMText with CDATA.

Hi,
    I am trying to send a SOAP request using Apache Axis 1.3. An element
in the SOAP body requires the text to be wrapped in CDATA element. 
 
The code snippet is as follows: 
 
String stringToBeWrapped = "A'B'C'D";
 
OMElement elementWhichNeedsCData = ....;
 
TextImpl omText = (TextImpl)
bodyElement.getOMFactory().createOMText(stringToBeWrapped); 
omText.setType(XMLStreamConstants.CDATA);
elementWhichNeedsCData.addChild(omText);
 
The code compiles without any problems. However the SOAP request is as
follows:
 
<soapenv:Body
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssec
urity-utility-1.0.xsd" wsu:Id="Id-17777129">
    <s1:EdiCustomsDeclaration
xmlns:s1="http://www.examples.com/schemas/custom/edi/v1">
                &lt;![CDATA[A'B'C'D]]&gt;
    </s1:EdiCustomsDeclaration>
</soapenv:Body></soapenv:Envelope>
 
The CDATA text element has &gt; and &lt; escape characters. 
 
When I print the omText value, I can see the CDATA construct intact. But
the SOAP message shows something else.
 
How do I prevent escape characters from appearing in the CDATA
construct? Please help.
 
Regards,
Vinay Cardoza