I've discovered that the reason my JAX-WS RI SOAP code is throwing a NAMESPACE_ERR exception is because of the presence of axis2-saaj-1.6.1.jar
in my project library. When I remove this jar everything works. I really don't know why there's a conflict but I've at least narrowed it down. The advice I've been given so far is to just remove the jar file and carry on.
Here's the problem - this jar file is bundled OOTB with this web product I'm writing this code for. It runs on Tomcat. It's a dependency for some features that we haven't used (but may) and besides that its 1st party provided so I don't want to touch it.
So two questions:
Code
URL wsdl = new URL("https://test.example.com/f/clientdataservice.asmx");
QName serviceName = new QName("urn:Example:ClientDataService", "ClientDataService");
Service service = ClientDataService.create(wsdl, serviceName);
HeaderHandlerResolver handlerResolver = new HeaderHandlerResolver();
service.setHandlerResolver(handlerResolver);
ClientDataServiceSoap port = service.getPort(ClientDataServiceSoap.class);
connector.templates.soap.api.User result = port.getUser("ABC123").get(0);
System.out.println(result.getContact().getEmail());
Exception (if axis2-saaj-1.6.1.jar is included)
Exception in thread "main" javax.xml.ws.WebServiceException: org.w3c.dom.DOMException: NAMESPACE_ERR: An attempt is made to create or change an object in a way which is incorrect with regard to namespaces.
at com.sun.xml.internal.ws.handler.ClientSOAPHandlerTube.callHandlersOnRequest(Unknown Source)
at com.sun.xml.internal.ws.handler.HandlerTube.processRequest(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.__doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber._doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.doRun(Unknown Source)
at com.sun.xml.internal.ws.api.pipe.Fiber.runSync(Unknown Source)
at com.sun.xml.internal.ws.client.Stub.process(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SEIStub.doProcess(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
at com.sun.proxy.$Proxy36.getUser(Unknown Source)
at connector.templates.soap.Test.main(Test.java:28)
Here's the full list of jars in the project:
activation.jar
ant.jar
antlr-2.7.6.jar
arial.jar
asm-3.1.jar
aspectjrt-1.8.9.jar
axiom-api-1.2.12.jar
axiom-dom-1.2.12.jar
axiom-impl-1.2.12.jar
axis.jar
axis2-adb-1.6.1.jar
axis2-kernel-1.6.1.jar
axis2-saaj-1.6.1.jar
axis2-transport-http-1.6.1.jar
axis2-transport-local-1.6.1.jar
batik-awt-util-1.6-1.jar
batik-ext-1.6-1.jar
batik-gui-util-1.6-1.jar
batik-util-1.6-1.jar
bsf.jar
bsh-2.1.8.jar
cerner.jar
cglib-2.2.jar
commons-beanutils.jar
commons-beanutils-bean-collections.jar
commons-beanutils-core.jar
commons-codec-1.9.jar
commons-collections-3.2.2.jar
commons-dbcp-1.4.jar
commons-digester-1.7.jar
commons-discovery-0.2.jar
commons-fileupload-1.3.1.jar
commons-httpclient.jar
commons-io-1.4.jar
commons-javaflow-20060411.jar
commons-lang-2.6.jar
commons-logging-1.1.3.jar
commons-logging-adapters-1.1.3.jar
commons-logging-api-1.1.3.jar
commons-net-1.4.1.jar
commons-pool-1.6.jar
commons-validator-1.3.1.jar
cssparser-0.9.7.jar
dom4j-1.6.1.jar
easymock.jar
easymockclassextension.jar
ehcache-1.6.0-beta3.jar
el-api-2.2.0.jar
el-impl-2.2.0.jar
esapi-2.0.1.jar
flexjson-2.1.jar
ganymed-ssh2-build263.jar
gdata-appsforyourdomain-1.0.jar
gdata-client-1.0.jar
gdata-core-1.0.jar
geronimo-annotation_1.1_spec-1.0.jar
geronimo-stax-api_1.0_spec-1.0.1.jar
GMCClientApp.jar
grac_request_details.jar
grac_risk_analysis_wout_no_ws.jar
grac_user_access.jar
grc_audit_log.jar
gson-2.1.jar
guava-11.0.1.jar
guice-3.0.jar
hibernate-3.5.2.jar
hk2-api-2.4.0-b34.jar
hk2-locator-2.4.0-b34.jar
hk2-utils-2.4.0-b34.jar
httpclient-4.3.6.jar
httpcore-4.3.3.jar
Human_ResourcesService.jar
IDMfw.jar
iText-2.1.6.jar
j2ssh-ant-0.2.9.jar
j2ssh-common-0.2.9.jar
j2ssh-core-0.2.9.jar
j2ssh-daemon-0.2.9.jar
jackson-core-asl-1.8.9.jar
jackson-mapper-asl-1.8.9.jar
jakarta-oro-2.0.8.jar
jasperreports-javaflow-4.5.0.jar
javassist.jar
javax.annotation-api-1.2.jar
javax.faces-2.1.26.jar
javax.inject-1.jar
javax.jms.jar
jawr-2.6.jar
jaxb-api-2.2.jar
jaxb-impl-2.2.1.1.jar
jaxen-1.1.3.jar
jaxrpc.jar
jaxrs-ri-2.22.2.jar
jcommon-1.0.17.jar
jdt-compiler-3.1.1.jar
jersey-apache-connector-2.17.jar
jersey-guava-2.22.2.jar
jersey-media-multipart-2.22.2.jar
jfreechart-1.0.14.jar
jline-0.9.94.jar
jms.jar
joda-time-1.6.2.jar
jpa.jar
js.jar
json.jar
json-path-2.2.0.jar
json-simple-1.1.1.jar
jstl-1.2.jar
jt400.jar
jta-1.1.jar
jtidy-r938.jar
juniversalchardet-1.0.3.jar
ldapbp.jar
log4j-1.2.17.jar
lucene-core-3.5.0.jar
lucene-demo-3.5.0.jar
mail.jar
mex-1.6.1-impl.jar
mimepull-1.9.6.jar
mysql-connector-java-5.1.28-bin.jar
NCSO.jar
neethi-3.0.1.jar
netsuite.jar
ojdbc6.jar
okhttp-2.0.0.jar
okio-1.0.1.jar
opensaml-2.5.3.jar
openws-1.4.4.jar
owasp-java-html-sanitizer.jar
ps6spy.jar
quartz-2.2.1.jar
rampart-core-1.6.1.jar
rampart-policy-1.6.1.jar
rampart-trust-1.6.1.jar
relaxngDatatype-2.2.jar
richfaces-components-api-4.3.2.Final.jar
richfaces-components-ui-4.3.2.Final.jar
richfaces-core-api-4.3.2.Final.jar
richfaces-core-impl-4.3.2.Final.jar
rsa-ws-7.1.2.jar
rsa-ws-8.0.jar
saaj.jar
sac-1.3.jar
sapidoc3.jar
scim-common.jar
scim-sdk-1.8.14.jar
scim-server.jar
sigar.jar
slf4j-api-1.5.11.jar
slf4j-log4j12-1.5.11.jar
soap.jar
spring-1.2.6.jar
sqljdbc42.jar
stax-api-1.0-2.jar
TenroxStub.jar
testng-5.4-jdk15.jar
Text_JDBC40.jar
tomahawk20-1.1.14.jar
tools.jar
twilio-java-sdk-3.4.1.jar
validation-api-1.1.0.Final.jar
velocity-1.5.jar
woden-api-1.0M9.jar
woden-impl-commons-1.0M9.jar
woden-impl-dom-1.0M9.jar
workflow.jar
wsdl4j-1.6.2.jar
wss4j-1.5.12.jar
wssdk.jar
wstx-asl-3.2.9.jar
xalan-2.7.0.jar
XmlSchema-1.4.7.jar
xmlsec-1.4.6.jar
xmltooling-1.3.4.jar
xmlunit-1.3.jar
xpp3.jar
xsom-20081112.jar
yuicompressor-2.4.2.jar
Unfortunately vendor support was unable to provide an answer as to why there was a conflict between JAX-WS RI and saaj but we received information on what breaks if we remove that jar.
We ended up electing to remove that saaj jar and overhaul some legacy, existing SOAP code to use JAX-WS RI. Doing so cleaned up a considerable amount of request message scaffolding work that was being done manually with strings (because of no domain visibility).
I don't particularly like this answer but will mark this question as answered since we've made a decision and will move forward with it. We'll just have to ensure that future product updates do not reintroduce this jar file back into the environment. It's possible one of the other implementations like Apache's CXF will have better luck.