0

I was trying out an soap weservice example. The code uses GeoIp webservice to determine the country from an ip address. When I am executing the code, I am getting the below exception.

exception:

Exception in thread "main" com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.NullReferenceException: Object reference not set to an instance of an object.
at WebserviceX.Service.Adapter.IPAdapter.CheckIP(String IP)
at WebserviceX.Service.GeoIPService.GetGeoIP(String IPAddress)
--- End of inner exception stack trace --- Please see the server log to find more detail regarding exact cause of the failure.
    at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(SOAP11Fault.java:178)
    at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(SOAPFaultBuilder.java:116)
    at com.sun.xml.internal.ws.client.sei.StubHandler.readResponse(StubHandler.java:238)
    at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:189)
    at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(DatabindingImpl.java:276)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:104)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:77)
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(SEIStub.java:147)
    at com.sun.proxy.$Proxy31.getGeoIP(Unknown Source)
    at org.manjosh.demo.IPlocationFinder.main(IPlocationFinder.java:19)

My code:

import net.webservicex.GeoIP;
import net.webservicex.GeoIPService;
import net.webservicex.GeoIPServiceSoap;

public class IPlocationFinder {

    public static void main(String[] args) {

        if (args.length != 1){
            System.out.println("you need to pass atleast 1 IP address");
        }
        else
        {
            String ipAddress = args[0];
            GeoIPService ipService = new GeoIPService();
            GeoIPServiceSoap geoIpserviceSoap = ipService.getGeoIPServiceSoap();
            GeoIP geoIp = geoIpserviceSoap.getGeoIP(ipAddress);
            System.out.println((String)geoIp.getCountryName());
        }
    }

}   
3
  • Try this IP 212.58.246.79 and see if you get UK. If you do it means that the IP you entered cannot be mapped. It is a poor service as many are missing. There are free databases out there with thousands of IPs. I found one of them and I do my lookup in my own MySQL instead of relying on web services. Commented Jun 24, 2017 at 16:14
  • Exception says what happened. You reached host, you sent your request, but it is not good for the service, or something wrong inside it. To dig further you need to capture what exactly you sent and what is actual Soap fault. Try to use SOAPUI and tcpMonitor. When you make SOAPUI works you can compare your code request and working SOAPUI request. Commented Jun 24, 2017 at 16:27
  • thanks, it works for UK. Commented Jun 25, 2017 at 13:41

1 Answer 1

1

Use soapui create xml and send request, if you get response in sopui first. Then check xml that you are sending as request contains all fields and matches one in soapui request.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.