cwolf
cwolf

Reputation: 51

SAAJ: XML in TextNode. Quotes not Escaped

together I ty to build a SOAP Request with SAAJ. All works fine but now I have to send an other XMl Document inside the SOAP Body inside SOAP Element.

I tried follwing code:

SOAPElement file = service.addChildElement(new QName("nameOfTextNode"));
file.addTextNode(xmlString);

The Problem is most characters are correctly escaped (e.g. '<' -> &lt;) but not single or double quotes. I can't use CDATA or let the quotes as they are, because i don't have control over the SOAP Service and they can't support CDATA or want to change anything.

When I use anothe Library to escape the String first. It will be escaped twice in the SOAP Request.

Do aynone have an idea? Please help.

Upvotes: 2

Views: 300

Answers (1)

Andreas Veithen
Andreas Veithen

Reputation: 9154

SAAJ doesn't escape single or double quotes in this case because it's not required. If the service requires that, then it doesn't conform to the XML specification and therefore isn't a SOAP service. Since SAAJ implements SOAP, you won't be able to use it.

Upvotes: 0

Related Questions