Request.xsd
<xsd:element name="HelloWorldReqType"> <xsd:complexType> <xsd:sequence> <xsd:element id="name" name="name" maxOccurs="1" minOccurs="1"/> <xsd:element id="gender" name="gender" maxOccurs="1" minOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element>Response.xsd
<xsd:element name="HelloWorld_response"> < xsd:complexType> <xsd:sequence> <xsd:element id="greetings" name="greetings" maxOccurs="1" minOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element>I should not explicitly define the same set of request and response elements in WSDL while I have chosen to import them. This is what I did to the WSDL:
<wsdl:types> <xsd:schema targetNamespace="http://www.example.org/HelloWorld/"> <xsd:import namespace="http://www.example.org/HelloWorldReq" schemaLocation="../resources/HelloWorldReq.xsd"/> <xsd:import namespace="http://www.example.org/HelloWorldRes" schemaLocation="../resources/HelloWorldRes.xsd"/> <xsd:element name="helloWorld_request"> <xsd:complexType> <xsd:sequence> <xsd:element name="name" type="xsd:string" maxOccurs="1" minOccurs="1"/> <xsd:element name="gender" type="xsd:string" maxOccurs="1" minOccurs="1"></xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <xsd:element name="helloWorld_response"> <xsd:complexType> <xsd:sequence> <xsd:element name="greetings" type="xsd:string" maxOccurs="1" minOccurs="1"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> </wsdl:types>Line 3 and 4 are the import statement that import the 2 XSDs into WSDL whereas starting from line 5, I define the same set of elements as in the XSDs. Well, this will receive an error complaining duplicate class while generating the JAVA artifact from XSD as shown below:
parsing WSDL... [ERROR] A class/interface with the same name "org.huahsin.ws.HelloWorldResponse" is already in use. Use a class customization to resolve this conflict. line 23 of file:/home/kokhoe/workspace/wsAsync/resources/HelloWorld.wsdl [ERROR] (Relevant to above error) another "HelloWorldResponse" is generated from here. line 8 of file:/home/kokhoe/workspace/wsAsync/resources/HelloWorldRes.xsd [ERROR] Two declarations cause a collision in the ObjectFactory class. line 8 of file:/home/kokhoe/workspace/wsAsync/resources/HelloWorldRes.xsd [ERROR] (Related to above error) This is the other declaration. line 23 of file:/home/kokhoe/workspace/wsAsync/resources/HelloWorld.wsdlThus experience from here was never be so greedy, choose either site when the element should define.