java:JAXWS 2.0 不支持 Rpc/编码的 wsdls
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/412772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
java: Rpc/encoded wsdls are not supported in JAXWS 2.0
提问by
I'm using CXF 2.1 to generate java code from a wsdl, but I'm getting the following error:
我正在使用 CXF 2.1 从 wsdl 生成 java 代码,但出现以下错误:
WSDLToJava Error: Rpc/encoded wsdls are not supported in JAXWS 2.0
org.apache.cxf.tools.common.ToolException: Rpc/encoded wsdls are not supported in JAXWS 2.0
at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.checkSupported(JAXWSDefinitionBuilder.java:141)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:87)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build(JAXWSDefinitionBuilder.java:61)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:127)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute(WSDLToJavaContainer.java:232)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool(ToolRunner.java:83)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run(WSDLToJava.java:103)
at org.apache.cxf.tools.wsdlto.WSDLToJava.main(WSDLToJava.java:173)
How do I fix this error, can I use a previous version of CXF or anything else to fix it?
如何修复此错误,我可以使用以前版本的 CXF 或其他任何东西来修复它吗?
回答by Chase Seibert
RPC/encoded is a vestige from before SOAP objects were defined with XML Schema. It's not widely supportedanymore. You will need to generate the stubs using Apache Axis 1.0, which is from the same era.
RPC/encoded 是使用 XML Schema 定义 SOAP 对象之前的遗迹。它不再受到广泛支持。您将需要使用来自同一时代的Apache Axis 1.0生成存根。
java org.apache.axis.wsdl.WSDL2Java http://someurl?WSDL
You will need the following jars or equivalents in the -cp classpath param:
您将需要 -cp 类路径参数中的以下 jars 或等效项:
- axis-1.4.jar
- commons-logging-1.1.ja
- commons-discovery-0.2.jar
- jaxrpc-1.1.jar
- saaj-1.1.jar
- wsdl4j-1.4.jar
- activation-1.1.jar
- mail-1.4.jar
- 轴1.4.jar
- commons-logging-1.1.ja
- commons-discovery-0.2.jar
- jaxrpc-1.1.jar
- saaj-1.1.jar
- wsdl4j-1.4.jar
- 激活-1.1.jar
- 邮件1.4.jar
This will generate similar stubs to wsimport.
这将生成与 wsimport 类似的存根。
Alternatively, if you are not using the parts of the schema that require rpc/encoded, you can download a copy of the WSDL and comment out those bits. Then run wsimport against the local file.
或者,如果您不使用需要 rpc/encoded 的架构部分,您可以下载 WSDL 的副本并注释掉这些位。然后对本地文件运行 wsimport。
If you look at the WSDL, the following bits are using rpc/encoded:
如果您查看 WSDL,以下位使用 rpc/encoded:
<soap:body use="encoded"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
回答by Rites
May be this would help with CXF. Alteast it worked for me.
I edited the WSDL file and removed all references of SOAP-ENC and created type ArrayOfString
in below way
可能这对 CXF 有帮助。Alteast 它对我有用。我编辑了 WSDL 文件并删除了 SOAP-ENC 的所有引用并ArrayOfString
以下面的方式创建了类型
<xsd:complexType name="ArrayOfString">
<xsd:sequence>
<xsd:element minOccurs="0" maxOccurs="unbounded" name="String" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
回答by Stephan
I used Axis 1.4 as Chase Seibert suggested in his answer, although the download link given in that answer doesn't work. The alternative download link I used gave me different libraries. Below are the steps I followed to generate my code.
我使用 Axis 1.4 作为 Chase Seibert 在他的回答中建议的,尽管该答案中给出的下载链接不起作用。我使用的替代下载链接给了我不同的库。以下是我生成代码所遵循的步骤。
Go to http://apache.is.co.za/axis/axis/java/1.4/and download axis-bin-1_4.zip.
转到http://apache.is.co.za/axis/axis/java/1.4/并下载axis-bin-1_4.zip。
Extract it, and you should have the following files (among others):
提取它,你应该有以下文件(以及其他文件):
- axis.jar
- commons-discovery-0.2.jar
- commons-logging-1.0.4.jar
- jaxrpc.jar
- saaj.jar
- wsdl4j-1.5.1.jar
- 轴文件
- commons-discovery-0.2.jar
- commons-logging-1.0.4.jar
- jaxrpc.jar
- 文件
- wsdl4j-1.5.1.jar
Execute WSDL2Java using the following command (replacing the URL, of course):
使用以下命令执行 WSDL2Java(当然是替换 URL):
java -cp axis.jar;commons-logging-1.0.4.jar;commons-discovery-0.2.jar;jaxrpc.jar;saaj.jar;wsdl4j-1.5.1.jar org.apache.axis.wsdl.WSDL2Java http://someURL?WSDL
This will generate your Java files.
这将生成您的 Java 文件。
P.S.:This seems to work equally well using Axis 1.2.1.
PS:这似乎在使用 Axis 1.2.1 时同样有效。
回答by Ming Yuan
just extract,and Execute WSDL2Java? using the following command (replacing the URL, of course):
只是提取,并执行 WSDL2Java?使用以下命令(当然是替换 URL):
java -cp axis.jar;commons-logging-1.0.4.jar;commons-discovery-0.2.jar;jaxrpc.jar;saaj.jar;wsdl4j-1.5.1.jar org.apache.axis.wsdl.WSDL2Java http://someURL?WSDL
回答by Foyta
In case someone would like to use maven: (plus heresome info about WSDL binding styles)
如果有人想使用 maven :(在这里加上一些关于 WSDL 绑定样式的信息)
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>axistools-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>wsdl2java</goal>
</goals>
<configuration>
<!-- Use your .wsdl location here-->
<sourceDirectory>${basedir}/src/main/resources/wsdl</sourceDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- Here the libraries that you need to call the Axis WS client -->
<dependencies>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis-jaxrpc</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.5</version>
</dependency>
<dependency>
<groupId>axis</groupId>
<artifactId>axis-wsdl4j</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis-saaj</artifactId>
<version>1.4</version>
</dependency>
<!-- activation+mail: To stop Axis generating WARNING about "Attachment support being disabled" -->
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.7</version>
</dependency>
</dependencies>
回答by Ana Morales
This is whats happened to me (old wsdl in the same folder): https://www.damirscorner.com/blog/posts/20180831-CodeGenerationWithMavenCxfPlugin.html
这就是发生在我身上的事情(同一文件夹中的旧 wsdl):https: //www.damirscorner.com/blog/posts/20180831-CodeGenerationWithMavenCxfPlugin.html
"Obviously, something else was causing the problem for the Maven plugin. After a lot of trial and error, I finally got to the bottom of it. There was another WSDL file in the same folder and that one was for an RPC/literal web service. The plugin failed because it was trying to process it although the full path to my WSDL path in the configuration didn't point to it in any way."
“显然,其他原因导致了 Maven 插件的问题。经过大量的反复试验,我终于找到了问题的根源。在同一个文件夹中还有另一个 WSDL 文件,那个文件用于 RPC/literal web服务。插件失败,因为它试图处理它,尽管配置中我的 WSDL 路径的完整路径没有以任何方式指向它。”