简体   繁体   English

从WSDL生成Java代码

[英]Generating Java Code from WSDL

I have to generate Java code from a wsdl file. 我必须从wsdl文件生成Java代码。 Currently my project uses wsimport, but the wsdl file for which I have to generate code has RPC encoding. 当前,我的项目使用wsimport,但是必须为其生成代码的wsdl文件具有RPC编码。 wsimport has no support for RPC. wsimport不支持RPC。 I tried using axis but it fails with following error: 我尝试使用轴,但失败并显示以下错误:

soap:fault element not recognized for soap 1.2 binding soap 1.2绑定无法识别出soap:fault元素

I found a jira already for this issue: https://issues.apache.org/jira/browse/AXIS-2614 我已经找到此问题的吉拉: https : //issues.apache.org/jira/browse/AXIS-2614

axis2 doesn't support RPC. axis2不支持RPC。 Is there any other way I can generate the code from the wsdl using maven. 还有什么其他方法可以使用maven从wsdl生成代码。

You could try using JAX-RPC instead of axis 您可以尝试使用JAX-RPC而不是axis

http://docs.oracle.com/javaee/1.3/tutorial/doc/IntroWS5.html http://docs.oracle.com/javaee/1.3/tutorial/doc/IntroWS5.html

You can also use Axis1 framework. 您也可以使用Axis1框架。 It is old, but available on https://axis.apache.org/axis There you can find a tool called wsdl2Java, which you can execute like: 它很旧,但是可以在https://axis.apache.org/axis上找到。您可以在这里找到一个名为wsdl2Java的工具,可以像下面这样执行:

java -cp <all jars of the framework> \
org.apache.axis.wsdl.WSDL2Java \
-p <destination package name> \
-o <destination src path> \
http://[Servername]/MyService?wsdl

This generates all classes from the wsdl service description file. 这将从wsdl服务描述文件生成所有类。 Then you can use the Stub classes to access the service. 然后,您可以使用Stub类访问服务。

The last snapshot version you can find on https://builds.apache.org/job/axis-trunk Click on "Last Build" and then on "Distribution" (or Maven Plugin). 您可以在https://builds.apache.org/job/axis-trunk上找到的最后一个快照版本。单击“ Last Build”,然后单击“ Distribution”(或Maven插件)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM