java:JAXWS 2.0不支持Rpc / encoded wsdls

时间:2009-01-05 10:45:17

标签: java jax-ws

我正在使用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)

如何解决此错误,我可以使用以前版本的CXF或其他任何方法来修复它吗?

6 个答案:

答案 0 :(得分:71)

RPC / encoded是使用XML Schema定义SOAP对象之前的遗留物。它已经not widely supported了。您需要使用来自同一时代的Apache Axis 1.0来生成存根。

java org.apache.axis.wsdl.WSDL2Java http://someurl?WSDL 

您将需要-cp classpath参数中的以下jar或等效项:

这将生成与wsimport类似的存根。

或者,如果您没有使用需要rpc / encoded的模式部分,您可以下载WSDL的副本并注释掉这些位。然后对本地文件运行wsimport。

如果查看WSDL,以下位使用rpc / encoded:

<soap:body use="encoded"
           encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">

答案 1 :(得分:16)

我使用Axis 1.4作为Chase Seibert在his answer中建议的,尽管该答案中给出的下载链接不起作用。我使用的替代下载链接给了我不同的库。以下是我生成代码所遵循的步骤。

转到http://apache.is.co.za/axis/axis/java/1.4/并下载 axis-bin-1_4.zip

提取它,你应该有以下文件(其中包括):

  • axis.jar
  • 公地发现-0.2.jar
  • 共享记录-1.0.4.jar
  • 没有jaxrpc.jar
  • 没有saaj.jar
  • WSDL4J-1.5.1.jar

使用以下命令执行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

这将生成您的Java文件。

P.S。:使用Axis 1.2.1似乎同样有效。

答案 2 :(得分:5)

这可能对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>

答案 3 :(得分:2)

万一有人想使用maven :(加上here有关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>

答案 4 :(得分:0)

这是发生了什么事(同一文件夹中的旧wsdl):https://www.damirscorner.com/blog/posts/20180831-CodeGenerationWithMavenCxfPlugin.html

“显然,是其他原因导致了Maven插件的问题。经过大量的试验和错误,我终于找到了问题的根源。同一文件夹中还有另一个WSDL文件,其中一个用于RPC。 / literal Web服务。尽管配置中指向我的WSDL路径的完整路径没有以任何方式指向它,但该插件失败了,因为它正在尝试处理它。”

答案 5 :(得分:-3)

刚提取,并执行WSDL2Java?使用以下命令(当然替换URL):

<input type="number" class="input numeric-only nodecimal width30" name="prefcreditlimitval" id="prefcreditlimit" min="100" step="100">