Axis2的wsdl2java在RPC /编码样式的Web服务上失败

问题描述 投票:11回答:8

Axis2还有其他选择吗?或者让它工作的方式(例如,不同的数据绑定)?

Retrieving document at '...'.
Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:271)
        at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
        at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
        at org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension.engage(SimpleDBExtension.java:53)
        at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:224)
        ... 2 more
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension.engage(SimpleDBExtension.java:50)
        ... 3 more
Caused by: org.apache.axis2.schema.SchemaCompilationException: can not find type {http://schemas.xmlsoap.org/soap/encoding/}Array from the parent schema ...        at org.apache.axis2.schema.SchemaCompiler.copyMetaInfoHierarchy(SchemaCompiler.java:1296)
        at org.apache.axis2.schema.SchemaCompiler.processComplexContent(SchemaCompiler.java:1258)
        at org.apache.axis2.schema.SchemaCompiler.processContentModel(SchemaCompiler.java:1153)
        at org.apache.axis2.schema.SchemaCompiler.processComplexType(SchemaCompiler.java:1097)
        at org.apache.axis2.schema.SchemaCompiler.processNamedComplexSchemaType(SchemaCompiler.java:1017)
        at org.apache.axis2.schema.SchemaCompiler.processSchema(SchemaCompiler.java:931)
        at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:766)
        at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:552)
        at org.apache.axis2.schema.SchemaCompiler.process(SchemaCompiler.java:1991)
        at org.apache.axis2.schema.SchemaCompiler.processParticle(SchemaCompiler.java:1874)
        at org.apache.axis2.schema.SchemaCompiler.processComplexType(SchemaCompiler.java:1081)
        at org.apache.axis2.schema.SchemaCompiler.processNamedComplexSchemaType(SchemaCompiler.java:1017)
        at org.apache.axis2.schema.SchemaCompiler.processSchema(SchemaCompiler.java:931)
        at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:766)
        at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:552)
        at org.apache.axis2.schema.SchemaCompiler.process(SchemaCompiler.java:1991)
        at org.apache.axis2.schema.SchemaCompiler.processParticle(SchemaCompiler.java:1874)
        at org.apache.axis2.schema.SchemaCompiler.processComplexType(SchemaCompiler.java:1081)
        at org.apache.axis2.schema.SchemaCompiler.processAnonymousComplexSchemaType(SchemaCompiler.java:980)
        at org.apache.axis2.schema.SchemaCompiler.processSchema(SchemaCompiler.java:934)
        at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:592)
        at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:563)
        at org.apache.axis2.schema.SchemaCompiler.compile(SchemaCompiler.java:370)
        at org.apache.axis2.schema.SchemaCompiler.compile(SchemaCompiler.java:280)
        at org.apache.axis2.schema.ExtensionUtility.invoke(ExtensionUtility.java:103)
        ... 8 more

注意:Apache CXF也失败了:(

java axis2 axis wsdl2java jax-rpc
8个回答
9
投票

我发现只有3个选项可以在Java中用于旧式rpc /编码Web服务:

1)SUN的JAX-RPC参考实现(wscompile)

2)WebLogic clientgen(我使用的是8.1版本)

v)Valid1 v1.4 wsdl2java

最初我们使用了Axis 1.4,它在相对较大的服务响应(> 20k)上表现出相当差的性能,即与没有解析的普通HTTP请求相比,客户端处理时间增加了两倍以上。如果响应变大,时间会增加。只需30多秒即可将1MB大容量反序列化。

SUN生成的客户端并没有真正起作用,并且根据请求失败并显示以下消息:

unexpected element name: 
   expected=getSubscriberInfoReturn, 
   actual={ws.generated.api}getSubscriberInfoReturn

我尝试过使用WebLogic的8.1 ​​clientgen,并将客户端代码与Axis 1.4生成的客户端性能进行了比较。 Axis赢得了比赛。因此,即使Axis客户端在相对较大的响应上表现不佳,它仍然是旧的rpc /编码Web服务的最佳选择:(。


4
投票

Axis2不支持RPC编码。资料来源:http://wiki.apache.org/ws/StackComparison


1
投票

试试Axis 1,我已经将它用于了这个原因。


1
投票

我在axis2中也遇到过SimpleDataBinding的问题。我通过使用AxisDataBinding选项解决了它们。从编码的角度来看,这有点重,但毕竟是有效的。

ADB in detail

此外,我同意罗伯特,说明axis1也是一个有趣的选择。


0
投票

我不打算深入研究这个,但是因为你要求替代方案:

Java 6 SE和Java 5 EE附带Metro JAX-WS(参考)实现。

它位于javax.xml.ws命名空间中。

Sun的开发者网络有一篇可能有用的文章Introducing JAX-WS 2.0 With the Java SE 6 Platform

说完这一切,Eclipse不是很JAX-WS friendly


0
投票

您可以为wsdl2java命令添加以下参数

-d xmlbeans

0
投票

如果soap编码样式是旧的axis2 wsdl2java或wsimport无法理解旧的RPC编码样式,那么这个问题就会引发因此使用轴1.4或更早版本的轴回退就是你不会找到wsdl2java作为旧轴的工具而不是你将在轴jar文件中找到它作为类文件,因此你必须手动设置类路径并使用该类

D:\ axis-1_4 \ lib> java -classpath \ axis-1_4 \ lib * org.apache.axis.wsdl.WSDL2Java urwsdl


0
投票

关于so​​apenc.xsd的答案​​帖子在这里找到Clickatell SOAP wsdl to JAXB java classes帮助了我。

我使用的是axis1.5的wsdl2java实用程序,我们在数组上得到了类似的错误。

Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
            at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:271)
            at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
            at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
    Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
            at org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension.engage(SimpleDBExtension.java:53)
            at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:224)
            ... 2 more
    Caused by: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension.engage(SimpleDBExtension.java:50)
            ... 3 more
    Caused by: org.apache.axis2.schema.SchemaCompilationException: can not find type {http://schemas.xmlsoap.org/soap/encoding/}Array from the parent schema ....
            at org.apache.axis2.schema.SchemaCompiler.copyMetaInfoHierarchy(SchemaCompiler.java:1296)
            at org.apache.axis2.schema.SchemaCompiler.processComplexContent(SchemaCompiler.java:1258)
            at org.apache.axis2.schema.SchemaCompiler.processContentModel(SchemaCompiler.java:1153)
            at org.apache.axis2.schema.SchemaCompiler.processComplexType(SchemaCompiler.java:1097)
            at org.apache.axis2.schema.SchemaCompiler.processNamedComplexSchemaType(SchemaCompiler.java:1017)

我尝试通过使用网站'http://schemas.xmlsoap.org/soap/encoding/'中的内容创建soapenc.xsd来更新我的wsdl文件。如下图所示,这对我来说非常有用。

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1= .. xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns=.. xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace=..>
<types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace=.. xmlns:ns1=.. xmlns:ns2=.. xmlns:tns=.. xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"/>
</types>
<import location="soapenc.xsd" namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<message name="Input">
    <part name=../>
</message>
<message name="Output">
    <part name=../>
</message>
<portType name=".."> .. </portType>
<binding name="..." type="tns:"..">
    <operation name="...">          ..          </operation>
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
</binding>
<service name="...">
    <port binding="tns:..." name="...">         <soap:address location="..."/>      </port>
</service>

© www.soinside.com 2019 - 2024. All rights reserved.