Hi,

I am currently trying to debug an issue that is actually driving me crazy. I am 
calling a web service from a camel cxf endpoint in payload mode that returns 
data that uses a namespace in an attribute name that is defined on the SOAP 
envelope of the response. If I convert the CxfPayload into a String, the XML 
will be invalid because the namespace definition is missing.

The response message looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
    <soap:Body>
        <ns1:getSeedResponse 
xmlns:ns1="https://maullin.sii.cl/DTEWS/CrSeed.jws";>
            <getSeedReturn xsi:type="xsd:string>ResponseData</getSeedReturn>
        </ns1:getSeedResponse>
    </soap:Body>
</soap:Envelope>

The converted payload (as a String) will then look like that

<ns1:getSeedResponse 
xmlns:ns1="https://maullin.sii.cl/DTEWS/CrSeed.jws";><getSeedReturn 
xsi:type="xsd:string">ResponseData</getSeedReturn></ns1:getSeedResponse>

If you try any XML operation on this (like an XPath) the parser will complain 
that the xsi namespace prefix is undefined.

The route looks like that:
        <camel:route>
            <camel:from uri="file:///tmp/chile/poller" />
            <camel:to uri="cxf:bean:SII_SEED_SII_GET_SEED" />
            <camel:convertBodyTo type="java.lang.String"/>
            <camel:to uri="file:///tmp/chile/receiver?flatten=true" />
        </camel:route>

and the endpoint is defined like that:
    <cxf:cxfEndpoint
        address="http://localhost:8080/cxf/getSeedDummyService";
        endpointName="orange:MessageFlow_2"
        id="SII_SEED_SII_GET_SEED">
        <cxf:properties>
            <entry key="dataFormat" value="PAYLOAD" />
            <entry key="synchronous" value="true" />
        </cxf:properties>
    </cxf:cxfEndpoint>

My analysis so far is that the Source that is transferred from a CXF Message 
object to a Camel CxfPayload object is a StaxSource (the CXF class). If I try 
similar things in Camel-CXF unit tests, the source seems to be a DOMSource for 
some reason (and there is some special code for namespace handling in 
DefaultCxfBinding for that).

However I have not managed to figure out where the SOAP envelop is read in 
payload mode and how to get a proper transformation in to anything flat that 
does not lose the namespace but does not parse the whole thing into a DOM tree 
(which is pretty huge). It am also under the impression that Woodstox does also 
play some role in this context (the XMLStreamReader behind the StaxSource is 
from Woodstox and this does not return these outer namespaces with the 
getNamespaceCount() method.

Does anybody have an idea how to proceed here?

Best regards
Stephan

Reply via email to