axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From " (JIRA)" <>
Subject [jira] Commented: (AXIS2C-730) using wsdl2c with -d adb option, and element with minOccurs=0 results in lost nodes in the deserialize method
Date Thu, 29 Nov 2007 22:49:43 GMT

] commented on AXIS2C-730:


I was actually experiencing a similar problem and was excited to see the fix being completed.
To test it, I checked out the nightly build from 29 November for AXIS2/JAVA and used the updated
WSDL2C tool to generate the C code for me with the adb option.

Now, where previously my test project would crash, it now does not crash anymore, so that's
good. However, the parsing is still not done correctly in the scenario described below. 

I receive the following SOAP response from my web server:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="" xmlns:xsd=""
<loginResponse xmlns="">
		<ns1:SessionId xmlns:ns1="">
		<ns2:User xmlns:ns2="">

So far so good. What you can't see from this message (as is expected), is that I have a sequence/array
of length zero and hence it does not show up in the response (a similar situation as described
in the initial problem). Now, the wsdl type looks like the following:

			<complexType name="UserInfo">
					<element name="UserId" nillable="false" type="common:UniqueId" />
					<element name="Username" nillable="false" type="xsd:string" />
						<element name="AccountTypes" nillable="false" 
							minOccurs="0" maxOccurs="unbounded" type="common:AccountType" />

The problem seems to arise that the generated code expects the sequence to have a sibling.
However, since it does not, the current node is NULL which, in turn, causes deserialization
of the non-existent sequence to fail. This, of course, causes the deserialization of the whole
type to fail. Specifically, the generated code that I now get from the WSDL2C tool is:

                      * building UserInfoSequence_type0 element
                                     * because elements are ordered this works fine
                                   if(current_node != NULL && is_early_node_valid)
                                       current_node = axiom_node_get_next_sibling(current_node,
                                       while(current_node && axiom_node_get_node_type(current_node,
                                           current_node = axiom_node_get_next_sibling(current_node,
                                       if(current_node != NULL)
                                           current_element = (axiom_element_t *)axiom_node_get_data_element(current_node,
                                   is_early_node_valid = AXIS2_FALSE;

                               qname = axiom_element_get_qname(current_element, env, current_node);
                                 element_qname = axutil_qname_create(env, "UserInfoSequence_type0",
"", NULL);

                           if (adb_UserInfoSequence_type0_is_particle() ||  
                                (current_node && current_element && axutil_qname_equals(element_qname,
env, qname)))
                              is_early_node_valid = AXIS2_TRUE;
                                      element = (void*)adb_UserInfoSequence_type0_create(env);

                                      status =  adb_UserInfoSequence_type0_deserialize((adb_UserInfoSequence_type0_t*)element,
                                                                            env, &current_node);
                                      if(AXIS2_FAILURE == status)
                                          AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed
in building adb object for element UserInfoSequence_type0");
                                          return AXIS2_FAILURE;
                                      status = adb_UserInfo_set_UserInfoSequence_type0(_UserInfo,
                                 if(AXIS2_FAILURE ==  status)
                                     AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in
setting the value for UserInfoSequence_type0 ");
                                     return AXIS2_FAILURE;
                                  return AXIS2_FAILURE;

>From the code above, the following line makes the current_node equal to NULL:

current_node = axiom_node_get_next_sibling(current_node, env);

This seems correct as the sequence does not have another sibling (maybe I'm interpreting this
incorrectly). Now, after a few lines, the following line gets executed:

status =  adb_UserInfoSequence_type0_deserialize((adb_UserInfoSequence_type0_t*)element,
                                                                            env, &current_node);

At this stage, the current_node is still NULL. The prototype of the function above was generated
to be: 

        axis2_status_t AXIS2_CALL
                adb_UserInfoSequence_type0_t* _UserInfoSequence_type0,
                const axutil_env_t *env,
                axiom_node_t **dp_parent)
In other words, the dp_parent is NULL in this case. This, in turn, caused the final building
of the adb object to fail since the method above contains the following check:

              if (NULL == parent)
                /* This should be checked before everything */
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                            "Failed in building adb object for UserInfoSequence_type0 : "
                            "NULL elemenet can not be passed to deserialize");
                return AXIS2_FAILURE;

This then causes the deserialization of the SOAP message to fail. 

It would be great if you could help me out in fixing this issue.

Thanks for all your help and time in advance.


Quoted from:

>  using wsdl2c with -d adb option, and element with minOccurs=0 results in lost nodes
in the deserialize method
> --------------------------------------------------------------------------------------------------------------
>                 Key: AXIS2C-730
>                 URL:
>             Project: Axis2-C
>          Issue Type: Bug
>          Components: code generation
>    Affects Versions: 1.1.0
>         Environment: Windows
>            Reporter: José Manuel Rubio
> I created stub using wsdl2c with -d adb option. 
> Generated code does not take into account the fact that a node could be missing from
the input. For example the following code is being generated:
> axis2_status_t AXIS2_CALL
> adb_ship_deserialize(
>        adb_ship_t* _ship,
>        const axutil_env_t *env,
>        axiom_node_t* parent)
> {
>    .
>    .
>    .
> if (current_node  && axiom_node_get_data_element( current_node, env) &&
> axiom_element_get_localname((axiom_element_t *)axiom_node_get_data_element( current_node,
env), env))
> )
> {
> 	current_element = (axiom_element_t *)axiom_node_get_data_element( current_node, env);
> 		  text_value = axiom_element_get_text(current_element, env, current_node );
> 	status = adb_ship_set_actualDraught( _ship, env,
> 										 atof( text_value));
> 	if( AXIS2_FAILURE ==  status)
> 	{
> 		AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "failed in setting the value for actualDraught
> 							 " %d :: %s", env->error->error_number,
> 							 AXIS2_ERROR_GET_MESSAGE(env->error));
> 		return AXIS2_FAILURE;
> 	}
> }
> if(current_node != NULL)
> {
>         //Here it is asking for the next node even when the code above has not processed
the current_node
> 	current_node = axiom_node_get_next_sibling( current_node, env);
> }

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:
For additional commands, e-mail:

View raw message