Reputation: 1482
I have a running JAX-WS webservice which already has some working endpoints. Now I'm having the following issue:
I'm having two different SOAP Requests here and I don't understand why the first one works but the second one does not.
The only obvious difference in the requests is that the first one specifies a namespace in the <Envelope>
tag while the second one specifies it when calling the method <getMoldDataHistory>
.
SOAP Request 1 - Not Working (Namespace is specified at the method call)
<s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"
>
<s:Body
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<getMoldDataHistory
xmlns="http://history.production.soap.webservices.product.company.at/">
<machineId>92623-15853588</machineId>
<start>0</start>
<end>0</end>
</getMoldDataHistory>
</s:Body>
</s:Envelope>
SOAP Request 2 - Working (Namespace is specified in the <Envelope>
tag)
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:his="http://history.production.soap.webservices.product.company.at/">
<soapenv:Header/>
<soapenv:Body>
<his:getMoldDataHistory>
<machineId>92623-15853588</machineId>
<start>0</start>
<end>0</end>
</his:getMoldDataHistory>
</soapenv:Body>
</soapenv:Envelope>
The SOAP error message I'm getting when making the first (Not working) request.
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<S:Fault xmlns:ns4="http://www.w3.org/2003/05/soap-envelope">
<faultcode>S:Server</faultcode>
<faultstring>java.lang.IllegalArgumentException</faultstring>
</S:Fault>
</S:Body>
</S:Envelope>
The stacktrace of the exception thrown from the Server when receiving the first SOAP request.
java.lang.IllegalArgumentException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.Trampoline.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.xml.internal.ws.api.server.MethodUtil.invoke(Unknown Source)
at com.sun.xml.internal.ws.api.server.InstanceResolver$1.invoke(Unknown Source)
at com.sun.xml.internal.ws.server.InvokerTube$2.invoke(Unknown Source)
at com.sun.xml.internal.ws.server.sei.EndpointMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.server.sei.SEIInvokerTube.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.server.WSEndpointImpl$2.process(Unknown Source)
at com.sun.xml.internal.ws.transport.http.HttpAdapter$HttpToolkit.handle(Unknown Source)
at com.sun.xml.internal.ws.transport.http.HttpAdapter.handle(Unknown Source)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handleExchange(Unknown Source)
at com.sun.xml.internal.ws.transport.http.server.WSHttpHandler.handle(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.AuthFilter.doFilter(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(Unknown Source)
at com.sun.net.httpserver.Filter$Chain.doFilter(Unknown Source)
at sun.net.httpserver.ServerImpl$Exchange.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
So I'm basically trying to figure out why the first request is not working despite it being a valid SOAP request. Is there anything I need to configure at my server to allow such requests?
EDIT:
After doing some more testing I found out that the position of the namespace declaration does NOT matter IF the method I call has 0 parameters. As soon as parameter is required it stops working.
EDIT 2:
Now I stumpled upon this thread here . I have the same issue. My C# Client who makes the requests does not use the namespace int the method TAG. After I add it it works.
Still how can I tell JAX-WS to deal with this.
Does not work:
<getMoldDataHistory xmlns="http://history.production.soap.webservices.product.company.at/">
Works:
<his:getMoldDataHistory xmlns:his="http://history.production.soap.webservices.product.company.at/">
Upvotes: 2
Views: 2269
Reputation: 20618
When using a prefix bound to a namespace like in
<his:getMoldDataHistory xmlns:his="http://history.production.soap.webservices.product.company.at/">
<machineId>92623-15853588</machineId>
<start>0</start>
<end>0</end>
</his:getMoldDataHistory>
then only the element getMoldDataHistory
is put into the specified namespace. The reason is that the syntax xmlns:his="..."
only declares the prefix. This then must used at all elements that you want to be in the specified namespace. In this code snippet, the only element is getMoldDataHistory
.
Using the xmlns="..."
syntax like in
<getMoldDataHistory xmlns="http://history.production.soap.webservices.product.company.at/">
<machineId>92623-15853588</machineId>
<start>0</start>
<end>0</end>
</getMoldDataHistory>
not only declares the namespace, but also puts the associated element and all child elements into this namespace.
Conclusion: These two XML snippets are not semantically equivalent.
If there was such a thing as an "expanded element name" syntax, then these XML snippets would look like ...
First one:
<{http://history.production.soap.webservices.product.company.at/}getMoldDataHistory>
<{}machineId>92623-15853588</{}machineId>
<{}start>0</{}start>
<{}end>0</{}end>
</{http://history.production.soap.webservices.product.company.at/}getMoldDataHistory>
Second one:
<{http://history.production.soap.webservices.product.company.at/}getMoldDataHistory>
<{http://history.production.soap.webservices.product.company.at/}machineId>92623-15853588</{http://history.production.soap.webservices.product.company.at/}machineId>
<{http://history.production.soap.webservices.product.company.at/}start>0</{http://history.production.soap.webservices.product.company.at/}start>
<{http://history.production.soap.webservices.product.company.at/}end>0<{/http://history.production.soap.webservices.product.company.at/}end>
</{http://history.production.soap.webservices.product.company.at/}getMoldDataHistory>
Upvotes: 2