使用Axis2客户端代码

时间:2014-02-14 17:56:50

标签: web-services wso2 axis2

我使用的是WSO2 Dev Studio 3.5,我使用了Generate Axis2 Web Service Client功能来生成新的Axis2客户端。 Dev Studio为我创建了新项目并生成了Stub,但我不知道如何利用这个Stub。我在生成存根的同一个包中创建了新类,并在下面尝试了两种方法,但这都引入了错误:

AdderStub stub = new AdderStub()

错误:

Exception in thread "main" java.lang.NoClassDefFoundError: javax/wsdl/WSDLException
    at axis2.adder.AdderStub.populateAxisService(AdderStub.java:41)
    at axis2.adder.AdderStub.<init>(AdderStub.java:88)
    at axis2.adder.AdderStub.<init>(AdderStub.java:77)
    at axis2.adder.AdderStub.<init>(AdderStub.java:126)
    at axis2.adder.AdderStub.<init>(AdderStub.java:118)
    at axis2.adder.TestAdder.main(TestAdder.java:19)
Caused by: java.lang.ClassNotFoundException: javax.wsdl.WSDLException
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 6 more


AdderStub stub = new AdderStub(null, "http://localhost:9763/services/Adder");

错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/ws/commons/schema/utils/NamespacePrefixList
    at axis2.adder.AdderStub.populateAxisService(AdderStub.java:41)
    at axis2.adder.AdderStub.<init>(AdderStub.java:88)
    at axis2.adder.AdderStub.<init>(AdderStub.java:77)
    at axis2.adder.TestAdder.main(TestAdder.java:19)
Caused by: java.lang.ClassNotFoundException: org.apache.ws.commons.schema.utils.NamespacePrefixList
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 4 more

您能否帮助我使用WSO2 Dev Studio生成的Axis2客户端代码?感谢。

此致 仲

1 个答案:

答案 0 :(得分:-1)

这看起来像这个项目的Java类路径的问题。通常,在build.xml中可以在pom.xml中找到所需的依赖jar列表,​​如果是Ant,则可以找到。运行主类时需要包含这些内容。 对于前者第一个错误是因为类路径中缺少wsdl4j jar。