An update to my reply. I had a chat with Dan on #apache-cxf and he explained to me that the logic was for creating the client from an annotated class and the jaxws spec requires non-namespaced targetNamespace to be qualified. In addition to this, WS-I Basic Profile rule R1014 also states the root element must be qualified. http://www.ws-i.org/profiles/basicprofile-1.1-2004-08-24.html#R1014
One way to workaround this restriction is to use the WSDL-based client creation, which does not automatically add the namespace as done during the Class-based client creation. If you have generated java classes from your WSDL, you can use the generated service class (the one extending javax.xml.ws.Service) to create your client instead of using the Service class with the generated port type class (which, I suppose, is what are doing now). This should solve your problem. Let me know. regards, aki 2015-05-05 13:41 GMT+02:00 Aki Yoshida <[email protected]>: > There seems to be a bug in CXF. I think I am seeing the same issue. > I'll have to look into it a little more. > > A quick workaround to make your broken client talk to the server is to > use CXF's transform feature. See > http://cxf.apache.org/docs/transformationfeature.html#TransformationFeature-Changinginputandoutputelementnamesandnamespaces > > You will need to configure this feature at your client to drop the > namespace from the namespaced element for the outbound and to add the > namespace back to the non-namesapced element for the inbound. > > regards, aki > > > 2015-04-23 18:00 GMT+02:00 Vladimir Sutskever <[email protected]>: >> Hi, >> >> I am using cxf client to consume a web-service that has targetNamespace="" >> in the WSDL's XSD definition. >> The CXF client seems to append a namespace of ns2 to the each request as >> shown below. >> >> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> >> <soap:Body> >> <ns2:ReadSubscriberRequest >> xmlns:ns2="http://www.x.com/TFProvisioning/"><http://www.openet.com/TFProvisioning/">> >> <SubscriberId>9999</SubscriberId> >> </ns2:ReadSubscriberRequest> >> </soap:Body> >> </soap:Envelope> >> >> Why does cxf add ns2 namespace? >> The ns2 namespace is unfamiliar to soap-service and therefore it throws an >> fault: Cannot find the declaration of element 'ns2:ReadSubscriberRequest' >> >> How do I prevent cxf from adding a ns2 namespace reference in a case when >> the wsdl doesn't have a targetNamespace? >> >> >> -Vladimir
