问题描述
我想打使用Axis2以下Web服务:
I am trying to hit the following web service with axis2: http://www.webservicex.net/geoipservice.asmx?WSDL
我有本地的Axis2和我产生我的课通过下载WSDL到本地驱动器并运行:
I have Axis2 locally, and I generated my classes by downloading the wsdl to my local drive and running:
./wsdl2java.sh -uri geoipservice.wsdl -p geoip -d xmlbeans -s -o geoip
这产生在它的build.xml文件,然后我跑了进来蚁族一个build目录,并产生libs文件夹中的客户机罐子。
This produced a build directory with a build.xml file in it, which i then ran "ant" in, and it produced a client jar in the libs folder.
我放弃了这个罐子到类路径,然后我尝试使用以下code打服务:
I dropped this jar onto my classpath, and then I tried to hit the service using the following code:
GeoIPServiceStub stub = new GeoIPServiceStub("http://www.webservicex.net/geoipservice.asmx?WSDL");
GetGeoIPDocument req = GetGeoIPDocument.Factory.newInstance();
GetGeoIP gic = req.addNewGetGeoIP();
gic.setIPAddress("74.125.91.105"); // google.com
GetGeoIPResponseDocument resp = stub.getGeoIP(req);
System.out.println(resp.getGetGeoIPResponse().toString());
事情似乎在第一次运行,我看到回来syslog中的结果,但它完成之前,抛出此异常:
Things seem to run at first, and I see the results coming back in the syslog, but before it finishes it throws this exception:
java.lang.NoSuchMethodError: org.apache.axiom.om.impl.OMStAXWrapper.<init>(Lorg/apache/axiom/om/OMXMLParserWrapper;Lorg/apache/axiom/om/OMElement;Z)V
at org.apache.axiom.om.impl.llom.OMStAXWrapper.<init>(OMStAXWrapper.java:52)
at org.apache.axiom.om.impl.llom.OMElementImpl.getXMLStreamReader(OMElementImpl.java:795)
at org.apache.axiom.om.impl.llom.OMElementImpl.getXMLStreamReaderWithoutCaching(OMElementImpl.java:765)
at geoip.GeoIPServiceStub.fromOM(GeoIPServiceStub.java:767)
at geoip.GeoIPServiceStub.getGeoIP(GeoIPServiceStub.java:325)
我GOOGLE了全国各地,并一直没能找到是什么原因造成这一点。谁能帮我找到我做错了什么?谢谢你。
I've googled all over and haven't been able to find what is causing this. Can anyone help me find what I'm doing wrong? Thank you.
推荐答案
您获得NoSuchMethodErrors如果你的编译器使用不同的类定义(编译期间)来创建.class文件,然后在JVM运行时。
You get NoSuchMethodErrors if your compiler used a different class definition (during compilation) to create your .class file then the jvm has at runtime.
在你的情况,它遗漏了 org.apache.axiom.om.impl.OMStAXWrapper(org.apache.axiom.om.OMXMLParserWrapper,org.apache.axiom.om.OMElement)构造函数
In your case, it misses the constructor for org.apache.axiom.om.impl.OMStAXWrapper(org.apache.axiom.om.OMXMLParserWrapper, org.apache.axiom.om.OMElement)
这可能意味着你打错org.apache.axiom库某处类路径中。
It probably means you have the wrong org.apache.axiom library somewhere on your classpath.
这篇关于Apache的Axis2中试图打Web服务时抛出的NoSuchMethodError?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!