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

Solution 1:

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:

  • 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

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/">

Solution 2:

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.

Solution 3:

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>