[英]Java JAX WS generated WSDL vs wsgen
我在Java中有一个JAX WS Web服务,并使用以下行将其从Document类型更改为RPC :
@SOAPBinding(style = Style.RPC)
问题是当我尝试使用JDK 1.8.0_91中的wsgen.exe(版本2.2.9)时:
"C:\Program Files\Java\jdk1.8.0_91\bin\wsgen.exe" -verbose -cp . com.ws.ServiceImpl -wsdl -inlineSchemas
为方法insertDevolutions生成的WSDL如下:
<xs:schema version="1.0" targetNamespace="..." xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="arrayList">
<xs:complexContent>
<xs:extension base="tns:abstractList">
<xs:sequence/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="abstractList" abstract="true">
<xs:complexContent>
<xs:extension base="tns:abstractCollection">
<xs:sequence/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="abstractCollection" abstract="true">
<xs:sequence/>
</xs:complexType>
</xs:schema>
...
<message name="insertDevolutions">
<part name="arg0" type="xsd:string"/>
<part name="arg1" type="tns:arrayList"/>
<part name="arg2" type="xsd:string"/>
<part name="arg3" type="xsd:string"/>
<part name="arg4" type="xsd:string"/>
<part name="arg5" type="xsd:string"/>
<part name="arg6" type="xsd:boolean"/>
</message>
但是,由服务使用URL http:// localhost:8080 / TestWS / ServiceImpl?wsdl生成的WSDL完全不同,因为对象委托已正确生成:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="..." attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="...">
<xs:complexType name="devolution">
<xs:sequence>
<xs:element name="company" type="xs:string"/>
<xs:element name="currency" type="xs:string"/>
<xs:element name="registerDate" type="xs:dateTime"/>>
<xs:element name="total" type="xs:double"/>
</xs:sequence>
</xs:complexType>
<xs:complexType final="#all" name="devolutionArray">
<xs:sequence>
<xs:element maxOccurs="unbounded" minOccurs="0" name="item" nillable="true" type="tns:devolution"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
...
<wsdl:message name="insertDevolutions">
<wsdl:part name="arg0" type="xsd:string"/>
<wsdl:part name="arg1" type="tns:devolutionArray"/>
<wsdl:part name="arg2" type="xsd:string"/>
<wsdl:part name="arg3" type="xsd:string"/>
<wsdl:part name="arg4" type="xsd:string"/>
<wsdl:part name="arg5" type="xsd:string"/>
<wsdl:part name="arg6" type="xsd:boolean"/>
</wsdl:message>
因此,我想知道如何在URL中生成带有wsdl选项的WSDL,因为我认为JAX WS使用与wsgen相同的工具。 是否有另一个工具可以像服务提供的那样生成WSDL?
最终,我发现WSDL是用CXF生成的,因为工具wsgen使用默认的JAXB实现,并且该接口不会转换像List<>
这样的接口,而像ArrayList<>
这样的类将按照前面提到的方式通过以下方式进行转换:
<xs:complexType name="arrayList">
<xs:complexContent>
<xs:extension base="tns:abstractList">
<xs:sequence/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
因此,当我使用follwing命令使用CXF提供的工具时:
"C:\apache-cxf-3.1.6\bin\java2ws" -wsdl -d . com.ws.ServiceImpl
正确生成带有RPC
样式的WSDL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.