Wednesday, December 4, 2013

NullPointerException while calling A web service with a non null soap messge

<An issue whose reason was known>

The issue that I faced was as follows:

1- I was calling a web service providing it a non null soap message.
2- I am not the one who creates the soap message, I am using a certain kind of engine (or wizard) that parses the WSDL, asks for the method that I want to call on the WS, asks for the parameters and then it creates the SOAP message on its own and sends the SOAP request.
3- The response returned was the cute "NullPointerException"
4- I asked the team responsible for handling the called Web Service to check their logs and tell me wither my request was processed or not and tell me what resulted this response.
5- They told me that the request sent was null although I was sure that the request was sent with values

The Solution strategy I followed:

1- First I used Soap UI to check that I was able to call the WS and that it was working fine, And after trying I found that it was working fine, then I realised that the problem is in the wizard that generates the soap message, either it generates nothing or generates a wrong message.
2-I used Wireshark to track the Soap message sent, In the Filter text box, I specified the port on which the WS is called, (tcp.port == 31112)

3-I started trying again and the http request appeared in the wireshark, I opened it (right click- Follow TCP stream) and took the request body copy paste to SOAP UI.

4- I tried calling the WS with that SOAP message -note in the picture, Request1 is the one generated by Soap UI, Request2 is the one I got from wireshark(the message sent actuallty)
You can note the difference in the SOAP message format, this is the cause of the error, the web service couldn't recognize this malformed SOAP message, so as  if it's null.

I used a work around to call this webservice - instead of using this wizard, I used normal java client generated from jboss JAXWS

The aim of this topic was mainly to discuss the problem symptoms, cause and the tools used for its detection more than the solution you will use since the solution depends mainly on the system you are actually using - for me I was using a wizard tool that's like an eclipse plugin, for some one else you might be able to change the format of the SOAP message or even the structure of the web service itself.

Hope it helps :)

No comments:

Post a Comment