[
https://issues.apache.org/jira/browse/AXIS2C-730?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12546926
]
[EMAIL PROTECTED] commented on AXIS2C-730:
------------------------------------------
Hi,
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="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<loginResponse xmlns="urn:types.directory.mycompany.com">
<loginReturn>
<ns1:SessionId xmlns:ns1="urn:common.mycompany.com">
<ns1:Raw>xxx</ns1:Raw>
</ns1:SessionId>
<ns2:User xmlns:ns2="urn:common.mycompany.com">
<ns2:UserId><ns2:Raw>xxx</ns2:Raw></ns2:UserId>
<ns2:Username>yyy</ns2:Username>
</ns2:User>
</loginReturn>
</loginResponse>
</soapenv:Body>
</soapenv:Envelope>
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">
<sequence>
<element name="UserId" nillable="false"
type="common:UniqueId" />
<element name="Username"
nillable="false" type="xsd:string" />
<sequence>
<element name="AccountTypes"
nillable="false"
minOccurs="0"
maxOccurs="unbounded" type="common:AccountType" />
</sequence>
</sequence>
</complexType>
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, env);
while(current_node &&
axiom_node_get_node_type(current_node, env) != AXIOM_ELEMENT)
{
current_node =
axiom_node_get_next_sibling(current_node, env);
}
if(current_node != NULL)
{
current_element = (axiom_element_t
*)axiom_node_get_data_element(current_node, env);
}
}
is_early_node_valid = AXIS2_FALSE;
qname = axiom_element_get_qname(current_element,
env, current_node);
element_qname = axutil_qname_create(env,
"UserInfoSequence_type0", "urn:common.mycompany.com", 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, ¤t_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, env,
(adb_UserInfoSequence_type0_t*)element);
if(AXIS2_FAILURE == status)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
"failed in setting the value for UserInfoSequence_type0 ");
return AXIS2_FAILURE;
}
}
else
{
...
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, ¤t_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_deserialize(
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.
Cheers,
Frank
Quoted from:
http://www.nabble.com/-jira--Created%3A-%28AXIS2C-730%29--using-wsdl2c-with--d-adb-option%2C-and-element-with-minOccurs%3D0-results-in-lost-nodes-in-the-deserialize-method-tf4652563.html#a13947621
> using wsdl2c with -d adb option, and element with minOccurs=0 results in
> lost nodes in the deserialize method
> --------------------------------------------------------------------------------------------------------------
>
> Key: AXIS2C-730
> URL: https://issues.apache.org/jira/browse/AXIS2C-730
> 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) &&
> !axutil_strcmp("actualDraught",
> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]