Web 服务客户端之间的差异导致一次成功(JAXWS) 一次错误(AXIS)

发布于 2024-12-13 17:43:39 字数 4744 浏览 7 评论 0原文

Web 服务客户端之间的差异导致一成功一错误 我在 tomcat 上使用 JAXWS 2.2 基于 wsdl 构建了 Web 服务。
基于这个 wsdl,我创建了运行良好的客户端。
但是当我从外部客户端获取 Web 服务时,我在服务器上收到错误,我嗅探了网络,发现存在差异 但我不知道它们主要是命名空间有多重要,正如我从嗅探外部请求中看到的那样,我看到它们使用 AXIS 来构建客户端。
对于我收到的 tomcat 异常,我知道根据服务器端的日志,它到达了服务,但在存根方法之一中失败 这是我的有效客户端服务:

POST /console/ws/APIEndpoint HTTP/1.1
Accept: text/xml, multipart/related
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://foo.com/ServerApi/sendMessageRequest"
User-Agent: JAX-WS RI 2.2.5-b01 
Host: 192.168.3.69:18112
Connection: keep-alive
Content-Length: 1221

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns3:sendMessage xmlns:ns2="http://www.foo.com" xmlns:ns3="http://www.foo.com/">
<NP_MESSAGE>
<ns2:HEADER>
<REQUEST_ID>NPAABBYYMMDDXXXXXZZZZ</REQUEST_ID>
<PROCESS_TYPE>PORT</PROCESS_TYPE>
<MSG_TYPE>Publish</MSG_TYPE>
<TRX_NO>MI000004548992</TRX_NO>
<VERSION_NO>1</VERSION_NO>
<RETRY_NO>2</RETRY_NO>
<RETRY_DATE>2011-11-03T11:48:23.769+02:00</RETRY_DATE>
<FROM>MI</FROM>
<TO>aa</TO>
</ns2:HEADER>
<BODY>
</BODY>
</NP_MESSAGE>
</ns3:sendMessage>
</S:Body>
</S:Envelope>

现在这是来自外部客户端的无效请求:

POST /console/ws/APIEndpoint HTTP/1.1
Host: 46.31.96.42:18112
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "http://foo.com/sendMessage"
Content-Length: 1197

Max-Forwards: 10
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<sendMessage xmlns="http://foo.com/">
<NP_MESSAGE>
<ns1:HEADER xmlns:ns1="http://foo.com">
<REQUEST_ID xmlns="">NPMICL111103350390001
</REQUEST_ID>
<PROCESS_TYPE xmlns="">PORT</PROCESS_TYPE>
<MSG_TYPE xmlns="">Publish</MSG_TYPE>
<TRX_NO xmlns="">MI000004554248</TRX_NO>
<VERSION_NO xmlns="">1</VERSION_NO>
<RETRY_NO xmlns="">2</RETRY_NO>
<RETRY_DATE xmlns="">2011-11-03T13:00:06.659+02:00</RETRY_DATE>
<FROM xmlns="">MI</FROM>
<TO xmlns="">TZ</TO>
</ns1:HEADER>
<BODY xmlns="">
</BODY>
</NP_MESSAGE>
</sendMessage>
</soapenv:Body>
</soapenv:Envelope> 

我从 tomcat 收到的异常如下所示:

 03/11/2011 12:33:43 com.sun.xml.ws.server.sei.EndpointMethodHandler invoke
SEVERE: null
java.lang.NullPointerException
        at com.foo.gw.ServiceApi.sendMessage(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.sun.xml.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:250)
        at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:150)
        at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:261)

并且 tomcat 返回:HTTP/1.1 500 Internal Server Error< /code>

我注意到在标题中 它们之间缺少一些参数,但在阅读了一些信息后,我不认为这是原因。因为请求确实到达了 tomcat 中的服务

更新:
这是我遇到异常的地方,我无法仅调试分散日志 这是我的服务类的样子:

更新 2:
我知道 NP_MESSAGE 为空,但为什么我可以看到它从客户端获取数据

@WebService (targetNamespace="http://www.foo.com/")
public class Api {  
    Api()
    {

    }
    @WebResult(name="return_NP_ACK", partName="return_NP_ACK")
    @WebMethod(operationName = "sendMessage")
    public NPACK sendMessage(@WebParam(name = "NP_MESSAGE")NPMESSAGE NP_MESSAGE)
    {
    if(null != NP_MESSAGE)
{
    Logger.WriteLog("WebService NP_MESSAGE not null ",Level.DEBUG);


}
else
{
     //  I know that NP_MESSAGE is null im getting here !!!
    Logger.WriteLog("WebService NP_MESSAGE is null ",Level.DEBUG);
}
    HEADER hHeader = NP_MESSAGE.getHEADER();  <-- here is where the exception 
    ....
    ...
    }
}

更新 3:
我发现了一些东西,但我不确定是否是我的情况。如果是的话。我该如何解决这个问题。 这是讨论 AX-RPC 与 JAX-WS 的链接。如果这是我的情况,我不完全了解。 不是每个 WS 框架都应该总是从 wsdl 创建存根,无论它做了什么,都可以说话,就像 CORBA 那样的契约。从来不是我的..
无论如何我该如何解决它,我没有选择与 AXIS 合作。我不能告诉 JAXWS 使用轴协议吗?

difference between web services clients results in one error in one success
I have web service I build using JAXWS 2.2 on tomcat , based on wsdl .
Based on this wsdl I created client that works great .
But when I getting web services from external client im getting errors on server , I sniffed the network , and I saw there are differences
But I don’t know how critical they are mostly namespaces , as I see from sniffin the external request I see they used AXIS to build the client .
For the tomcat exception im getting , I know according to the logs on the server side it gets to the service but fails in one of the stubs methods
Here is my client service that works:

POST /console/ws/APIEndpoint HTTP/1.1
Accept: text/xml, multipart/related
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://foo.com/ServerApi/sendMessageRequest"
User-Agent: JAX-WS RI 2.2.5-b01 
Host: 192.168.3.69:18112
Connection: keep-alive
Content-Length: 1221

<?xml version='1.0' encoding='UTF-8'?>
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns3:sendMessage xmlns:ns2="http://www.foo.com" xmlns:ns3="http://www.foo.com/">
<NP_MESSAGE>
<ns2:HEADER>
<REQUEST_ID>NPAABBYYMMDDXXXXXZZZZ</REQUEST_ID>
<PROCESS_TYPE>PORT</PROCESS_TYPE>
<MSG_TYPE>Publish</MSG_TYPE>
<TRX_NO>MI000004548992</TRX_NO>
<VERSION_NO>1</VERSION_NO>
<RETRY_NO>2</RETRY_NO>
<RETRY_DATE>2011-11-03T11:48:23.769+02:00</RETRY_DATE>
<FROM>MI</FROM>
<TO>aa</TO>
</ns2:HEADER>
<BODY>
</BODY>
</NP_MESSAGE>
</ns3:sendMessage>
</S:Body>
</S:Envelope>

and now this is the request from external client that doesn't work:

POST /console/ws/APIEndpoint HTTP/1.1
Host: 46.31.96.42:18112
Content-Type: text/xml; charset=utf-8
Accept: application/soap+xml, application/dime, multipart/related, text/*
User-Agent: Axis/1.4
Cache-Control: no-cache
Pragma: no-cache
SOAPAction: "http://foo.com/sendMessage"
Content-Length: 1197

Max-Forwards: 10
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<sendMessage xmlns="http://foo.com/">
<NP_MESSAGE>
<ns1:HEADER xmlns:ns1="http://foo.com">
<REQUEST_ID xmlns="">NPMICL111103350390001
</REQUEST_ID>
<PROCESS_TYPE xmlns="">PORT</PROCESS_TYPE>
<MSG_TYPE xmlns="">Publish</MSG_TYPE>
<TRX_NO xmlns="">MI000004554248</TRX_NO>
<VERSION_NO xmlns="">1</VERSION_NO>
<RETRY_NO xmlns="">2</RETRY_NO>
<RETRY_DATE xmlns="">2011-11-03T13:00:06.659+02:00</RETRY_DATE>
<FROM xmlns="">MI</FROM>
<TO xmlns="">TZ</TO>
</ns1:HEADER>
<BODY xmlns="">
</BODY>
</NP_MESSAGE>
</sendMessage>
</soapenv:Body>
</soapenv:Envelope> 

the exception im getting from the tomcat looks like this :

 03/11/2011 12:33:43 com.sun.xml.ws.server.sei.EndpointMethodHandler invoke
SEVERE: null
java.lang.NullPointerException
        at com.foo.gw.ServiceApi.sendMessage(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.sun.xml.ws.api.server.InstanceResolver$1.invoke(InstanceResolver.java:250)
        at com.sun.xml.ws.server.InvokerTube$2.invoke(InvokerTube.java:150)
        at com.sun.xml.ws.server.sei.EndpointMethodHandler.invoke(EndpointMethodHandler.java:261)

and the tomcat returns : HTTP/1.1 500 Internal Server Error

i notice that in the header the
some parameters are missing between them but after reading some info i don't thing its the reason. beacose the request do get to the service in tomcat

UPDATE:
here is where i thing im getting the exception , i can't debug only scatter logs
here is how my service class looks like :

UPDATE 2:
i know that the NP_MESSAGE is null but why i can see it get data when it comes from the client

@WebService (targetNamespace="http://www.foo.com/")
public class Api {  
    Api()
    {

    }
    @WebResult(name="return_NP_ACK", partName="return_NP_ACK")
    @WebMethod(operationName = "sendMessage")
    public NPACK sendMessage(@WebParam(name = "NP_MESSAGE")NPMESSAGE NP_MESSAGE)
    {
    if(null != NP_MESSAGE)
{
    Logger.WriteLog("WebService NP_MESSAGE not null ",Level.DEBUG);


}
else
{
     //  I know that NP_MESSAGE is null im getting here !!!
    Logger.WriteLog("WebService NP_MESSAGE is null ",Level.DEBUG);
}
    HEADER hHeader = NP_MESSAGE.getHEADER();  <-- here is where the exception 
    ....
    ...
    }
}

UPDATE 3:
i found something but im not sure if its my case . and if it. how can i fix this .
this is link that talks about AX-RPC versus JAX-WS . i don't have the full knowledge if this is my case .
doesn't every WS framework suppose to always create stubs from wsdl that can talk no mater what did it , like contract like CORBA. never mine ..
any way how do i fix it , i don't have option to work with AXIS . can't i just tell JAXWS to work with the axis protocol ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

宣告ˉ结束 2024-12-20 17:43:39

我认为问题出在轴消息中:

<sendMessage xmlns="http://foo.com/">
<NP_MESSAGE>

因为 xmlns 定义定义了默认命名空间,所以 NP_MESSAGE 元素现在也在该命名空间中定义。但是,在 jaxws 消息中,没有默认命名空间,因此 NP_MESSAGE 元素没有命名空间。

您可以尝试将所有元素(WebParam、WebResult)放在与 WebService 相同的 targetNamespace 中。

i think the problem is here in the axis message:

<sendMessage xmlns="http://foo.com/">
<NP_MESSAGE>

because the xmlns definition defines the default namespace, the NP_MESSAGE element is now also defined in that namespace. however, in the jaxws message, there is no default namespace, so the NP_MESSAGE element has no namespace.

you might try putting all your elements (WebParam, WebResult) in the same targetNamespace as your WebService.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文