рüффп
рüффп

Reputation: 5448

What is the best practice to send XML data embedded in a SOAP message?

I have a JAX-WS Web-Service which accepts some basic data and a String which is supposed to contains the content of a whole XML file. In the first time I though I can just put this XML in my SOAP request as a CDATA section like this:

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
   <soapenv:Header/>
   <soapenv:Body>
    ...
      <contentData>
    <![CDATA[
      <my>
        <xml>
          <here>
            ...
          </here>
        </xml>
      </my>
    ]]>
       </contentData>
       ...
   </soapenv:Body>
</soapenv:Envelope>

But the issue is that my XML data contains as well some CDATA sections and it is not working like this as nested CDATA are not allowed (W3School reference).

What would be the best practice to send such data?

I saw this question but serialising the Java object is not an option as the XML data are generated by another side.

Upvotes: 2

Views: 7330

Answers (2)

FX Swede
FX Swede

Reputation: 31

I found this answer:

Use XmlDocument as param type in the Web-Service, rather than string

This is what the Web-Service I am communicating with is using.

Upvotes: 1

Hemanth
Hemanth

Reputation: 647

I definitely prefer Solution 2, encoding and decoding Base64 formats.

Upvotes: 1

Related Questions