从WSDL创建Java API

时间:2012-07-20 12:35:02

标签: java api soap wsdl

我想创建java类或使用此WSDL中的API(https://secure.myclang.com/app/api/soap/public/wsdl/index.php?version=1.10)我试过了axis2 -1.6.2,但我没有让它工作..

有人可以帮助我,或者WSDL出了什么问题?

我得到的错误:

 C:\Users\Gynnad\Downloads\axis2-1.5.1-bin\axis2-1.5.1\bin>wsdl2java.bat -uri 
 https://secure.myclang.com/app/api/soap/public/wsdl/index.php?version=1.10
 Using AXIS2_HOME:   C:\Users\Gynnad\Downloads\axis2-1.6.2-bin\axis2-1.6.2
 Using JAVA_HOME:    C:\Program Files (x86)\Java\jdk1.6.0_31
 Retrieving document at 'https://secure.myclang.com/app/api/soap/public/wsdl/index.php?version=1.10'.
 log4j:WARN No appenders could be found for logger     (org.apache.axis2.description.WSDL11ToAllAxisServicesBuilder).log4j:WARN Please initialize      the log4j system properly.
 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:293)
    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:246)
    ... 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 https://secure.myclang.com/app/api/soap/public/index.php?version=1.10
    at org.apache.axis2.schema.SchemaCompiler.copyMetaInfoHierarchy(SchemaCompiler.java:1371)
    at org.apache.axis2.schema.SchemaCompiler.processComplexContent(SchemaCompiler.java:1333)
    at org.apache.axis2.schema.SchemaCompiler.processContentModel(SchemaCompiler.java:1228)
    at org.apache.axis2.schema.SchemaCompiler.processComplexType(SchemaCompiler.java:1172)
    at org.apache.axis2.schema.SchemaCompiler.processNamedComplexSchemaType(SchemaCompiler.java:1092)
    at org.apache.axis2.schema.SchemaCompiler.processSchema(SchemaCompiler.java:1006)
    at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:645)
    at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:604)
    at org.apache.axis2.schema.SchemaCompiler.process(SchemaCompiler.java:2069)
    at org.apache.axis2.schema.SchemaCompiler.processParticle(SchemaCompiler.java:1952)
    at org.apache.axis2.schema.SchemaCompiler.processComplexType(SchemaCompiler.java:1156)
    at org.apache.axis2.schema.SchemaCompiler.processNamedComplexSchemaType(SchemaCompiler.java:1092)
    at org.apache.axis2.schema.SchemaCompiler.processSchema(SchemaCompiler.java:1006)
    at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:645)
    at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:604)
    at org.apache.axis2.schema.SchemaCompiler.process(SchemaCompiler.java:2069)
    at org.apache.axis2.schema.SchemaCompiler.processParticle(SchemaCompiler.java:1952)
    at org.apache.axis2.schema.SchemaCompiler.processComplexType(SchemaCompiler.java:1156)
    at org.apache.axis2.schema.SchemaCompiler.processAnonymousComplexSchemaType(SchemaCompiler.java:1055)
    at org.apache.axis2.schema.SchemaCompiler.processSchema(SchemaCompiler.java:1009)
    at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:645)
    at org.apache.axis2.schema.SchemaCompiler.processElement(SchemaCompiler.java:615)
    at org.apache.axis2.schema.SchemaCompiler.compile(SchemaCompiler.java:423)
    at org.apache.axis2.schema.SchemaCompiler.compile(SchemaCompiler.java:292)
    at org.apache.axis2.schema.ExtensionUtility.invoke(ExtensionUtility.java:102)
    ... 8 more

2 个答案:

答案 0 :(得分:2)

你可以尝试一下这个:

WSDL2JAVA

编辑:

根据您的错误,我认为问题在于WSDL本身:

org.apache.axis2.schema.SchemaCompilationException: can not find type {http://schemas.xmlsoap.org/soap/encoding/}Array from the parent schema https://secure.myclang.com/app/api/soap/public/index.php?version=1.10

答案 1 :(得分:0)

您也可以尝试

Apache CXF - WSDL to Java

执行相同的

也有Maven Plugin