Java AXIS2 Web服务客户端(Java AXIS2 web

编程入门 行业动态 更新时间:2024-10-17 23:21:24
Java AXIS2 Web服务客户端(Java AXIS2 web-service client)

我正在尝试编写一个代码来使用Web服务: http : //www.webservicex.net/ws/WSDetails.aspx?CATID = 12&WSID = 64

我使用了Axis2的WSDL2Java.bat工具并生成了两个Java文件:

GeoIPServiceStub.java GeoIPServiceCallbackHandler.java

我已将这些以及轴'lib'文件夹导入到我的项目中。

这是我正在使用的代码:

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

当我尝试运行它时,它会抛出一个InstantiationError

提前谢谢了!

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!

最满意答案

您正在尝试实例化抽象类或接口。 这就是抛出InstantiationError的原因。

根据文档,它陈述如下

公共类InstantiationError扩展了IncompatibleClassChangeError

当应用程序尝试使用Java新构造来实例化抽象类或接口时抛出。通常,编译器会捕获此错误; 如果类的定义不兼容地更改,则此错误只能在运行时发生。

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.

更多推荐

本文发布于:2023-08-07 11:16:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464507.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:客户端   Java   web   Web

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!