java: Rpc/encoded wsdls are not supported in JAXWS 2.0
Asked Answered
T

7

64

I'm using CXF 2.1 to generate java code from a wsdl, but I'm getting the following error:

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?

Trachytic answered 5/1, 2009 at 10:45 Comment(0)
G
83

RPC/encoded is a vestige from before SOAP objects were defined with XML Schema. It's not widely supported anymore. You will need to generate the stubs using Apache Axis 1.0, which is from the same era.

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

You will need the following jars or equivalents in the -cp classpath param:

This will generate similar stubs to 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.

If you look at the WSDL, the following bits are using rpc/encoded:

<soap:body use="encoded"
           encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
Gagliardi answered 6/1, 2009 at 3:14 Comment(6)
Is there any documentation available for this problem in internet?Lynching
On the last Axis 1.4 distribution I have different jars naming and mail-1.4.jar is not present. It does not work as is. (I followed your Axis 1.0 link)Sopher
u ll need to add it explicitly.mail-1.x.jar and activation-1.x.jarAmieva
I tried your method and I get "java.net.ProtocolException: Server redirected too many times", which is probably due to the fact that I'm trying to import from a web service that requires authentication, how can I deal with authentication using your method?Lakh
I had removed use=encoded attribute, from <soap:body> and wsimport stopped complaining anymore and generated artifacts out of the wsdl. Is this a right approach ? Or it will have any impact.Misconceive
@Albert, for maven see my post belowFlightless
A
20

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.

Go to http://apache.is.co.za/axis/axis/java/1.4/ and download 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

Execute WSDL2Java using the following command (replacing the URL, of course):

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.

P.S.: This seems to work equally well using Axis 1.2.1.

Ashien answered 28/7, 2014 at 6:43 Comment(2)
Two classes are reported missing resulting in Attachment support being disabled. To fix this, get mail.jar and activation.jar and add them to the command.Stochmal
Add mailapi.jar and activation.jar as @Marco Brochet stated. I used -classpath and replaced ";" with ":". 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 api.clickatell.com/soap/webservice.php?WSDLJoust
A
7

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

<xsd:complexType name="ArrayOfString">
    <xsd:sequence>
      <xsd:element minOccurs="0" maxOccurs="unbounded" name="String" type="xsd:string"/>
    </xsd:sequence>
</xsd:complexType>
Artemis answered 17/4, 2012 at 17:10 Comment(0)
F
7

In case someone would like to use maven: (plus here some info about WSDL binding styles)

<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>
Flightless answered 15/10, 2018 at 21:51 Comment(0)
P
0

This is whats happened to me (old wsdl in the same folder): 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."

Plattdeutsch answered 29/4, 2020 at 12:27 Comment(0)
C
0

May be this will help to someone. I checked the above and it did not work for me.

I downloaded Apache Axis 1.2.1 then changed the command as like that

java -classpath full_path/commons-logging-1.0.4.jar:full_path/commons-discovery-0.2.jar:full_path/jaxrpc.jar:full_path/saaj.jar:full_path/wsdl4j-1.5.1.jar:full_path/mailapi.jar:full_path/activation.jar:full_path/mail.jar -Xmx128M org.apache.axis.wsdl.WSDL2Java -pcom.package -T1.1 -ofull_path_of_output file:full_path_of_wsdl
Caprifoliaceous answered 29/9, 2023 at 8:29 Comment(0)
B
-4

just extract,and Execute WSDL2Java? using the following command (replacing the URL, of course):

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
Bounded answered 4/8, 2016 at 8:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.