WSDL2Java code generates invalid elements in XML instances.
-----------------------------------------------------------

                 Key: AXIS-2561
                 URL: http://issues.apache.org/jira/browse/AXIS-2561
             Project: Apache Axis
          Issue Type: Bug
          Components: Serialization/Deserialization, WSDL processing
    Affects Versions: 1.4
            Reporter: Joseph J. Pantella, IV


Basic Problem:

WSDL that includes an element modeled like this:

        <xs:element name="Subject" type="SubjectType">
        <xs:complexType name="SubjectType">
                <xs:sequence>
                        <xs:choice>
                                <xs:element ref="category"/>
                                <xs:element ref="keyword"/>
                        </xs:choice>
                        <xs:element ref="category" minOccurs="0" 
maxOccurs="unbounded"/>
                        <xs:element ref="keyword" minOccurs="0" 
maxOccurs="unbounded"/>
                </xs:sequence>
        </xs:complexType>

generates (partially) XML that looks like this:

<ns1:keyword ns1:value="someKeyword" xmlns:ns1="http://someNS"/>
<ns2:category2 ns2:code="someCode" ns2:label="someLabel" 
ns2:qualifier="http://someURI/2/"; xmlns:ns2="http://someNS//"/>
<ns3:keyword2 ns3:value="someKeyword" xmlns:ns3="http://someNS"/>

The problem is that the generated XML has elements with name category2 and 
keyword2 which are clearly not valid according to the XML Schema.  

Explanation:  

This is because in the generated class that WSDL2Java creates (for Subject in 
this case) it generates different variables for the choice namely, "keyword" 
and "category", and other variables for the remaining elements in the sequence, 
in this case because they are the same it generates variables "keyword2" and 
"category2".  WSDL2Java then creates accessor methods for each of these 
variables and properly sets the org.apache.axis.description.ElementDesc 
information.  The problem arises because the BeanSerializer ultimately uses 
reflection to determine the element names in the XML (apparently in lieu of the 
information provided in the org.apache.axis.description.ElementDesc object).  
Because there are methods get/setCategory2 and get/setKeyword2, in addition to 
get/setKeyword and get/SetCategory, the BeanSerializer serializes out XML that 
contains illegal elements namely "<keyword2>" and "<category2>" elements.  

I've somewhat confirmed that the problem is a result of the BeanSerializer 
relying on reflection by changing the method names and witnessing that the 
element names change with them.  E.g. if I change the get/setKeyword2 methods 
to get/setKeyword3 in the generated SubjectType class, I get <keyword3>  
elements in the XML instances.  

Possible Resolutions:

1) Modify the WSDL2Java code to create only one aptly named accessor for each 
element defined in an XML Schema so that the BeanSerializer does not find 
inappropriate getters/setters and generate invalid XML. 

2) Modify the BeanSerializer to use the information captured in the ElementDesc 
object for element names, rather than relying on reflection to do the right 
thing.  

BTW I've qualified this bug as Major because it causes a massive 
interoperability problem which is, of course, and the whole point of web 
services.  

Thanks, 

-- Joe

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

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to