添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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,

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>
                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/"));
– Manuel M
                Jun 7, 2016 at 15:23
                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?
– Thiago Sayão
                Apr 17, 2018 at 18:46
                The maven solution does not work for me. It seems "soapenc.xsd" in the catalog file is simply ignored.
– Albert Hendriks
                Jun 26, 2018 at 14:54

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.

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>
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.