简体   繁体   English

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

[英]Trying to find out why one of those two SOAP requests does not work (java.lang.IllegalArgumentException)

I have a running JAX-WS webservice which already has some working endpoints. 我有一个正在运行的JAX-WS Web服务,该服务已经有一些正常工作的端点。 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. 我在这里有两个不同的SOAP请求,但我不明白为什么第一个有效,而第二个无效。

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> . 请求中唯一明显的区别是,第一个在<Envelope>标记中指定了名称空间,而第二个在调用方法<getMoldDataHistory>时指定了名称空间。

SOAP Request 1 - Not Working (Namespace is specified at the method call) SOAP请求1-不起作用(在方法调用中指定了名称空间)

<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) SOAP请求2-工作(在<Envelope>标记中指定了名称空间)

<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. 发出第一个(不起作用)请求时收到的SOAP错误消息。

<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. 接收第一个SOAP请求时从服务器引发的异常的stacktrace。

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. 所以我基本上是想弄清楚为什么第一个请求尽管是有效的SOAP请求却无法正常工作。 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. 经过更多测试后,我发现如果我调用的方法具有0个参数,则名称空间声明的位置无关紧要。 As soon as parameter is required it stops working. 一旦需要参数,它将停止工作。

EDIT 2: 编辑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. 发出请求的C#客户端未在TAG方法中使用命名空间。 After I add it it works. 添加后,它可以工作。

Still how can I tell JAX-WS to deal with this. 我仍然如何告诉JAX-WS处理此问题。

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/">

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. 然后仅将元素getMoldDataHistory放入指定的名称空间。 The reason is that the syntax xmlns:his="..." only declares the prefix. 原因是语法xmlns:his="..."仅声明前缀。 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 . 在此代码段中,唯一的元素是getMoldDataHistory

Using the xmlns="..." syntax like in 使用xmlns="..."语法,例如

<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. 结论:这两个XML代码段在语义上并不等效。

If there was such a thing as an "expanded element name" syntax, then these XML snippets would look like ... 如果存在“扩展元素名称”语法之类的问题,那么这些XML代码段将看起来像...

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么会有java.lang.IllegalArgumentException? - Why is there an java.lang.IllegalArgumentException? 为什么会出现java.lang.IllegalArgumentException? - Why java.lang.IllegalArgumentException? 为什么 apache spark 不适用于 java 10? 我们得到非法反射然后 java.lang.IllegalArgumentException - Why apache spark does not work with java 10? We get illegal reflective then java.lang.IllegalArgumentException java.lang.IllegalArgumentException:“ json”不包含“ /” - java.lang.IllegalArgumentException: “json” does not contain '/' java.lang.IllegalArgumentException - java.lang.IllegalArgumentException java.lang.IllegalArgumentException - java.lang.IllegalArgumentException 尝试用Java播放音乐:java.lang.IllegalArgumentException:格式无效 - Trying to play music in Java: java.lang.IllegalArgumentException: Invalid format 为什么我得到java.lang.IllegalArgumentException:XPath为null时找不到元素错误消息 - Why do I get java.lang.IllegalArgumentException: Cannot find elements when the XPath is null error message 尝试检索文档数据中的“ java.lang.IllegalArgumentException” - “ java.lang.IllegalArgumentException ” from trying to retrieve document data 尝试运行clojure Web应用程序时出现java.lang.IllegalArgumentException - java.lang.IllegalArgumentException when trying to run a clojure web application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM