You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@axis.apache.org by Dimuthu Gamage <di...@gmail.com> on 2008/11/13 19:03:59 UTC

Re: Incorrect deserialization when the first child is an empty element

Hi Catalina,

Looks like there is a bug. It happens that if parent types only contains
attributes, the code that you mentioned is necessary,


  current_node = first_node;
  is_early_node_valid = AXIS2_FALSE;

is never executed.


Please raise a JIRA reporting this issue. I attached a patch (taken from the
latest svn) for give an idea what has gone wrong.


Thanks
Dimuthu



On Wed, Nov 12, 2008 at 7:09 PM, Catalina Caloian <
Catalina.Caloian@quintiq.com> wrote:

> Hello.
>
> Scenario:
>     - the first element in a sequence is nillable
>     - in the actual XML, that first element is present, but is empty
>     - the deserialization code of the parent mishandles this element by not
> recognizing it as being its *first* child element and by treating it as if
> it were a child with position >= 2
>
> Example:
>
> Relevant part of the wsdl:
>
> <complexType name="TransientVO">
>    <sequence></sequence>
>  </complexType>
>
> <complexType name="Address">
>        <complexContent>
>             <extension base="ns2:TransientVO">
>                   <sequence>  </sequence>
>                   <!-- attributes -->
>             </extension>
>        </complexContent>
>    </complexType>
>
> <complexType name="ResultAddress">
>        <complexContent>
>            <extension base="tns:Address">
>        <sequence>
>                <element name="wrappedAdditionalFields"
> type="tns:ArrayOfAdditionalField" minOccurs="1" maxOccurs="1"
> nillable="true"/>
>                <element name="coordinates" type="ns1:Point" minOccurs="0"
> maxOccurs="1" nillable="true"/>
>                </sequence>
>                <!-- attributes -->
>            </extension>
>        </complexContent>
>  </complexType>
>
>
>
> If 'wrappedAdditionalFields' would have been recognized as the first child
> element, according to the CADBBeanTemplateSource.xsl template, the
> deserialization code would have looked something like this:
> adb_ResultAddress_deserialize(...)
> {
>   ...
>   /*
>    * building wrappedAdditionalFields element
>    */
>
>   current_node = first_node;
>   is_early_node_valid = AXIS2_FALSE;
>   ...
> }
>
> Instead, the deserialization code looks something like this:
>
> adb_ResultAddress_deserialize(...)
> {
>   ...
>   /*
>    * building wrappedAdditionalFields element
>    */
>
>    /*
>     * because elements are ordered this works fine
>     */
>       if(current_node != NULL && is_early_node_valid)
>       {
>         // code as if this were a child with position >= 2
>         // at this point, current_node is NULL because no element has been
> recognized as being the first child (and no element will be recognized as
> such)
>       }
> }
>
>
> For generating C code I have used axis2-1.4.1-src with some slight changes
> to CADBBeanTemplateSource.xsl to embed some minor bug fixes.
>
> I have attached to this e-mail the wsdl and the template I've been using.
>
> I'm not sure if this problem is a bug in Axis2C or in Axis2. However, I
> thought I would try to raise this problem here hoping that somebody might be
> able to help me.
>
> Thank you,
> Catalina Caloian
>
>
>
>
>
> This message contains information that may be privileged or confidential
> and is the property of Quintiq. It is only intended for the person to whom
> it is addressed. If you are not the intended recipient, you are not
> authorized to read, print, retain, copy, disseminate, distribute or use this
> message or any part thereof. If you have received this message in error,
> please notify the sender immediately and delete all copies of this message.
> Please note that e-mails are susceptible to change, therefore they are not
> binding.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-dev-help@ws.apache.org
>



-- 
Thanks,
Dimuthu Gamage

http://www.dimuthu.org
http://www.wso2.org

Re: Incorrect deserialization when the first child is an empty element

Posted by Catalina Caloian <Ca...@quintiq.com>.
Hi.

The patch you've attached seems to solve the problem. 

Unfortunately, it introduces another bug as a side-effect: now, a 'current_node = first_node;' assignment also happens in the deserialization of structures deduced from the simpleTypes of a wsdl. This leads to compilation errors because 'current_node', 'first_node' etc. are not declared in the deserialization methods of simple types (as they have no relevance in this case).

The workaround I've found was to exclude simple types from the list of nodes for which 'current_node' needs to be initialized.

<!-- the position()=1 should be outside the otherwise choose of @attribute -->
+             <xsl:choose>
+               <xsl:when test="not(@isarray)">  <!--not an array so continue normal -->
+                     <xsl:if test="$ordered or not($anon or $istype or @simple) or $choice"> <!-- since non-anon and choices has just only one sub element-->
+                         <xsl:if test="position()=1">
+                           current_node = first_node;
+                           is_early_node_valid = AXIS2_FALSE;

                              .........

+               </xsl:when>
+               <xsl:otherwise>
+                    current_node = first_node;
+                    is_early_node_valid = AXIS2_FALSE;
+               </xsl:otherwise>
+             </xsl:choose>

However, I'm still a long way from fully understanding the logic behind the template, so I'm not sure if this workaround is correct.

Thank you for your help.

Catalina-Georgiana Caloian
Software Engineer
 
Quintiq
 
T +31 (0) 73 691 07 39
F +31 (0) 73 691 07 54
M +31 (0) 65 247 63 99
E catalina.caloian@quintiq.com
I www.quintiq.com


>>> 
From: 	"Dimuthu Gamage" <di...@gmail.com>
To:	"Apache AXIS C Developers List" <ax...@ws.apache.org>
Date: 	11/13/2008 7:04 PM
Subject: 	Re: Incorrect deserialization when the first child is an empty element

Hi Catalina,

Looks like there is a bug. It happens that if parent types only contains
attributes, the code that you mentioned is necessary,


  current_node = first_node;
  is_early_node_valid = AXIS2_FALSE;

is never executed.


Please raise a JIRA reporting this issue. I attached a patch (taken from the
latest svn) for give an idea what has gone wrong.


Thanks
Dimuthu


-- 
Thanks,
Dimuthu Gamage

http://www.dimuthu.org 
http://www.wso2.org


This message contains information that may be privileged or confidential and is the property of Quintiq. It is only intended for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute or use this message or any part thereof. If you have received this message in error, please notify the sender immediately and delete all copies of this message. Please note that e-mails are susceptible to change, therefore they are not binding.

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-c-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-c-dev-help@ws.apache.org