Axis incorrectly adding invalid and extraneous tags when the wsdl imports 
schema that contains multiple versions of underlying schema elements
----------------------------------------------------------------------------------------------------------------------------------------------

         Key: AXIS-2217
         URL: http://issues.apache.org/jira/browse/AXIS-2217
     Project: Apache Axis
        Type: Bug
  Components: Serialization/Deserialization  
    Versions: current (nightly)    
 Environment: Windows-XP Service pack2, J2SDK 1.4.2.08, Compaq nc6000
    Reporter: Anand Raghavendran
    Priority: Critical


We have implemented schema versioning for our services using the schema 
namespace as version differntiator.  Please see the following wsdl and schemas:

<wsdl:definitions xmlns:ns2="http://www.abc.com/XYZ/root"; 
xmlns:tns="http://www.abc.com/ContactServicePort/"; 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns:ns="http://www.abc.com/XYZ";  
xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap/";  
xmlns:ns1="http://www.abc.com/XYZ/v1_1"; xmlns:ns3="http://www.abc.com/XYZ/v1_2"; 
xmlns:ns4="http://www.stndforum.org/STD_150"; 
targetNamespace="http://www.abc.com/ContactServicePort/"; name="ContactService">
        <wsdl:types>
                <xsd:schema attributeFormDefault="unqualified" 
elementFormDefault="qualified" 
targetNamespace="http://www.xyz.com/ContactServicePort/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
                        <xsd:import namespace="http://www.abc.com/XYZ/root"; 
schemaLocation="http://127.0.0.1:8080/axis/Contact_root.xsd"/>
                </xsd:schema>
        </wsdl:types>
        <wsdl:message name="ContactServiceRequest">
                <wsdl:part name="Contact" element="ns2:ContactRq"/>
        </wsdl:message>
        <wsdl:message name="ContactServiceResponse">
                <wsdl:part name="ContactResults" element="ns2:ContactRs"/>
        </wsdl:message>
        <wsdl:portType name="ContactService">
                <wsdl:operation name="processContact">
                        <wsdl:input name="ContactServiceRequest" 
message="tns:ContactServiceRequest"/>
                        <wsdl:output name="ContactServiceResponse" 
message="tns:ContactServiceResponse"/>
                </wsdl:operation>
        </wsdl:portType>
        <wsdl:binding name = "ContactSOAPBinding"
      type = "tns:ContactService">
      <soap:binding style = "document"
         transport = "http://schemas.xmlsoap.org/soap/http"/>
      <wsdl:operation name = "processContact">
         <soap:operation soapAction = 
"http://127.0.0.1:8080/axis/services/ContactService"/>
         <wsdl:input name = "ContactServiceRequest">
            <soap:body use = "literal"/>
         </wsdl:input>
         <wsdl:output name = "ContactServiceResponse">
            <soap:body use = "literal"/>
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name = "ContactService">
      <wsdl:port binding = "tns:ContactSOAPBinding"
         name = "ContactServiceSOAPPort">
         <soap:address location = 
"http://127.0.0.1:8080/axis/services/ContactService";
            xmlns:wsdl = "http://schemas.xmlsoap.org/wsdl/"/>
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>

<xsd:schema attributeFormDefault="unqualified" 
  elementFormDefault="qualified" 
  targetNamespace="http://www.abc.com/XYZ/root"; 
  xmlns:com.abc.root="http://www.abc.com/XYZ/root"; 
  xmlns:com.abc="http://www.abc.com/XYZ"; 
  xmlns:com.abc.component.v1_2="http://www.abc.com/XYZ/v1_2";
  xmlns:com.abc.component.v1_1="http://www.abc.com/XYZ/v1_1";
  xmlns="http://www.stndforum.org/STD_150"; 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
        <xsd:import namespace="http://www.abc.com/XYZ"; 
schemaLocation="Contact.xsd"/>
        <xsd:import namespace="http://www.abc.com/XYZ/v1_1"; 
schemaLocation="Contact_V1_1.xsd"/>
        <xsd:import namespace="http://www.abc.com/XYZ/v1_2"; 
schemaLocation="Contact_V1_2.xsd"/>
        <xsd:import namespace="http://www.stndforum.org/STD_150"; 
schemaLocation="Contact_base.xsd"/>
        <xsd:complexType name="ContactRq_Type">
            <xsd:sequence>
                <xsd:element ref="RqUID"/>
                <xsd:choice>
                        <xsd:element ref="com.abc:ContactSearch" minOccurs="0" 
/>
                        <xsd:element ref="com.abc.component.v1_1:ContactSearch" 
minOccurs="0" />
                        <xsd:element ref="com.abc.component.v1_2:ContactSearch" 
minOccurs="0"/>
                </xsd:choice>
            </xsd:sequence>
        </xsd:complexType>
        <xsd:element name="ContactRq" type="com.abc.root:ContactRq_Type"/>      
                
        <xsd:complexType name="ContactRs_Type">
            <xsd:sequence>
                <xsd:element ref="RqUID"/>
                <xsd:choice>
                        <xsd:element ref="com.abc:ContactInfo" minOccurs="0"/>
                        <xsd:element ref="com.abc.component.v1_1:ContactInfo" 
minOccurs="0"/>
                        <xsd:element ref="com.abc.component.v1_2:ContactInfo" 
minOccurs="0"/>
                </xsd:choice>
            </xsd:sequence>
        </xsd:complexType>
        <xsd:element name="ContactRs" type="com.abc.root:ContactRs_Type"/>      
                
</xsd:schema>

<xsd:schema attributeFormDefault="unqualified" 
  elementFormDefault="qualified" 
  targetNamespace="http://www.abc.com/XYZ"; 
  xmlns:com.abc="http://www.abc.com/XYZ"; 
  xmlns="http://www.stndforum.org/STD_150"; 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
   <xsd:import namespace="http://www.stndforum.org/STD_150"; 
schemaLocation="Contact_base.xsd"/>
   <xsd:complexType name="ContactSearch_Type">
                <xsd:sequence>                                  
                        <xsd:element ref="ContactName" minOccurs="0"/>
                </xsd:sequence>
   </xsd:complexType>
   <xsd:element name="ContactSearch" type="com.abc:ContactSearch_Type"/>
   <xsd:complexType name="ContactInfo_Type">
                <xsd:sequence>
                        <xsd:element ref="CSPhoneNum" minOccurs="0" 
maxOccurs="unbounded"/>
                        <xsd:element ref="ContactName" minOccurs="0"/>
                        <xsd:element ref="URL" minOccurs="0"/>
                </xsd:sequence>
   </xsd:complexType>
        <xsd:element name="ContactInfo" type="com.abc:ContactInfo_Type"/>
</xsd:schema>

<xsd:schema attributeFormDefault="unqualified" 
  elementFormDefault="qualified" 
  targetNamespace="http://www.abc.com/XYZ/v1_1"; 
  xmlns:com.abc.component.v1_1="http://www.abc.com/XYZ/v1_1"; 
  xmlns="http://www.stndforum.org/STD_150"; 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
   <xsd:import namespace="http://www.stndforum.org/STD_150"; 
schemaLocation="Contact_base.xsd"/>
   <xsd:complexType name="ContactSearch_Type">
        <xsd:sequence>                  
           <xsd:element ref="ContactName"/>
           <xsd:choice> 
                <xsd:element ref="CSPhoneNum"/>
                <xsd:element ref="Pager"/>
           </xsd:choice>                        
        </xsd:sequence>
   </xsd:complexType>
   <xsd:element name="ContactSearch" 
type="com.abc.component.v1_1:ContactSearch_Type"/>
   <xsd:complexType name="ContactInfo_Type">
        <xsd:sequence>
                <xsd:element ref="CSPhoneNum" minOccurs="0" 
maxOccurs="unbounded"/>
                <xsd:element ref="ContactName" minOccurs="0"/>
                <xsd:element ref="Pager" minOccurs="0"/>                
                <xsd:element ref="URL" minOccurs="0"/>
        </xsd:sequence>
   </xsd:complexType>
        <xsd:element name="ContactInfo" 
type="com.abc.component.v1_1:ContactInfo_Type"/>
</xsd:schema>

<xsd:schema attributeFormDefault="unqualified" 
  elementFormDefault="qualified" 
  targetNamespace="http://www.abc.com/XYZ/v1_2"; 
  xmlns:com.abc.component.v1_2="http://www.abc.com/XYZ/v1_2"; 
  xmlns="http://www.stndforum.org/STD_150"; 
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
   <xsd:import namespace="http://www.stndforum.org/STD_150"; 
schemaLocation="Contact_base.xsd"/>
   <xsd:complexType name="ContactSearch_Type">
        <xsd:sequence>                  
           <xsd:element ref="ContactName"/>
           <xsd:choice> 
                <xsd:element ref="CSPhoneNum"/>
                <xsd:element ref="Pager"/>
                <xsd:element ref="Cell"/>
           </xsd:choice>                        
        </xsd:sequence>
   </xsd:complexType>
   <xsd:element name="ContactSearch" 
type="com.abc.component.v1_2:ContactSearch_Type"/>
   <xsd:complexType name="ContactInfo_Type">
        <xsd:sequence>
                <xsd:element ref="CSPhoneNum" minOccurs="0" 
maxOccurs="unbounded"/>
                <xsd:element ref="ContactName" minOccurs="0"/>
                <xsd:element ref="Pager" minOccurs="0"/>
                <xsd:element ref="Cell" minOccurs="0"/>
                <xsd:element ref="URL" minOccurs="0"/>
        </xsd:sequence>
   </xsd:complexType>
        <xsd:element name="ContactInfo" 
type="com.abc.component.v1_2:ContactInfo_Type"/>
</xsd:schema>

<xsd:schema xmlns="http://www.stndforum.org/STD_150"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
targetNamespace="http://www.stndforum.org/STD_150"; 
elementFormDefault="qualified" attributeFormDefault="unqualified">
        <xsd:element name="URL" type="URL_Type"/>
        <xsd:simpleType name="URL_Type">
                <xsd:restriction base="URL"/>
        </xsd:simpleType>
        <xsd:simpleType name="URL">
                <xsd:restriction base="NC">
                        <xsd:maxLength value="1024"/>
                </xsd:restriction>
        </xsd:simpleType>
        <xsd:simpleType name="Pager_Type">
                <xsd:restriction base="NC">
                        <xsd:maxLength value="25"/>
                </xsd:restriction>
        </xsd:simpleType>
        <xsd:element name="Pager" type="Pager_Type"/>
        <xsd:simpleType name="Identifier">
                <xsd:restriction base="NC">
                        <xsd:maxLength value="36"/>
                </xsd:restriction>
        </xsd:simpleType>
        <xsd:element name="RqUID" type="Identifier"/>
        <xsd:simpleType name="NC">
                <xsd:restriction base="xsd:string"/>
        </xsd:simpleType>
        <xsd:simpleType name="PhoneNumber">
                <xsd:restriction base="xsd:string"/>
        </xsd:simpleType>
        <xsd:element name="CSPhoneNum" type="PhoneNumber"/>
        <xsd:element name="Cell" type="PhoneNumber"/>
        <xsd:simpleType name="ContactName_Type">
                <xsd:restriction base="NC">
                        <xsd:maxLength value="40"/>
                </xsd:restriction>
        </xsd:simpleType>
        <xsd:element name="ContactName" type="ContactName_Type"/>
</xsd:schema>

We used document literal message style web services for our deployment.  The 
wsdl takes ContactRq as the input message and ContactRs as the output message.  
  I generated client side side bindings and the created my test harness.   The 
test case named ContactService_ServiceTestCase.java composes and submits a 
ContactRq request with ContactSearch object.  Here is te test method: 

public void test1ContactServiceSOAPPortProcessContact() throws Exception {
        com.abc.www.ContactServicePort.ContactSOAPBindingStub binding;
        try {
            binding = (com.abc.www.ContactServicePort.ContactSOAPBindingStub)
                          new 
com.abc.www.ContactServicePort.ContactService_ServiceLocator().getContactServiceSOAPPort();
        }
        catch (javax.xml.rpc.ServiceException jre) {
            if(jre.getLinkedCause()!=null)
                jre.getLinkedCause().printStackTrace();
            throw new junit.framework.AssertionFailedError("JAX-RPC 
ServiceException caught: " + jre);
        }
        assertNotNull("binding is null", binding);



        // Time out after a minute
        binding.setTimeout(60000);

 try {
                        System.out.println("Creating IFX Request");
                        com.abc.www.XYZ.root.ContactRq_Type data = new 
com.abc.www.XYZ.root.ContactRq_Type();
                        data.setRqUID("cc6f705c-bc42-4aad-8a05-cced85b8066a");
                        com.abc.www.XYZ.ContactSearch_Type search = new 
com.abc.www.XYZ.ContactSearch_Type();
                        data.setContactSearch(search);

                        search.setContactName("Test");
            System.out.println("Calling  Contact Service");
            // Test operation
                        com.abc.www.XYZ.root.ContactRs_Type value = null;

                value = binding.processContact(data);
                        System.out.println("Processed  Contact Service");

                        System.out.println("UID: " + value.getRqUID());


                } catch (Throwable ex) {
                        ex.printStackTrace();
                }

        // TBD - validate results
    }

I setup the tcpmon and trapped the messages going across the wire.  Notice the 
following tags in the request XML.  Clearly the serialized XML is incorrect as 
there are no tags defined for contactSearch2 and contactSearch3 in any of the 
schemas:

<contactSearch2 xsi:nil="true"/>
<contactSearch3 xsi:nil="true"/>

The full request is attached below:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
<soapenv:Body>
   <ContactRq xmlns="http://www.abc.com/XYZ/root";>
        <ns1:RqUID 
xmlns:ns1="http://www.stndforum.org/STD_150";>cc6f705c-bc42-4aad-8a05-cced85b8066a</ns1:RqUID>
       <ns2:ContactSearch xsi:type="ns3:ContactSearch_Type" 
xmlns:ns2="http://www.abc.com/XYZ/v1_2"; xmlns:ns3="http://www.abc.com/XYZ";>
                   <ns4:ContactName 
xmlns:ns4="http://www.stndforum.org/STD_150";>Test</ns4:ContactName>
       </ns2:ContactSearch>
      <contactSearch2 xsi:nil="true"/><contactSearch3 xsi:nil="true"/>
</ContactRq>
</soapenv:Body>
</soapenv:Envelope>

Please fix this issue.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to