开发者

Clickatell SOAP wsdl to JAXB java classes

I'm trying to generate JAXB classes from the Clickatell wsdl: You can find the wsdl definition here it quite large: http://api.clickatell.com/soap/webservice.php?WSDL

开发者_开发问答

When trying to generate java classes from this Wsdl i got the following errors: [ERROR] undefined simple or complex type 'SOAP-ENC:Array' [ERROR] undefined attribute 'SOAP-ENC:arrayType'

I hope someone can help me out. Cheers, Tim


Your schema refers to the type SOAP-ENC:Array defined in the schema xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/ but that schema is not included in the wsdl.

I had a similar problem and had to use a catalog to tell jaxb/xjc where to find the schema.

Go to http://schemas.xmlsoap.org/soap/encoding/ and save as soapenc.xsd

Then create a plain text file with following content

PUBLIC "http://schemas.xmlsoap.org/soap/encoding/" "soapenc.xsd"

Then pass that file to xjc as the catalog file


Update: If you are on maven, this is how it would all hang together.

place the schema, soapenc.xsd, and catalog.cat(the plain text file) in src/main/resources

Then tell the jaxb plugin to pass the catalog to xjc

<plugin>
    <groupId>org.jvnet.jaxb2.maven2</groupId>
    <artifactId>maven-jaxb2-plugin</artifactId>
    <executions>
      <execution>
        <id>wsdl-generate</id>
        <configuration>
          <schemaIncludes>
            <include>*.wsdl</include>
          </schemaIncludes>
          <catalog>${project.basedir}/src/main/resources/catalog.cat</catalog>
        </configuration>
        <goals>
          <goal>generate</goal>
        </goals>
      </execution>
    </executions>
  </plugin>


I think the best way is to use old good axis 1.4. It was designed to work with rpc services and it usually does its job. The main problem is that this library is very, very old (the jar was uploaded to central in 2006) and it is not maintained any more.

If you decide to give it a try, just add the following dependency to your pom:

<dependency>
    <groupId>axis</groupId>
    <artifactId>axis</artifactId>
    <version>1.4</version>
</dependency>

add the following plugin:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>axistools-maven-plugin</artifactId>
    <version>1.4</version>
    <executions>
        <execution>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>
        <dependency>
            <groupId>javax.activation</groupId>
            <artifactId>javax.activation-api</artifactId>
            <version>1.2.0</version>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.7</version>
        </dependency>
    </dependencies>
    <configuration>
        <sourceDirectory>${project.basedir}/src/main/resources</sourceDirectory>
        <wsdlFiles>
            <wsdlFile>my_service.wsdl</wsdlFile>
        </wsdlFiles>
    </configuration>
</plugin>

put your wsdl file into src/main/resources/my_service.wsdl and build the app by mvn clean package.

Plugin details can be found here


check WS-I BasicProfile-1.1 spec at http://www.ws-i.org/Profiles/BasicProfile-1.1.html#soapenc_Array

It says :

R2110 In a DESCRIPTION, declarations MUST NOT extend or restrict the soapenc:Array type.

R2111 In a DESCRIPTION, declarations MUST NOT use wsdl:arrayType attribute in the type declaration.

R2112 In a DESCRIPTION, elements SHOULD NOT be named using the convention ArrayOfXXX.

R2113 An ENVELOPE MUST NOT include the soapenc:arrayType attribute.

yo!


I was using wsdl2java utility of axis1.5, we got the similar error on array.

Exception in thread "main" org.apache.axis2.wsdl.codegen.CodeGenerationException: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
            at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:271)
            at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35)
            at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24)
    Caused by: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
            at org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension.engage(SimpleDBExtension.java:53)
            at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:224)
            ... 2 more
    Caused by: java.lang.reflect.InvocationTargetException
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
            at java.lang.reflect.Method.invoke(Method.java:597)
            at org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension.engage(SimpleDBExtension.java:50)
            ... 3 more
    Caused by: org.apache.axis2.schema.SchemaCompilationException: can not find type {http://schemas.xmlsoap.org/soap/encoding/}Array from the parent schema ....
            at org.apache.axis2.schema.SchemaCompiler.copyMetaInfoHierarchy(SchemaCompiler.java:1296)
            at org.apache.axis2.schema.SchemaCompiler.processComplexContent(SchemaCompiler.java:1258)
            at org.apache.axis2.schema.SchemaCompiler.processContentModel(SchemaCompiler.java:1153)
            at org.apache.axis2.schema.SchemaCompiler.processComplexType(SchemaCompiler.java:1097)
            at org.apache.axis2.schema.SchemaCompiler.processNamedComplexSchemaType(SchemaCompiler.java:1017)

As explained in one of the answers above on soapenc.xsd ,i tried updating my wsdl file by creating the soapenc.xsd with the contents from website 'http://schemas.xmlsoap.org/soap/encoding/'. As shown below, this worked really for me.

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns1= .. xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns=.. xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace=..>
<types>
    <schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" targetNamespace=.. xmlns:ns1=.. xmlns:ns2=.. xmlns:tns=.. xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"/>
</types>
<import location="soapenc.xsd" namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<message name="Input">
    <part name=../>
</message>
<message name="Output">
    <part name=../>
</message>
<portType name=".."> .. </portType>
<binding name="..." type="tns:"..">
    <operation name="...">          ..          </operation>
    <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
</binding>
<service name="...">
    <port binding="tns:..." name="...">         <soap:address location="..."/>      </port>
</service>


JAXB doesnot support RPC/Encoding. Use JAX-RPC to solve this problem.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜