xmlweb-servicesxml-serializationoracle-service-bus

Convert xml as string


i have a scenario where in i need to send an xml as a tag content in a SOAP request message to a webservice for example

<arg_1><xml version="1.0" encoding="UTF-8"?><sometag><somemoretag>abcd</somemoretag></sometag></arg_1></code>

arg_1 happens to be an String parameter to a webservice. So i bring in a CDATA section for this

<arg_1><![CDATA[<xml version="1.0" encoding="UTF-8"?><sometag><somemoretag>abcd</somemoretag></sometag>]]></arg_1>

But this keeps throwing me an exception

org.xml.sax.SAXException: WSWS3084E: Error: SimpleDeserializer encountered a child element, which is NOT expected, in something it was trying to deserialize. Message being parsed:

I keep getting this exception. Has anyone seen this before??


Solution

  • There are a couple of ways you could handle this -

    1. Remove the XML Prolog and insert the original XML document into the content of an element in the other document.
    <arg_1><sometag><somemoretag>abcd</somemoretag></sometag></arg_1>
    
    1. Escape the the original XML document like you would any other text content and insert the resulting text into the content of an element.
    <arg_1>&lt;sometag&gt;&lt;somemoretag&gt;abcd&lt;/somemoretag&gt;&lt;/sometag&gt;</arg_1>