java:JAXWS 2.0不支持Rpc/encoded wsdls

56 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)
Run Code Online (Sandbox Code Playgroud)

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

Cha*_*ert 72

RPC/encoded是使用XML Schema定义SOAP对象之前的遗留物.它不再受到广泛支持.您需要使用来自同一时代的Apache Axis 1.0生成存根.

java org.apache.axis.wsdl.WSDL2Java http://someurl?WSDL 
Run Code Online (Sandbox Code Playgroud)

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

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

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

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

<soap:body use="encoded"
           encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
Run Code Online (Sandbox Code Playgroud)

  • 互联网上是否有针对此问题的文档? (3认同)
  • 在上一个 Axis 1.4 发行版中,我使用了不同的 jar 命名并且不存在 mail-1.4.jar。它不能按原样工作。(我遵循了您的 Axis 1.0 链接) (2认同)

Ste*_*han 16

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

访问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
Run Code Online (Sandbox Code Playgroud)

这将生成您的Java文件.

PS:使用Axis 1.2.1似乎同样有效.

  • 报告缺少两个类,导致禁用附件支持.要解决此问题,请获取mail.jar和activation.jar并将其添加到命令中. (4认同)
  • 添加mailapi.jar和activation.jar为@Marco Brochet说.我使用了-classpath并替换了";" 用":".java -classpath axis.jar:commons-logging-1.0.4.jar:commons-discovery-0.2.jar:jaxrpc.jar:saaj.jar:wsdl4j-1.5.1.jar:mailapi.jar:activation.jar org. apache.axis.wsdl.WSDL2Java https://api.clickatell.com/soap/webservice.php?WSDL (4认同)

Foy*_*yta 6

如果有人想使用 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>
Run Code Online (Sandbox Code Playgroud)


Rit*_*tes 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>
Run Code Online (Sandbox Code Playgroud)