質問

I am trying to write a code to consume a web service found at: http://www.webservicex.net/ws/WSDetails.aspx?CATID=12&WSID=64

I've used Axis2's WSDL2Java.bat tool and had two Java files generated:

  • GeoIPServiceStub.java
  • GeoIPServiceCallbackHandler.java

I've imported these, as well as the axis 'lib' folder into my project.

This is the code I'm using:

    GeoIPServiceStub stub = new GeoIPServiceStub();

    GetGeoIP geoIP = new GetGeoIP();

    geoIP.setIPAddress("X.X.X.X");
    GetGeoIPResponse reponse = stub.getGeoIP(geoIP);

When I try running it, it throws an InstantiationError.

Many thanks in advance!

役に立ちましたか?

解決

you are trying to instantiate an abstract class or interface. that's why InstantiationError is thrown.

As per the docs, it is stated as follows

public class InstantiationError extends IncompatibleClassChangeError

Thrown when an application tries to use the Java new construct to instantiate an abstract class or an interface.Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top