user63898
user63898

Reputation: 30895

difference between web services clients results in one error(AXIS) in one success(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 ?

Upvotes: 0

Views: 4791

Answers (1)

jtahlborn
jtahlborn

Reputation: 53694

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.

Upvotes: 1

Related Questions