我正在尝试使用Apache Axis创建服务2.部分服务需要从WSDL文件生成,所以我使用org.apache.axis2.wsdl.WSDL2Java来执行此操作。我创建了以下WSDL文件:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://webservice.dummy.com" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://webservice.dummy.com">
<types>
<schema targetNamespace="http://webservice.dummy.com" xmlns:tns="http://webservice.dummy.com" xmlns="http://www.w3.org/2000/10/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<element name="tns:BodyData">
<complexType>
<all>
<element name="price" type="xsd:float"/>
</all>
</complexType>
</element>
</schema>
</types>
<wsdl:message name="CreateResp">
<wsdl:part name="CreateResp" element="xsd:int"/>
</wsdl:message>
<wsdl:message name="CreateReq">
<wsdl:part name="CreateReq" element="tns:BodyData"/>
</wsdl:message>
</wsdl:definitions>
但是WSDL2Java无法验证此文件并显示以下内容:
[java] org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:293) [java] at org.apache.axis2.wsdl.WSDL2Code.main(WSDL2Code.java:35) [java] at org.apache.axis2.wsdl.WSDL2Java.main(WSDL2Java.java:24) [java]引起:org.apache.axis2.wsdl.codegen.CodeGenerationException:org.apache.axis2.wsdl.databinding.UnmatchedTypeException:没有类型被映射到名称为BodyData且名称空间为http://webservice.dummy.com的名称 [java] at org.apache.axis2.wsdl.codegen.emitter.AxisServiceBasedMultiLanguageEmitter.emitSkeleton(AxisServiceBasedMultiLanguageEmitter.java:1451) [java] at org.apache.axis2.wsdl.codegen.CodeGenerationEngine.generate(CodeGenerationEngine.java:275) [java] ... 2更多
有人可以解释我的wsdl文件有什么问题吗?
答案 0 :(得分:0)
而不是<element name="tns:BodyData">
,它应该是<element name="BodyData">
。