Clickatell SOAP wsdl to JAXB java classes
Asked Answered
C

5

19

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

Carree answered 8/3, 2010 at 13:45 Comment(0)
B
27

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>
Baucis answered 8/7, 2013 at 23:36 Comment(3)
Note: if you are using a dynamic client, juss pass the encoding file to the Client: Client client = factory.createClient(wsdlURL.toExternalForm(), SERVICE_NAME, Collections.singletonList("http://schemas.xmlsoap.org/soap/encoding/"));Saum
If i add the soapenc.xsd the arrayType error goes away, but it conflicts with another types, for example: 'positiveInteger' is already defined. Any ideas?Ingulf
The maven solution does not work for me. It seems "soapenc.xsd" in the catalog file is simply ignored.Develop
E
2

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

Ereshkigal answered 11/1, 2019 at 10:28 Comment(0)
C
0

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!

Coff answered 3/12, 2010 at 11:26 Comment(1)
how should this help?Loth
F
0

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>

Fulks answered 19/3, 2019 at 8:19 Comment(0)
L
-1

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

Labdanum answered 8/3, 2010 at 13:59 Comment(1)
This has nothing to do with JAXB, it's a JAX-WS issueCurie

© 2022 - 2024 — McMap. All rights reserved.