简体   繁体   中英

SOAP namespace issue on web service with Apache CXF

I am using Apache CXF 3.0.2 to expose a service that is hitting an issue with namespaces during unmarshalling. When all namespace declarations are done at the soapenvelope level they seem to be getting stripped off or lost when I am going to unmarshall the message. For example the following would show as invalid xml:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:v1="http://foo.com/v1"
xmlns:v2="http://bar.com/v2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body >
        <v1:foo>
            <v2:bar>
        </v1:foo>
    </soapenv:Body>
</soapenv:Envelope>

But if I move the declaration down the to the soapbody or below the xml validates fine:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"     
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <soapenv:Body xmlns:v2="http://bar.com/v2" xmlns:v1="http://foo.com/v1">
        <v1:foo>
            <v2:bar>
        </v1:foo>
    </soapenv:Body>
</soapenv:Envelope>

I have been trying to write an interceptor to manipulate the incoming request and move/copy the name space declarations that I care about from the header to the Body tag but don't seem to be able to manipulate the incoming message in this manner. Does any one have any suggestions?

Look into extending AbstractSoapInterceptor since you are using Apache CFX . Overriding handleMessage() gives you access to your SOAPMessage and you can manipulate it.

Apache CFX Interceptors

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM