I am using a JAX-WS service. Following is the part of request class.
@XmlElement(name = "Answers")
protected String answers;
Now, in the actual SOAP request, the answers need to be sent in the xml as CDATA. There is a separate stub class for answers. Hence, I am marshalling the object of that class into an xml. I am surrounding this in CDATA tags as shown below:
xmlstr = "<![CDATA[" + xmlstr + "]]>";
Hence, my request xml should look like this:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<!-- Other tags -->
<Answers>
<![CDATA[
<TagOne></TagOne>
<TagTwo></TagTwo>
]]>
</Answers>
</S:Body>
</S:Envelope>
However, when the request is sent to server, from the SOAPLoggingHandler, it looks like this:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<!-- Other tags -->
<Answers>
<![CDATA[
<TagOne></TagOne>
<TagTwo></TagTwo>
]]>
</Answers>
</S:Body>
</S:Envelope>
Due to this escaping of characters, I am receiving the response saying "Invalid Answers xml format". I have 2 questions:
Is xmlstr = "" the correct way to create a CDATA xml from a bean? If not then, is there any standard way to do that?
If I want to send the CDATA section in request without escaping, which changes should I make into my implementation?
Let me know if anything else is required.