Hi all,
I'm facing a problem using Spring WS WebServiceTemplate to implement a WS client.
Basically, I'm injecting some XML as a String in my request, it is enclosed in a CDATA tag (this is required by the remote service), but it's entities get escaped. I'm looking for a way to bypass this encoding (which I didn't expect, since CDATA content shouldn't be interpreted in any way, right ?).
More details after the break
I have to reach an external application using SOAP, with this kind of structure :
When I use this markup with soapui, I get the correct answer.Code:<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:abc="http://abc.remote.com"> <soap:Header/> <soap:Body> <abc:action> <abc:params> <![CDATA[ <subaction> <name>NAME</name> <infos> <info1>INFO1</info1> <info2>INFO2</info2> </infos> </subaction> ]]> </abc:params> </abc:action> </soap:Body> </soap:Envelope>
Using Wireshark, I see this exact markup being sent over the wire by soapui.
However, when I use my WebServiceTemplate, I noticed that what is sent is this markup, but with XML entities escaped (< etc.).
The remote service then answers with an error (I absolutely don't know anything about nor can't do anything on the remote implementation).
Relevant code example :
with the same XmlBeansMarshaller as marshaller and unmarshaller for myWSTemplate, and buildRequest() returning a markup like :Code:public SubactionResponseDocument subaction() { // build the XML to send with SOAP SubactionDocument request = buildRequest(); SubactionResponseDocument answer = (SubactionResponseDocument)myWSTemplate.marshalSendAndReceive(request); return answer; }
According to Wireshark, it results in this kind of markup being sent :Code:<abc:action> <abc:params> <![CDATA[ <subaction> <name>NAME</name> <infos> <info1>INFO1</info1> <info2>INFO2</info2> </infos> </subaction> ]]> </abc:params> </abc:action>
Digging through the huge actual function call hierarchy (Spring / DOM / SOAP / ...) with Eclipse hasn't led me to the place where this escaping happensCode:<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:abc="http://abc.remote.com"> <soap:Header/> <soap:Body> <abc:action> <abc:params> <![CDATA[ <subaction> etc. ]]> </abc:params> </abc:action> </soap:Body> </soap:Envelope>
However I can tell that :
* when calling marshalSendAndReceive(request), request text is not escaped.
* in XmlBeansMarshaller.marshalDomNode(Object graph, Node node), graph's text is still unescaped too
I think I gave all what I thought relevant, of course feel free to ask any information I forgot
Thanks in advance for any contribution !




Reply With Quote