javaweb-serviceswsdljax-rswsgen

Java JAX WS generated WSDL vs wsgen


I have a JAX WS Web service in java, and I change it from type Document to RPC with the following line:

@SOAPBinding(style = Style.RPC)

The problem is when I try to use wsgen.exe (version 2.2.9) from JDK 1.8.0_91:

"C:\Program Files\Java\jdk1.8.0_91\bin\wsgen.exe" -verbose -cp . com.ws.ServiceImpl -wsdl -inlineSchemas

The WSDL generated for the method insertDevolutions is the following:

<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>

But the WSDL generated by the service with the URL http://localhost:8080/TestWS/ServiceImpl?wsdl is totally different because the object devolution is generated correctly:

<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>

So I want to know how is the WSDL with wsdl option in the URL generated because I thought JAX WS uses the same tool as wsgen. Is there another tool that generates the WSDL like the one provided by the service?


Solution

  • Finally I found that the WSDL was generated with CXF, because the tool wsgen uses the default JAXB implementation and this one does not convert interfaces like List<> and the classes like ArrayList<> are converted like I mentioned before in the following way:

    <xs:complexType name="arrayList">
        <xs:complexContent>
            <xs:extension base="tns:abstractList">
                <xs:sequence/>
            </xs:extension>
        </xs:complexContent>
    </xs:complexType>
    

    So when I use the tools provided by CXF with the follwing command:

    "C:\apache-cxf-3.1.6\bin\java2ws" -wsdl -d . com.ws.ServiceImpl
    

    The WSDL with RPC style is generated correctly.