axis-c-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Now Pains Now Gains <nowgains.nowpa...@gmail.com>
Subject Re: How to get rid of the error from attribute parsing?
Date Tue, 11 Jan 2011 23:54:56 GMT
Hi all,

I have a .NET web service login service. The following is the response
from the Login service. Somehow, because the results are returned as
"Attributes" of the <LoginResult> Element, the soap2c utility tool
generated function for deserialize it always returns AXIS2_FAILURE
(because it tries to get child nodes from the LoginResult
node/element, but it does not have any child, so "first_node" is
always NULL! See the code below ) . How can I get rid of this problem?
Is there a workaround for this if I don't want to manually rewrite
this function?

 <?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
 <soap:Body>
 <LoginResponse xmlns="MyProject.Web.Services">
       <LoginResult Authenticated="true" FollowRedirects="true"
AuthTicket="some long ..... string"   ServerName="World Acceptance"
AuthTicketCookieName="som_a" />
 </LoginResponse>
 </soap:Body>
 </soap:Envelope>


 soap2c genereated serializer:

 adb_LoginInfo_deserialize(adb_LoginInfo_t* _LoginInfo, const axutil_env_t *env,
         axiom_node_t **dp_parent, axis2_bool_t *dp_is_early_node_valid,
         axis2_bool_t dont_care_minoccurs) {
     axiom_node_t *parent = *dp_parent;

     axis2_status_t status = AXIS2_SUCCESS;

     const axis2_char_t* text_value = NULL;
     axutil_qname_t *qname = NULL;

     axutil_qname_t *element_qname = NULL;

     axiom_node_t *first_node = NULL;
     axis2_bool_t is_early_node_valid = AXIS2_TRUE;
     axiom_node_t *current_node = NULL;
     axiom_element_t *current_element = NULL;

     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK(env->error, _LoginInfo, AXIS2_FAILURE);

     while (parent && axiom_node_get_node_type(parent, env) != AXIOM_ELEMENT) {
         parent = axiom_node_get_next_sibling(parent, env);
     }
     if (NULL == parent) {
         /* This should be checked before everything */
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                 "Failed in building adb object for LoginInfo : "
                     "NULL elemenet can not be passed to deserialize");
         return AXIS2_FAILURE;
     }

     first_node = axiom_node_get_first_child(parent, env);

     /*
      * building Authenticated element
      */

     current_node = first_node;
     is_early_node_valid = AXIS2_FALSE;

     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);
         qname = axiom_element_get_qname(current_element, env, current_node);
     }

     element_qname = axutil_qname_create(env, "Authenticated",
             "MyProject.Web.Services", NULL);

     if ((current_node && current_element && (axutil_qname_equals(element_qname,
             env, qname)))) {
         if (current_node && current_element && (axutil_qname_equals(
                 element_qname, env, qname))) {
             is_early_node_valid = AXIS2_TRUE;
         }

         text_value = axiom_element_get_text(current_element, env,
current_node);
         if (text_value != NULL) {
             if (!axutil_strcasecmp(text_value, "true")) {
                 status = adb_LoginInfo_set_Authenticated(_LoginInfo, env,
                         AXIS2_TRUE);
             } else {
                 status = adb_LoginInfo_set_Authenticated(_LoginInfo, env,
                         AXIS2_FALSE);
             }
         }

         else {
             AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                     "NULL value is set to a non nillable element
Authenticated");
             status = AXIS2_FAILURE;
         }

         if (AXIS2_FAILURE == status) {
             AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                     "failed in setting the value for Authenticated ");
             if (element_qname) {
                 axutil_qname_free(element_qname, env);
             }
             return AXIS2_FAILURE;
         }
     }
     else if (!dont_care_minoccurs) {
         if (element_qname) {
             axutil_qname_free(element_qname, env);
         }
         /* this is not a nillable element*/
         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                 "non nillable or minOuccrs != 0 element Authenticated
missing");
         return AXIS2_FAILURE;
     }


 Thanks a lot.

 --
 Ch. Zhang
 ---------------------------------
 Now Gains, Now Pains




--
Ch. Zhang
---------------------------------
Now Gains, Now Pains

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


Mime
View raw message