Choice and sequence elements are not serialized when part of a choice element
-----------------------------------------------------------------------------

                 Key: AXIS2-4858
                 URL: https://issues.apache.org/jira/browse/AXIS2-4858
             Project: Axis2
          Issue Type: Bug
          Components: codegen
    Affects Versions: 1.5
         Environment: Current download
            Reporter: Thomas Raddatz


Choice and sequence elements not added as part of a choice element

I have the following complex type:

<xsd:complexType name="choices">
 <xsd:sequence>
  <xsd:choice minOccurs="0">
   <xsd:sequence minOccurs="0" maxOccurs="unbounded">
    <xsd:element name="firstChildOfSequence" type="xsd:string" />
    <xsd:element name="secondChildOfSequence" type="xsd:string" />
   </xsd:sequence>
   <xsd:choice>
    <xsd:element name="firstChildOfChoice" type="xsd:string" />
    <xsd:element name="secondChildOfChoice" type="xsd:string" />
   </xsd:choice>
   <xsd:choice>
    <xsd:element name="thirdChildOfChoice" type="xsd:string" />
    <xsd:element name="forthChildOfChoice" type="xsd:string" />
   </xsd:choice>
  </xsd:choice>
 <xsd:element name="endOfMessage" type="xsd:string" />
 </xsd:sequence>
</xsd:complexType>

There are two problems when parsing the request message.

The first problem is that the sequence element is not added to the outer 
choice element because of a ADBException("Unexpected subelement 
endOfMessage") when processing the following request:

<soapenv:Envelope 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
 xmlns:cho="http://tools400.de/wsdl2rpg/webservice/axis2/errors/choice";>
   <soapenv:Header/>
   <soapenv:Body>
      <cho:echoChoices 
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
         <choices xsi:type="cho:choices">
            <firstChildOfSequence 
xsi:type="xsd:string">child1</firstChildOfSequence>
            <secondChildOfSequence 
xsi:type="xsd:string">child2</secondChildOfSequence>
            <endOfMessage xsi:type="xsd:string">endOfMessage</endOfMessage>
         </choices>
      </cho:echoChoices>
   </soapenv:Body>
</soapenv:Envelope>

The second problem is that the <firstChildOfChoice> element is added to the 
outer 
choice element but its associated tracker value is set back to false later on. 
That happens 
because Factory.parse() of ChoicesChoice_type1() returns an object although 
there is 
no third and fourth "ChildOfChoice" element. In fact the object is returned 
because of the 
<endOfMessage> element which is definitely wrong. Sample request message:

<soapenv:Envelope 
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"; 
 xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; 
 xmlns:cho="http://tools400.de/wsdl2rpg/webservice/axis2/errors/choice";>
   <soapenv:Header/>
   <soapenv:Body>
      <cho:echoChoices 
soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/";>
         <choices xsi:type="cho:choices">
            <firstChildOfChoice 
xsi:type="xsd:string">firstChildOfChoice</firstChildOfChoice>
            <endOfMessage xsi:type="xsd:string">endOfMessage</endOfMessage>
         </choices>
      </cho:echoChoices>
   </soapenv:Body>
</soapenv:Envelope>

In order to fix the problems I fixed the following files the initially had been 
generated 
by WSDL2JAVA:

  ChoicesChoice_type0.java
  ChoicesChoice_type1.java
  ChoicesChoice_type2.java

Please verify the changes I did and fix WSDL2JAVA.


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to