You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-user@axis.apache.org by "Haszlakiewicz, Eric" <EH...@transunion.com> on 2008/10/10 01:22:45 UTC

problem with WSDL2C generated code and empty elements

I have an element in my schema that is defined like so:
    <xs:simpleType name="foo-type">
        <xs:restriction base="xs:string">
            <xs:minLength value="0"/>
            <xs:maxLength value="10"/>
        </xs:restriction>
    </xs:simpleType>
...
    <xs:element name="myelem" type="tns:foo-type" minOccurs="1"
maxOccurs="1"/>

I have code that generates responses with this element in it using the
adb methods, and that seems to work fine, at least some of the time.
I'm running into problems when the length of the string is 0.  The
element is created, and returned to the client, but the generated
adb_foo_type_deserialize function doesn't handle it correctly.  I think
the fix is fairly simple:

...snip...
    text_node = axiom_node_get_first_child(parent, env);
    if (text_node &&
        axiom_node_get_node_type(text_node, env) == AXIOM_TEXT)
   {
      axiom_text_t *text_element =
(axiom_text_t*)axiom_node_get_data_element(text_node, env);
      if(text_element && axiom_text_get_value(text_element, env))
      {
           text_value =
(axis2_char_t*)axiom_text_get_value(text_element, env);
           status =
adb_address_line_type_deserialize_from_string(_address_line_type, env,
text_value, parent);
       }
   }
...snip...

turns into:
    text_node = axiom_node_get_first_child(parent, env);
    axiom_text_t *text_element;
    if (text_node &&
        axiom_node_get_node_type(text_node, env) == AXIOM_TEXT)
      text_element =
(axiom_text_t*)axiom_node_get_data_element(text_node, env);

   if(text_element && axiom_text_get_value(text_element, env))
      text_value = (axis2_char_t*)axiom_text_get_value(text_element,
env);
   else
      text_value = "";

   status =
adb_address_line_type_deserialize_from_string(_address_line_type, env,
text_value, parent);


Does that make sense?  Should I submit the patch to the stylesheet used
by WSDL2C as a axis2/c bug or a axis2/java bug?

eric

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


Re: problem with WSDL2C generated code and empty elements

Posted by Dimuthu Gamage <di...@gmail.com>.
Hi Eric,
Yea it looks like a bug. Please submit the patch to the Axis2/C jiras.

Thanks
Dimuthu

On Fri, Oct 10, 2008 at 4:52 AM, Haszlakiewicz, Eric <EHASZLA@transunion.com
> wrote:

>
> I have an element in my schema that is defined like so:
>    <xs:simpleType name="foo-type">
>        <xs:restriction base="xs:string">
>            <xs:minLength value="0"/>
>            <xs:maxLength value="10"/>
>        </xs:restriction>
>    </xs:simpleType>
> ...
>    <xs:element name="myelem" type="tns:foo-type" minOccurs="1"
> maxOccurs="1"/>
>
> I have code that generates responses with this element in it using the
> adb methods, and that seems to work fine, at least some of the time.
> I'm running into problems when the length of the string is 0.  The
> element is created, and returned to the client, but the generated
> adb_foo_type_deserialize function doesn't handle it correctly.  I think
> the fix is fairly simple:
>
> ...snip...
>    text_node = axiom_node_get_first_child(parent, env);
>    if (text_node &&
>        axiom_node_get_node_type(text_node, env) == AXIOM_TEXT)
>   {
>      axiom_text_t *text_element =
> (axiom_text_t*)axiom_node_get_data_element(text_node, env);
>      if(text_element && axiom_text_get_value(text_element, env))
>      {
>           text_value =
> (axis2_char_t*)axiom_text_get_value(text_element, env);
>           status =
> adb_address_line_type_deserialize_from_string(_address_line_type, env,
> text_value, parent);
>       }
>   }
> ...snip...
>
> turns into:
>    text_node = axiom_node_get_first_child(parent, env);
>    axiom_text_t *text_element;
>    if (text_node &&
>        axiom_node_get_node_type(text_node, env) == AXIOM_TEXT)
>      text_element =
> (axiom_text_t*)axiom_node_get_data_element(text_node, env);
>
>   if(text_element && axiom_text_get_value(text_element, env))
>      text_value = (axis2_char_t*)axiom_text_get_value(text_element,
> env);
>   else
>      text_value = "";
>
>   status =
> adb_address_line_type_deserialize_from_string(_address_line_type, env,
> text_value, parent);
>
>
> Does that make sense?  Should I submit the patch to the stylesheet used
> by WSDL2C as a axis2/c bug or a axis2/java bug?
>
> eric
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-c-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-c-user-help@ws.apache.org
>
>


-- 
Thanks,
Dimuthu Gamage

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