I'm working on a web-service client using a set of CXF-based tools
developed by a colleague who knows a lot more about WSs than I do
(although he couldn't explain the following problem).

The client passes a byte[] and a parameter list to a WS method, which
returns a response containing an XML element, represented as an
org.w3c.dom.Element in the service's Java API (annotated with
@XmlAnyElement).

The client code then serializes that Element as the root of an XML
document, which it saves locally.  Unfortunately, the CXF library is
discarding significant whitespace text nodes between
receiving the SOAP response and creating the Element.  I've determined
this by using the axis 1.4 TCPMonitor proxy.

The SOAP response coming from the server includes the desired
whitespace:

#v+
<TextWithNodes><Node id="0"/> <Node id="1"/>Internationalisation<Node id="21"/> 
<Node id="22"/>vertical<Node id="30"/> <Node id="31"/>stream<Node 
id="37"/>:<Node id="38"/> <Node id="39"/>INT<Node id="42"/> <Node 
id="43"/>VS<Node id="45"/> <Node id="46"/>UPDATE<Node id="52"/>&#xD;
#v-

But the Element is serialized as follows:

#v+
<TextWithNodes><Node id="0"/><Node id="1"/>Internationalisation<Node 
id="21"/><Node id="22"/>vertical<Node id="30"/><Node id="31"/>stream<Node 
id="37"/>:<Node id="38"/><Node id="39"/>INT<Node id="42"/><Node 
id="43"/>VS<Node id="45"/><Node id="46"/>UPDATE<Node id="52"/>
#v-

I tried three different ways to serialize it, then did some debugging
(see message <[email protected]> in comp.text.xml)
that showed that the whitespace text nodes are missing from the
Element --- with complete disregard for  the xml:space="preserve"
attribute which the server puts in and which still appears in the
serialized XML from the client!

Is there a way to force CXF not to drop the whitespace?

Thanks,
Adam

Reply via email to