Mr Asker
Mr Asker

Reputation: 2380

Exception in thread "main" com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server

I am trying to learn the SOAP protocol. So after generating the net.webservicex code with the aid of the wsimport by using the folowing command

C:\Program Files\Java\jdk1.8.0_74\bin>wsimport -keep -s src http://www.webservicex.net/geoipservice.asmx?WSDL

I placed the generated code in my project (Please take a look at the screen shoot underneath). I have added some the ip of google in run configurations --> java application --> arguments --> programm arguments--> 216.58.213.238

But when executing the main method in the IPLocationFinder class, I am getting the following error:

IPLocationFinder class

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 in one IP address");
        } else {
            String ipAddress = args[0];
            GeoIPService ipService = new GeoIPService();
            GeoIPServiceSoap geoIPServiceSoap = ipService.getGeoIPServiceSoap();
            // Here is line 14.
            GeoIP geoIP  = geoIPServiceSoap.getGeoIP(ipAddress);
            System.out.println(geoIP.getCountryName());
        }
    }
}

error

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(Unknown Source)
    at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.StubHandler.readResponse(Unknown Source)
    at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(Unknown Source)
    at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
    at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
    at com.sun.proxy.$Proxy31.getGeoIP(Unknown Source)
    at IPLocationFinder.main(IPLocationFinder.java:14)

enter image description here

enter image description here

Upvotes: 2

Views: 12641

Answers (3)

Barani r
Barani r

Reputation: 2367

This may also due to something wrong in the soap request that is getting passed. For example: the request username or password value might be having extra "\" or some other character. You can validate it using the SOAPUI and correct the request in the code.

Upvotes: 0

Silfrede
Silfrede

Reputation: 1

This question is pretty challenging to analyze; However this exceptions simple means the service client Soap web services does not longer support the request. You are probably using the latest JDK version where the client is using the oldest one.

For example: I was using JDK1.8 and the client use jdk1.6 also the JavaBrains uses JDK 1.6.

Solution: Check the JDK version on you computer

Upvotes: 1

krsna
krsna

Reputation: 4353

Some addresses will not appear in the database and therefore cannot be mapped. This is one of the limitation of IP Address location (Geolocation).

You should try with this IP Address 212.58.246.79

It should display "United Kingdom"

You can read more about geolocation in general here: https://www.lifewire.com/does-ip-address-geolocation-really-work-818154

Hope this helps you.

Upvotes: 2

Related Questions