JAX-WS – Error during call because a namespace has no prefix – How to add it?

I am facing an issue when I try to call a WS using JAX-WS. All my java classes are generated with wsdl-2-java maven plugin (cxf).

Below my maven wsdlOptions:

<wsdlOption> <wsdl>https://mywsdl</wsdl> <wsdlLocation>https://mywsdl</wsdlLocation> <extendedSoapHeaders>true</extendedSoapHeaders> <extraargs>     <extraarg>-client</extraarg>     <extraarg>-autoNameResolution</extraarg>     <extraarg>-p</extraarg>     <extraarg>http://myws=com.ws.myws</extraarg>     <extraarg>-p</extraarg>     <extraarg>http://namespace1=com.xsd.namespace1</extraarg>     <extraarg>-p</extraarg>     <extraarg>http://namespace2=com.xsd.namespace2</extraarg>     <extraarg>-p</extraarg>     <extraarg>http://namespace3=com.xsd.namespace3</extraarg> </extraargs> 

Here is the generated SOAP call :

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header>     <ns2:Options      xmlns="http://namespace1"     xmlns:ns2="http://namespace2"      xmlns:ns3="http://namespace3" /> </soap:Header> <soap:Body>     <ns2:GetRequest      xmlns="http://namespace1"     xmlns:ns2="http://namespace2"      xmlns:ns3="http://namespace3">         <ns2:Key>             <ns3:Code>AAA</ns3:Code>             <ns3:CmpCode>BBB</ns3:CmpCode>             <ns3:Level>CCC</ns3:Level>         </ns2:Key>     </ns2:GetRequest> </soap:Body> 

Here is the call that works with SOAP UI :

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header>     <ns2:Options      xmlns:ns1="http://namespace1"     xmlns:ns2="http://namespace2"      xmlns:ns3="http://namespace3" /> </soap:Header> <soap:Body>     <ns2:GetRequest      xmlns:ns1="http://namespace1"     xmlns:ns2="http://namespace2"      xmlns:ns3="http://namespace3">         <ns2:Key>             <ns3:Code>AAA</ns3:Code>             <ns3:CmpCode>BBB</ns3:CmpCode>             <ns3:Level>CCC</ns3:Level>         </ns2:Key>     </ns2:GetRequest> </soap:Body> 

The only difference is that the namespace xmlns (related to namespace1) has no prefix.

<ns2:Options xmlns="http://namespace1" [...] /> 

The error returned says that I try to call a method on the “namespace1”, which I don’t.

So I have tried to add a SOAPHandler to be able to parse the SOAP Body and do some modifications. But when I open all the variables that I can access at runtime, I don’t even see this “namespace1” so I can’t add/remove it. Maybe I should continue on this way.

I have also tried to change the order in my wsdloptions but it’s always “namespace1” that is ko.

I am looking for a global/elegant solution because I have nearly 20 others ws to generate for the same provider, so I am pretty sure that I will have the same issue.

Any idea ?