试图找出为什么这两个SOAP请求之一不起作用(java.lang.IllegalArgumentException)

我有一个正在运行的JAX-WS Web服务,它已经有一些工作端点。 现在我遇到以下问题:

我在这里有两个不同的SOAP请求,我不明白为什么第一个工作,但第二个不工作。

请求中唯一明显的区别是第一个在标记中指定了一个名称空间,而第二个在调用方法时指定了它。

SOAP请求1 – 不工作(在方法调用中指定了命名空间)

    92623-15853588 0 0    

SOAP请求2 – 工作(名称空间在标记中指定)

     92623-15853588 0 0    

我在做第一个(不工作)请求时得到的SOAP错误消息。

    S:Server java.lang.IllegalArgumentException    

接收第一个SOAP请求时从服务器抛出的exception的堆栈跟踪。

 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) 

所以我基本上试图弄清楚为什么第一个请求不起作用,尽管它是一个有效的SOAP请求。 我需要在我的服务器上配置什么才能允许这样的请求吗?

编辑:

在做了一些测试之后,我发现命名空间声明的位置无关紧要,如果我调用的方法有0个参数。 一旦需要参数,它就会停止工作。

编辑2:

现在我在这里解决了这个问题 。 我有同样的问题。 发出请求的我的C#客户端不使用方法TAG中的命名空间。 添加后它就可以了。

我怎么能告诉JAX-WS处理这个问题。

不起作用:

  

作品:

  

当使用绑定到命名空间的前缀时,如

  92623-15853588 0 0  

然后只将元素getMoldDataHistory放入指定的命名空间。 原因是语法xmlns:his="..."仅声明前缀。 然后必须在您希望在指定命名空间中的所有元素上使用它。 在此代码段中,唯一的元素是getMoldDataHistory

使用xmlns="..."语法,如

  92623-15853588 0 0  

不仅声明了命名空间,还将关联的元素和所有子元素放入此命名空间。

结论:这两个XML片段在语义上不相同。

如果存在“扩展元素名称”语法这样的东西,那么这些XML片段看起来像……

第一:

 <{http://history.production.soap.webservices.product.company.at/}getMoldDataHistory> <{}machineId>92623-15853588 <{}start>0 <{}end>0  

第二个:

 <{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/}start>0 <{http://history.production.soap.webservices.product.company.at/}end>0<{/http://history.production.soap.webservices.product.company.at/}end>