axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nand...@apache.org
Subject svn commit: r385453 [3/4] - in /webservices/axis2/trunk/c: include/ modules/xml/om/ modules/xml/soap/ test/unit/xml/om/ test/xml/om/ test/xml/soap/
Date Mon, 13 Mar 2006 08:11:06 GMT
Modified: webservices/axis2/trunk/c/modules/xml/soap/soap12_builder_helper.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/soap/soap12_builder_helper.c?rev=385453&r1=385452&r2=385453&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/soap/soap12_builder_helper.c (original)
+++ webservices/axis2/trunk/c/modules/xml/soap/soap12_builder_helper.c Mon Mar 13 00:11:01 2006
@@ -84,7 +84,7 @@
                              
 /******************** function implementations ********************************/
 
- AXIS2_DECLARE(axis2_soap12_builder_helper_t*)
+AXIS2_DECLARE(axis2_soap12_builder_helper_t*)
 axis2_soap12_builder_helper_create(axis2_env_t **env, 
                                    axis2_soap_builder_t *soap_builder)
 {
@@ -115,8 +115,10 @@
     builder_helper_impl->value_present = AXIS2_FALSE;
     builder_helper_impl->subcode_value_present = AXIS2_FALSE;
     builder_helper_impl->builder_helper.ops = NULL; 
+
     builder_helper_impl->builder_helper.ops = (axis2_soap12_builder_helper_ops_t*) AXIS2_MALLOC(
                                                 (*env)->allocator, sizeof(axis2_soap12_builder_helper_ops_t));
+    
     if(!(builder_helper_impl->builder_helper.ops))
     {
         AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
@@ -163,27 +165,42 @@
                              int element_level)
 {
     axis2_soap12_builder_helper_impl_t *builder_helper_impl = NULL;
+    
     axis2_char_t* ele_localname = NULL;
     axis2_om_element_t *om_ele = NULL;
+    
     axis2_soap_body_t *soap_body = NULL;
     axis2_soap_fault_t *soap_fault = NULL;
     axis2_soap_envelope_t *soap_envelope = NULL;    
     
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK((*env)->error, om_ele_node, AXIS2_FAILURE);
-
     builder_helper_impl = AXIS2_INTF_TO_IMPL(builder_helper);
+    
     om_ele = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(om_ele_node, env);
+    if(!om_ele)
+        return AXIS2_FAILURE;
+        
     ele_localname = AXIS2_OM_ELEMENT_GET_LOCALNAME(om_ele, env);
+    if(!ele_localname)
+        return AXIS2_FAILURE;
+    
     soap_envelope = AXIS2_SOAP_BUILDER_GET_SOAP_ENVELOPE(builder_helper_impl->soap_builder, env);
+    if(!soap_envelope)
+        return AXIS2_FAILURE;
+        
     soap_body = AXIS2_SOAP_ENVELOPE_GET_BODY(soap_envelope, env);
-    soap_fault = AXIS2_SOAP_BODY_GET_FAULT(soap_body, env);   
-   
-    if(element_level == 4)
+    if(!soap_body)
+        return AXIS2_FAILURE;
+
+    soap_fault = AXIS2_SOAP_BODY_GET_FAULT(soap_body, env);
+    if(!soap_fault)
+        return AXIS2_FAILURE;
+        
+   if(element_level == 4)
     {
         if(AXIS2_STRCMP(AXIS2_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME, ele_localname) == 0)
         {
-           
             if(builder_helper_impl->code_present)
             {
                 AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_MULTIPLE_CODE_ELEMENTS_ENCOUNTERED, AXIS2_FAILURE);
@@ -193,12 +210,18 @@
             {
                 axis2_soap_fault_code_t* soap_fault_code = NULL;
                 soap_fault_code = axis2_soap_fault_code_create(env);
+                if(!soap_fault_code)
+                    return AXIS2_FAILURE;
+   
                 AXIS2_SOAP_FAULT_CODE_SET_BASE_NODE(soap_fault_code , env, om_ele_node);            
-                AXIS2_SOAP_FAULT_CODE_SET_SOAP_VERSION(soap_fault_code, env, AXIS2_SOAP12);
+                
+       /*         AXIS2_SOAP_FAULT_CODE_SET_SOAP_VERSION(soap_fault_code, env, AXIS2_SOAP12); */
                 
                 AXIS2_SOAP_FAULT_CODE_SET_BUILDER(soap_fault_code, env, 
                     builder_helper_impl->soap_builder);
+                    
                 AXIS2_SOAP_FAULT_SET_CODE(soap_fault, env, soap_fault_code);
+                
                 builder_helper_impl->code_present = AXIS2_TRUE;
                 builder_helper_impl->code_processing = AXIS2_TRUE;
             }
@@ -220,9 +243,14 @@
                     {
                         axis2_soap_fault_reason_t *fault_reason = NULL;
                         fault_reason = axis2_soap_fault_reason_create(env);
+                        if(!fault_reason)
+                            return AXIS2_FAILURE;
+                 
                         AXIS2_SOAP_FAULT_REASON_SET_BASE_NODE(fault_reason, env, om_ele_node);
-                        AXIS2_SOAP_FAULT_SET_SOAP_VERSION(fault_reason, env, AXIS2_SOAP12);
+                     /*   AXIS2_SOAP_FAULT_SET_SOAP_VERSION(fault_reason, env, AXIS2_SOAP12); */
+                     
                         AXIS2_SOAP_FAULT_SET_REASON(soap_fault, env, fault_reason);
+                     
                         AXIS2_SOAP_FAULT_REASON_SET_BUILDER(soap_fault, env, 
                                 builder_helper_impl->soap_builder); 
                                 
@@ -271,10 +299,15 @@
                     {
                         axis2_soap_fault_node_t *soap_fault_node = NULL;
                         soap_fault_node = axis2_soap_fault_node_create(env);
+                        if(!soap_fault_node)
+                            return AXIS2_FAILURE;
                         
                         AXIS2_SOAP_FAULT_NODE_SET_BASE_NODE(soap_fault_node, env, om_ele_node);
-                        AXIS2_SOAP_FAULT_NODE_SET_SOAP_VERSION(soap_fault_node, env, AXIS2_SOAP12);
+                        
+                /*        AXIS2_SOAP_FAULT_NODE_SET_SOAP_VERSION(soap_fault_node, env, AXIS2_SOAP12); */
+                
                         AXIS2_SOAP_FAULT_SET_NODE(soap_fault, env, soap_fault_node);                    
+                
                         builder_helper_impl->node_present = AXIS2_TRUE;                    
                     }
                 }else
@@ -311,8 +344,12 @@
                     {
                         axis2_soap_fault_role_t *soap_fault_role = NULL;
                         soap_fault_role = axis2_soap_fault_role_create(env);
+                        if(!soap_fault_role)
+                            return AXIS2_FAILURE;
+                        
                         AXIS2_SOAP_FAULT_ROLE_SET_BASE_NODE(soap_fault_role, env, om_ele_node);
-                        AXIS2_SOAP_FAULT_ROLE_SET_SOAP_VRESION(soap_fault_role, env, AXIS2_SOAP12);
+                    /*    AXIS2_SOAP_FAULT_ROLE_SET_SOAP_VRESION(soap_fault_role, env, AXIS2_SOAP12); */
+                    
                         AXIS2_SOAP_FAULT_SET_ROLE(soap_fault, env, soap_fault_role);
                         builder_helper_impl->role_present = AXIS2_TRUE;                    
                     }
@@ -348,8 +385,12 @@
                         
                         axis2_soap_fault_detail_t *soap_fault_detail = NULL;
                         soap_fault_detail = axis2_soap_fault_detail_create(env);
+                        if(!soap_fault_detail)
+                            return AXIS2_FAILURE;
+                            
                         AXIS2_SOAP_FAULT_DETAIL_SET_BASE_NODE(soap_fault_detail, env, om_ele_node);
-                        AXIS2_SOAP_FAULT_SET_SOAP_VERSION(soap_fault_detail, env, AXIS2_SOAP12);
+                   /*     AXIS2_SOAP_FAULT_SET_SOAP_VERSION(soap_fault_detail, env, AXIS2_SOAP12); */
+                   
                         AXIS2_SOAP_FAULT_SET_DETAIL(soap_fault, env, soap_fault_detail);
                         builder_helper_impl->detail_present = AXIS2_TRUE;
                     }                        
@@ -383,8 +424,17 @@
         axis2_om_element_t *parent_ele = NULL;
         axis2_char_t *parent_localname = NULL;
         parent_node = AXIS2_OM_NODE_GET_PARENT(om_ele_node, env);
+        if(!parent_node)
+            return AXIS2_FAILURE;
+       
         parent_ele = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(parent_node, env);
+        if(!parent_ele)
+            return AXIS2_FAILURE;
+
         parent_localname = AXIS2_OM_ELEMENT_GET_LOCALNAME(parent_ele, env);
+        if(!parent_localname)
+            return AXIS2_FAILURE;
+            
         if(AXIS2_STRCMP(parent_localname, 
             AXIS2_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME) == 0)
         {
@@ -394,10 +444,18 @@
                 {
                     axis2_soap_fault_value_t *soap_fault_value = NULL;
                     axis2_soap_fault_code_t *parent_fcode = NULL;
+                    
                     soap_fault_value = axis2_soap_fault_value_create(env);
+                    if(!soap_fault_value)
+                        return AXIS2_FAILURE;
+                        
                     AXIS2_SOAP_FAULT_VALUE_SET_BASE_NODE(soap_fault_value, env, om_ele_node);
-                    AXIS2_SOAP_FAULT_VALUE_SET_SOAP_VERSION(soap_fault_value, env, AXIS2_SOAP12);                    
+             /*       AXIS2_SOAP_FAULT_VALUE_SET_SOAP_VERSION(soap_fault_value, env, AXIS2_SOAP12);  */
+             
                     parent_fcode = AXIS2_SOAP_FAULT_GET_CODE(soap_fault, env);
+                    if(!parent_fcode)
+                        return AXIS2_FAILURE;
+                        
                     AXIS2_SOAP_FAULT_CODE_SET_VALUE(parent_fcode, env, soap_fault_value);
                     
                     builder_helper_impl->value_present = AXIS2_TRUE;
@@ -412,7 +470,7 @@
                 }            
             }
             else if(AXIS2_STRCMP(ele_localname, 
-                AXIS2_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME) == 0)
+                        AXIS2_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME) == 0)
             {
                 if(!(builder_helper_impl->sub_code_present))
                 {
@@ -421,10 +479,19 @@
                         
                         axis2_soap_fault_sub_code_t *fault_subcode = NULL;
                         axis2_soap_fault_code_t *fault_code = NULL;
+        
                         fault_subcode = axis2_soap_fault_sub_code_create(env);
+                        if(!fault_subcode)
+                            return AXIS2_FAILURE;
+                        
                         AXIS2_SOAP_FAULT_SUB_CODE_SET_BASE_NODE(fault_subcode, env, om_ele_node);
-                        AXIS2_SOAP_FAULT_SUB_CODE_SET_SOAP_VRESION(fault_subcode, env, AXIS2_SOAP12);
+                        
+              /*          AXIS2_SOAP_FAULT_SUB_CODE_SET_SOAP_VRESION(fault_subcode, env, AXIS2_SOAP12); */
+              
                         fault_code = AXIS2_SOAP_FAULT_GET_CODE(soap_fault, env);
+                        if(!fault_code)
+                            return AXIS2_FAILURE;
+                            
                         AXIS2_SOAP_FAULT_CODE_SET_SUB_CODE(fault_code, env, fault_subcode);
                         
                         AXIS2_SOAP_FAULT_SUB_CODE_SET_BUILDER(fault_subcode, env,
@@ -459,15 +526,24 @@
             {
                 axis2_soap_fault_text_t *soap_fault_text = NULL;
                 axis2_soap_fault_reason_t *fault_reason = NULL;
+
                 soap_fault_text = axis2_soap_fault_text_create(env);
+                if(!soap_fault_text)
+                    return AXIS2_FAILURE;
+                               
                 AXIS2_SOAP_FAULT_TEXT_SET_BASE_NODE(soap_fault_text, env, om_ele_node);
-                AXIS2_SOAP_FAULT_TEXT_SET_SOAP_VERSION(soap_fault_text, env, AXIS2_SOAP12);
+            /*    AXIS2_SOAP_FAULT_TEXT_SET_SOAP_VERSION(soap_fault_text, env, AXIS2_SOAP12); */
+            
                 fault_reason = AXIS2_SOAP_FAULT_GET_REASON(soap_fault, env);
+                if(!fault_reason)
+                    return AXIS2_FAILURE;
+                    
                 AXIS2_SOAP_FAULT_REASON_SET_SOAP_FAULT_TEXT(fault_reason, env, soap_fault_text);
                 /*****************
                 AXIS2_OM_NODE_SET_BUILD_STATUS(om_ele_node, env, AXIS2_FALSE);
                 ******************/
                 builder_helper_impl->reason_processing = AXIS2_FALSE;
+                
                 AXIS2_SOAP_BUILDER_SET_BOOL_PROCESSING_MANDATORY_FAULT_ELEMENTS(builder_helper_impl->soap_builder, env, AXIS2_FALSE );
                 
             }
@@ -480,6 +556,7 @@
         }else if(AXIS2_STRCMP(parent_localname, AXIS2_SOAP12_SOAP_FAULT_DETAIL_LOCAL_NAME) == 0)
         {
             AXIS2_SOAP_BUILDER_SET_PROCESSING_DETAIL_ELEMENTS(builder_helper_impl->soap_builder, env, AXIS2_TRUE);
+            
             if(!(builder_helper_impl->detail_element_names))
             {
                 builder_helper_impl->detail_element_names = axis2_array_list_create(env, 20);
@@ -499,9 +576,20 @@
         axis2_om_node_t *parent_node = NULL;
         axis2_om_element_t *parent_ele = NULL;
         axis2_char_t *parent_localname = NULL;
+        
         parent_node = AXIS2_OM_NODE_GET_PARENT(om_ele_node, env);
+        if(!parent_node)
+            return AXIS2_FAILURE;
+               
         parent_ele = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(parent_node, env);
+        if(!parent_ele)
+            return AXIS2_FAILURE;
+            
         parent_localname = AXIS2_OM_ELEMENT_GET_LOCALNAME(parent_ele, env);   
+        if(!parent_localname)
+            return AXIS2_FAILURE;
+
+
         
         if(AXIS2_STRCMP(parent_localname, AXIS2_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME) == 0)
         {
@@ -519,10 +607,25 @@
                     axis2_soap_fault_code_t *code = NULL;
                     axis2_soap_fault_value_t *value = NULL;
                     code = AXIS2_SOAP_FAULT_GET_CODE(soap_fault, env);
+                    
+                    if(!code)
+                    {
+                        AXIS2_LOG_DEBUG((*env)->log , AXIS2_LOG_SI, "fault code null when it should not be null");
+                        return AXIS2_FAILURE;
+                    }
+                    
                     sub_code = AXIS2_SOAP_FAULT_CODE_GET_SUB_CODE(code, env);
+                    if(!sub_code)
+                    {
+                        AXIS2_LOG_DEBUG((*env)->log , AXIS2_LOG_SI, "fault subcode null when it should not be null");
+                        return AXIS2_FAILURE;
+                    }
                     value = axis2_soap_fault_value_create(env);
+                    if(!value)
+                        return AXIS2_FAILURE;
+                        
                     AXIS2_SOAP_FAULT_VALUE_SET_BASE_NODE(value, env, om_ele_node);
-                    AXIS2_SOAP_FAULT_VALUE_SET_SOAP_VERSION(value, env, AXIS2_SOAP12);
+                    
                     AXIS2_SOAP_FAULT_SUB_CODE_SET_VALUE(sub_code, env, value);
              
                     builder_helper_impl->subcode_value_present = AXIS2_TRUE;
@@ -539,12 +642,28 @@
                         axis2_soap_fault_code_t *fault_code = NULL;
                         axis2_soap_fault_sub_code_t *parent_subcode = NULL;
                         axis2_soap_fault_sub_code_t *subcode = NULL;
+
                         subcode = axis2_soap_fault_sub_code_create(env);
+                        if(!subcode)
+                            return AXIS2_FAILURE;
+                            
                         AXIS2_SOAP_FAULT_SUB_CODE_SET_BASE_NODE(subcode, env, om_ele_node);
-                        AXIS2_SOAP_FAULT_SUB_CODE_SET_SOAP_VRESION(subcode, env, AXIS2_SOAP12);
+                  
                         fault_code = AXIS2_SOAP_FAULT_GET_CODE(soap_fault, env);
+                        if(!fault_code)
+                        {
+                            AXIS2_LOG_DEBUG((*env)->log , AXIS2_LOG_SI, "fault code null when it should not be null");
+                            return AXIS2_FAILURE;
+                        }
                         parent_subcode = AXIS2_SOAP_FAULT_CODE_GET_SUB_CODE(fault_code, env);
+                        if(!parent_subcode)
+                        {
+                            AXIS2_LOG_DEBUG((*env)->log , AXIS2_LOG_SI, "fault subcode null when it should not be null");
+                            return AXIS2_FAILURE;
+                        }
+                        
                         AXIS2_SOAP_FAULT_SUB_CODE_SET_SUB_CODE(parent_subcode, env, subcode);
+                        
                         builder_helper_impl->subcode_value_present = AXIS2_FALSE;
                         builder_helper_impl->sub_sub_code_present = AXIS2_TRUE;
                         builder_helper_impl->sub_code_processing = AXIS2_TRUE;                        
@@ -577,6 +696,9 @@
             int detail_element_level = 0;
             axis2_bool_t local_name_exists = AXIS2_FALSE;
             int i = 0;
+            if(!(builder_helper_impl->detail_element_names))
+                return AXIS2_FAILURE;
+                
             for(i =0; i < AXIS2_ARRAY_LIST_SIZE(builder_helper_impl->detail_element_names, env) ; i++)
             {
                 if(AXIS2_STRCMP(parent_localname, AXIS2_ARRAY_LIST_GET(builder_helper_impl->detail_element_names, env, i)) == 0)

Modified: webservices/axis2/trunk/c/modules/xml/soap/soap_body.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/soap/soap_body.c?rev=385453&r1=385452&r2=385453&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/soap/soap_body.c (original)
+++ webservices/axis2/trunk/c/modules/xml/soap/soap_body.c Mon Mar 13 00:11:01 2006
@@ -107,7 +107,7 @@
     body_impl->soap_body.ops = NULL;
     body_impl->om_ele_node = NULL;
     body_impl->soap_builder = NULL;
-    body_impl->soap_version = AXIS2_SOAP_VERSION_NOT_SET;    
+    body_impl->soap_version = AXIS2_SOAP12;    
     body_impl->has_fault = AXIS2_FALSE;
     body_impl->soap_fault = NULL; 
 
@@ -161,19 +161,23 @@
    
     
     /*get parent node from SOAP envelope */
-    if (envelope)
+    parent = AXIS2_SOAP_ENVELOPE_GET_BASE_NODE(envelope, env);
+    if(!parent)
     {
-        parent = AXIS2_SOAP_ENVELOPE_GET_BASE_NODE(envelope, env);
-        if(parent)
-        {
-            parent_ele = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(
-                        parent, env);
-        }            
+        AXIS2_SOAP_BODY_FREE(&(body_impl->soap_body), env);
+        return NULL;        
     }
-    if(parent_ele)
-        om_ns = AXIS2_OM_ELEMENT_GET_NAMESPACE(parent_ele, env);
-    
+    parent_ele = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(
+                        parent, env);
+
+    if(!parent_ele)
+    {
+        AXIS2_SOAP_BODY_FREE(&(body_impl->soap_body), env);
+        return NULL;        
+    }  
     
+    om_ns = AXIS2_OM_ELEMENT_GET_NAMESPACE(parent_ele, env);
+
     ele = axis2_om_element_create(env, parent, 
                                   AXIS2_SOAP_BODY_LOCAL_NAME, om_ns, 
                                   &(body_impl->om_ele_node));
@@ -183,6 +187,7 @@
         axis2_soap_body_free(&(body_impl->soap_body), env);
         return NULL;
     }
+    
     AXIS2_SOAP_ENVELOPE_SET_BODY(envelope, env, &(body_impl->soap_body));
     body_impl->soap_version = 
         AXIS2_SOAP_ENVELOPE_GET_SOAP_VERSION(envelope, env);
@@ -196,7 +201,10 @@
 {
     axis2_soap_body_impl_t *body_impl = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, body, AXIS2_FAILURE);
+    
     body_impl = AXIS2_INTF_TO_IMPL(body);
+    
     if(body_impl->soap_fault)
     {
         AXIS2_SOAP_FAULT_FREE(body_impl->soap_fault, env);
@@ -213,10 +221,10 @@
 }
     
 /**
- * Indicates whether a <code>SOAPFault</code> object exists in
- * this <code>SOAPBody</code> object.
+ * Indicates whether a object exists in
+ * this SOAPBody object.
  *
- * @return <code>true</code> if a <code>SOAPFault</code> object exists in
+ * @return true</code> if a <code>SOAPFault</code> object exists in
  *         this <code>SOAPBody</code> object; <code>false</code>
  *         otherwise
  */
@@ -241,22 +249,27 @@
                 if(status == AXIS2_FAILURE)
                     return AXIS2_FALSE;
             }
+            if(body_impl->soap_fault)
+            {
+                body_impl->has_fault = AXIS2_TRUE;
+                return AXIS2_TRUE;
+            }
         }
     }
-    if(body_impl->soap_fault)
-        return AXIS2_TRUE;
+   
     return AXIS2_FALSE;
 }
 
 /**
- * Returns the <code>SOAPFault</code> object in this <code>SOAPBody</code>
- * object.
+ * Returns the axis2_soap_fault_t struct in this axis2_soap_bodY_t
+ * struct
  *
  * @return the <code>SOAPFault</code> object in this <code>SOAPBody</code>
  *         object
  */
-axis2_soap_fault_t* AXIS2_CALL axis2_soap_body_get_fault(axis2_soap_body_t *body,
-    axis2_env_t **env) 
+axis2_soap_fault_t* AXIS2_CALL 
+axis2_soap_body_get_fault(axis2_soap_body_t *body,
+                          axis2_env_t **env) 
 {
     axis2_soap_body_impl_t *body_impl = NULL;
     AXIS2_ENV_CHECK(env, NULL);
@@ -265,7 +278,7 @@
     {
         return body_impl->soap_fault;
     }
-    else if(body_impl->soap_builder != NULL)
+    else if(NULL != body_impl->soap_builder )
     {
         while(!(body_impl->soap_fault) && !(AXIS2_OM_NODE_GET_BUILD_STATUS(body_impl->om_ele_node, env)))
         {
@@ -274,38 +287,12 @@
             if(status == AXIS2_FAILURE)
                 return NULL;
         }
-    }
-    
-    /*
-    else
-    {
-        axis2_om_node_t *first_node = NULL;
-        axis2_om_element_t *first_ele = NULL;
-        axis2_om_namespace_t *om_ns = NULL;
-        axis2_char_t *ns_uri = NULL;
-        axis2_char_t *localname = NULL;        
-        first_node = AXIS2_OM_NODE_GET_FIRST_CHILD(body_impl->om_ele_node, env);
-        if(first_node)
+        if(body_impl->soap_fault)
         {
-                
-            first_ele = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(first_node, env);
-            localname = AXIS2_OM_ELEMENT_GET_LOCALNAME(first_ele, env);
-            om_ns = AXIS2_OM_ELEMENT_GET_NAMESPACE(first_ele, env);
-            ns_uri = AXIS2_OM_NAMESPACE_GET_URI(om_ns, env);
-            if(first_ele && AXIS2_STRCMP(AXIS2_SOAP_FAULT_LOCAL_NAME, localname) == 0 &&
-                (AXIS2_STRCMP(ns_uri, AXIS2_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI) == 0 ||
-                 AXIS2_STRCMP(ns_uri, AXIS2_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI) == 0))
-            {
-                body_impl->has_fault = AXIS2_TRUE;
-                body_impl->soap_fault = axis2_soap_fault_create(env);
-                AXIS2_SOAP_FAULT_SET_SOAP_VERSION(body_impl->soap_fault, 
-                        env, body_impl->soap_version);
-                AXIS2_SOAP_FAULT_SET_BASE_NODE(body_impl->soap_fault, env, first_node);
-                return body_impl->soap_fault;                            
-            }                 
+            body_impl->has_fault = AXIS2_TRUE;
+            return body_impl->soap_fault;            
         }
     }
-    */
     return NULL;
 }
 

Modified: webservices/axis2/trunk/c/modules/xml/soap/soap_builder.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/soap/soap_builder.c?rev=385453&r1=385452&r2=385453&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/soap/soap_builder.c (original)
+++ webservices/axis2/trunk/c/modules/xml/soap/soap_builder.c Mon Mar 13 00:11:01 2006
@@ -23,7 +23,7 @@
  #include <axis2_soap.h>
  #include <axis2_soap_body.h>
  #include <axis2_soap_header_block.h>
- 
+ #include <axis2_om_stax_builder_internal.h>
  /*********************** impl struct *****************************************/
  
  typedef struct axis2_soap_builder_impl_t
@@ -66,8 +66,7 @@
 typedef enum axis2_builder_last_node_states
 {
     AXIS2_BUILDER_LAST_NODE_NULL = 0,
-    AXIS2_BUILDER_LAST_NODE_DONE_TRUE,
-    AXIS2_BUILDER_LAST_NODE_DONE_FALSE
+    AXIS2_BUILDER_LAST_NODE_NOT_NULL
 }axis2_builder_last_node_states;
 
 #define AXIS2_MAX_EVENT 100
@@ -240,16 +239,21 @@
 {
     axis2_soap_builder_impl_t *builder_impl = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    if(!builder)
+        return AXIS2_FAILURE;
+        
     builder_impl = AXIS2_INTF_TO_IMPL(builder);
     if(builder_impl->builder_helper)
     {
         if(builder_impl->soap_version == AXIS2_SOAP11 && builder_impl->builder_helper)
         {
             AXIS2_SOAP11_BUILDER_HELPER_FREE((axis2_soap11_builder_helper_t *)(builder_impl->builder_helper), env);
+            builder_impl->builder_helper = NULL;
         }
         else if(builder_impl->soap_version == AXIS2_SOAP12 && builder_impl->builder_helper)
         {
             AXIS2_SOAP12_BUILDER_HELPER_FREE((axis2_soap12_builder_helper_t *)(builder_impl->builder_helper), env);
+            builder_impl->builder_helper = NULL;
         }
     }
     if(builder_impl->om_builder)
@@ -260,6 +264,7 @@
     if(builder->ops)
     {
         AXIS2_FREE((*env)->allocator, builder->ops);
+        builder->ops = NULL;
     }
     AXIS2_FREE((*env)->allocator, builder_impl);
     return AXIS2_SUCCESS;
@@ -297,8 +302,15 @@
  {
     axis2_soap_builder_impl_t *builder_impl = NULL;
     AXIS2_ENV_CHECK(env, NULL);
+    if(!builder)
+        return NULL;
     builder_impl = AXIS2_INTF_TO_IMPL(builder);
-    return AXIS2_OM_STAX_BUILDER_GET_DOCUMENT(builder_impl->om_builder, env);
+    if(builder_impl->om_builder)
+    {
+        return AXIS2_OM_STAX_BUILDER_GET_DOCUMENT(builder_impl->om_builder, env);
+    }
+    else
+        return NULL;
  }
                                 
 axis2_status_t AXIS2_CALL
@@ -311,32 +323,27 @@
     axis2_om_node_t *current_node =  NULL;
     int status = AXIS2_SUCCESS;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    if(!builder)
+        return AXIS2_FAILURE;
     builder_impl = AXIS2_INTF_TO_IMPL(builder);
     if(builder_impl->done)
     {
         return AXIS2_FAILURE;   
     }
-    
-    lastnode = AXIS2_OM_STAX_BUILDER_GET_LAST_NODE(builder_impl->om_builder, env);
+    if(!(builder_impl->om_builder))
+        return AXIS2_FAILURE;
+   
+    lastnode = axis2_om_stax_builder_get_lastnode(builder_impl->om_builder, env);
     
     if(!lastnode)
     {
         builder_impl->last_node_status = AXIS2_BUILDER_LAST_NODE_NULL;
-    }/*else if(AXIS2_OM_NODE_GET_BUILD_STATUS(lastnode, env))
-    {
-        builder_impl->last_node_status = AXIS2_BUILDER_LAST_NODE_DONE_TRUE;
-    }*/
+    }
     else
     {
-        builder_impl->last_node_status = AXIS2_BUILDER_LAST_NODE_DONE_FALSE;
+        builder_impl->last_node_status = AXIS2_BUILDER_LAST_NODE_NOT_NULL;
     }
-    /*
-    current_node = AXIS2_OM_STAX_BUILDER_NEXT(builder_impl->om_builder, env);
-    */
     current_event = AXIS2_OM_STAX_BUILDER_NEXT_WITH_TOKEN(builder_impl->om_builder, env);
-    /*
-    current_event = AXIS2_OM_STAX_BUILDER_GET_CURRENT_EVENT(builder_impl->om_builder, env);
-    */
     if(current_event == -1)
     {
         builder_impl->done = AXIS2_TRUE;
@@ -345,9 +352,11 @@
     if(current_event == AXIS2_XML_READER_EMPTY_ELEMENT ||
         current_event ==  AXIS2_XML_READER_START_ELEMENT)
     {
-      current_node = AXIS2_OM_STAX_BUILDER_GET_LAST_NODE(builder_impl->om_builder, env);
-    
-      status = axis2_soap_builder_create_om_element(builder, env, current_node);
+      current_node = axis2_om_stax_builder_get_lastnode(builder_impl->om_builder, env);
+      if(current_node) 
+          status = axis2_soap_builder_create_om_element(builder, env, current_node);
+      else
+        return AXIS2_FAILURE;
     }
    
     return status;
@@ -361,7 +370,12 @@
     axis2_soap_builder_impl_t *builder_impl = NULL;
     AXIS2_ENV_CHECK(env, NULL);
     builder_impl = AXIS2_INTF_TO_IMPL(builder);
-    return AXIS2_SOAP_ENVELOPE_GET_BASE_NODE(builder_impl->soap_envelope, env);
+    if(builder_impl->soap_envelope)
+    {
+        return AXIS2_SOAP_ENVELOPE_GET_BASE_NODE(builder_impl->soap_envelope, env);
+    }
+    else
+        return NULL;
 } 
                                        
                                                           
@@ -376,22 +390,24 @@
     int ret_val = AXIS2_SUCCESS;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK((*env)->error, current_node, AXIS2_FAILURE);
+    if(!builder)
+        return AXIS2_FAILURE;
+        
     builder_impl = AXIS2_INTF_TO_IMPL(builder);
     if(builder_impl->last_node_status == AXIS2_BUILDER_LAST_NODE_NULL)
     {
-       
        ret_val =  axis2_soap_builder_construct_node(builder, env, NULL, current_node, AXIS2_TRUE);
-         
-    }/*else if(builder_impl->last_node_status == AXIS2_BUILDER_LAST_NODE_DONE_TRUE)
-    {
-      ret_val =  axis2_soap_builder_construct_node(builder, env, 
-            AXIS2_OM_NODE_GET_PARENT(current_node, env), current_node, AXIS2_FALSE);
-    
-    }*/
+    }
     else
     {
-       ret_val = axis2_soap_builder_construct_node(builder, env, 
-            AXIS2_OM_NODE_GET_PARENT(current_node, env), current_node, AXIS2_FALSE);
+       axis2_om_node_t *parent_node = NULL;
+       parent_node = AXIS2_OM_NODE_GET_PARENT(current_node, env);
+       if(parent_node)
+       {
+           ret_val = axis2_soap_builder_construct_node(builder, env, parent_node , current_node, AXIS2_FALSE);
+       }
+       else
+            return AXIS2_FAILURE;
     }
     return ret_val;
 }   
@@ -416,40 +432,51 @@
     
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK((*env)->error, om_element_node, AXIS2_FAILURE);
-    
+    if(!builder)
+        return AXIS2_FAILURE;
+   
     builder_impl = AXIS2_INTF_TO_IMPL(builder);
-    
-    
-    element_level = AXIS2_OM_STAX_BUILDER_GET_ELEMENT_LEVEL(
+    if(!builder_impl->om_builder)
+        return AXIS2_FAILURE;
+    /** get element level of this om element */
+    element_level = axis2_om_stax_builder_get_element_level(
                         builder_impl->om_builder, env);
-    
+    /* get om element struct from node */
     om_element = (axis2_om_element_t *)
                 AXIS2_OM_NODE_GET_DATA_ELEMENT(om_element_node, env);
-     
+    if(!om_element)
+        return AXIS2_FAILURE;
+    /* get element localname */    
     ele_localname = AXIS2_OM_ELEMENT_GET_LOCALNAME(om_element, env);
-    
+    if(!ele_localname)
+        return AXIS2_FAILURE;
     
     if(parent)
     {
+        /** a parent node exist , so not soap envelope element */
         parent_ele = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(parent, env);
-        parent_localname = AXIS2_OM_ELEMENT_GET_LOCALNAME(parent_ele, env);
+        if(parent_ele)
+            parent_localname = AXIS2_OM_ELEMENT_GET_LOCALNAME(parent_ele, env);
     }
     if(!parent && is_soap_envelope)
     {   
-        
+        /** this is the soap envelope element */
         if(AXIS2_STRCASECMP(ele_localname, AXIS2_SOAP_ENVELOPE_LOCAL_NAME) != 0)
         {
             AXIS2_ERROR_SET((*env)->error, 
                 AXIS2_ERROR_SOAP_MESSAGE_FIRST_ELEMENT_MUST_CONTAIN_LOCAL_NAME, AXIS2_FAILURE);
             return AXIS2_FAILURE;   
         }
+        
+        /** create a null soap envelope struct */
         builder_impl->soap_envelope = axis2_soap_envelope_create_null(env);
-       
+        if(!builder_impl->soap_envelope)
+            return AXIS2_FAILURE;
+        /** wrap this om node in it */
         status = AXIS2_SOAP_ENVELOPE_SET_BASE_NODE(builder_impl->soap_envelope, 
                     env, om_element_node);
         
         AXIS2_SOAP_ENVELOPE_SET_BUILDER(builder_impl->soap_envelope, env, builder);
-        
         status = axis2_soap_builder_process_namespace_data(builder, env, om_element_node, AXIS2_TRUE);
         if(status == AXIS2_FAILURE)
             return AXIS2_FAILURE;
@@ -457,7 +484,8 @@
     else if(element_level == 2)
     {
         if(AXIS2_STRCMP(ele_localname, AXIS2_SOAP_HEADER_LOCAL_NAME) == 0)
-        {   
+        {  
+            /** this is the soap header element */
             axis2_soap_header_t *soap_header = NULL;
             if(builder_impl->header_present)
             {
@@ -471,12 +499,21 @@
                     AXIS2_ERROR_SOAP_BUILDER_HEADER_BODY_WRONG_ORDER, AXIS2_FAILURE);
                 return  AXIS2_FAILURE;                                              
             }
+            
             builder_impl->header_present = AXIS2_TRUE;
+            
             soap_header = axis2_soap_header_create(env);
+            if(!soap_header)
+                return AXIS2_FAILURE;
+                
             AXIS2_SOAP_HEADER_SET_BASE_NODE(soap_header, env, om_element_node);
 
             AXIS2_SOAP_ENVELOPE_SET_HEADER(builder_impl->soap_envelope, env, soap_header);
+            
             AXIS2_SOAP_HEADER_SET_BUILDER(soap_header, env, builder);
+           
+            AXIS2_SOAP_HEADER_SET_SOAP_VERSION(soap_header, env, builder_impl->soap_version);
+           
             status = axis2_soap_builder_process_namespace_data(builder, env, 
                                 om_element_node, AXIS2_TRUE);
             if(status == AXIS2_FAILURE)
@@ -495,12 +532,20 @@
             
             }
             builder_impl->body_present = AXIS2_TRUE;                
+            
             soap_body = axis2_soap_body_create(env);
+            if(!soap_body)
+                return AXIS2_FAILURE;
+                
             AXIS2_SOAP_BODY_SET_BASE_NODE(soap_body, env, om_element_node);
+            
             AXIS2_SOAP_BODY_SET_BUILDER(soap_body, env, builder);
+            
             AXIS2_SOAP_ENVELOPE_SET_BODY(builder_impl->soap_envelope, env, soap_body);
+            
             status = axis2_soap_builder_process_namespace_data(builder, env, 
                         om_element_node, AXIS2_TRUE);
+            
             if(status == AXIS2_FAILURE)
                 return AXIS2_FAILURE;
         }
@@ -511,57 +556,69 @@
             return AXIS2_FAILURE;                                            
         }
     }
-    else if((element_level == 3) && AXIS2_STRCASECMP(parent_localname, 
-            AXIS2_SOAP_HEADER_LOCAL_NAME) == 0)
+    else if((element_level == 3) &&  parent_localname &&  
+                AXIS2_STRCASECMP(parent_localname, AXIS2_SOAP_HEADER_LOCAL_NAME) == 0)
     {
             axis2_soap_header_block_t *header_block = NULL;
             axis2_soap_header_t *soap_header = NULL;
+            
+            soap_header = AXIS2_SOAP_ENVELOPE_GET_HEADER(builder_impl->soap_envelope, env);
+            if(!soap_header)
+                return AXIS2_FAILURE;
+                
             header_block = axis2_soap_header_block_create(env);
+            if(!header_block)
+                return AXIS2_FAILURE;
+                
             AXIS2_SOAP_HEADER_BLOCK_SET_BASE_NODE(header_block, env, om_element_node);
            
-            soap_header = AXIS2_SOAP_ENVELOPE_GET_HEADER(builder_impl->soap_envelope, env);
             AXIS2_SOAP_HEADER_SET_HEADER_BLOCK(soap_header, env, header_block);
 
+            AXIS2_SOAP_HEADER_BLOCK_SET_SOAP_VERSION(header_block, env, builder_impl->soap_version);
+            
+
     }
-    else if((element_level == 3) && 
+    else if((element_level == 3) && parent_localname &&
             AXIS2_STRCASECMP(parent_localname, AXIS2_SOAP_BODY_LOCAL_NAME) == 0 &&
                 AXIS2_STRCASECMP(ele_localname, AXIS2_SOAP_BODY_FAULT_LOCAL_NAME) == 0)
     {
             axis2_soap_body_t *soap_body = NULL;
             axis2_soap_fault_t *soap_fault = NULL;
-            axis2_om_node_t *envelope_node = NULL;
-            axis2_om_element_t *envelope_ele = NULL;
             axis2_om_namespace_t *env_ns = NULL;
-            envelope_node = AXIS2_SOAP_ENVELOPE_GET_BASE_NODE(
-                builder_impl->soap_envelope, env);
-            envelope_ele = (axis2_om_element_t *)
-                AXIS2_OM_NODE_GET_DATA_ELEMENT(envelope_node, env);
-            env_ns = AXIS2_OM_ELEMENT_GET_NAMESPACE(envelope_ele, env);
-                       
+            
+            env_ns = AXIS2_SOAP_ENVELOPE_GET_NAMESPACE(builder_impl->soap_envelope, env);
+            if(!env_ns)
+                return AXIS2_FAILURE;
+           
             soap_body = AXIS2_SOAP_ENVELOPE_GET_BODY(builder_impl->soap_envelope, env);
+            
             if(!soap_body )
                 return AXIS2_FAILURE;
+            
             soap_fault = axis2_soap_fault_create(env);
             if(!soap_fault) 
                 return AXIS2_FAILURE;
-            AXIS2_SOAP_FAULT_SET_BASE_NODE(soap_fault, env, om_element_node);
             
-            AXIS2_SOAP_FAULT_SET_SOAP_VERSION(soap_fault, env, builder_impl->soap_version);
+            AXIS2_SOAP_FAULT_SET_BASE_NODE(soap_fault, env, om_element_node);
             
             AXIS2_SOAP_BODY_SET_FAULT(soap_body, env, soap_fault);                    
                                 
             builder_impl->processing_fault = AXIS2_TRUE;
+            
             builder_impl->processing_mandatory_fault_elements = AXIS2_TRUE; 
+            
             if(AXIS2_STRCMP(AXIS2_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI, 
                 AXIS2_OM_NAMESPACE_GET_URI(env_ns , env)) == 0)
             {
-                builder_impl->builder_helper = axis2_soap12_builder_helper_create(env, builder); 
-             
+                builder_impl->builder_helper = axis2_soap12_builder_helper_create(env, builder);
+                if(!(builder_impl->builder_helper))
+                    return AXIS2_FAILURE;
             }
             else if(AXIS2_STRCMP(AXIS2_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI, 
                 AXIS2_OM_NAMESPACE_GET_URI(env_ns , env)) == 0)
             {   
-                builder_impl->builder_helper = axis2_soap11_builder_helper_create(env, builder, builder_impl->om_builder);            
+                builder_impl->builder_helper = axis2_soap11_builder_helper_create(env, builder, builder_impl->om_builder);                 if(!(builder_impl->builder_helper))
+                    return AXIS2_FAILURE;
             }
              
     }
@@ -569,14 +626,16 @@
     {
         if(builder_impl->soap_version == AXIS2_SOAP11)
         {   
-             status = AXIS2_SOAP11_BUILDER_HELPER_HANDLE_EVENT(((axis2_soap11_builder_helper_t*)(builder_impl->builder_helper)), 
+            status = AXIS2_SOAP11_BUILDER_HELPER_HANDLE_EVENT(
+                ((axis2_soap11_builder_helper_t*)(builder_impl->builder_helper)),
                 env,  om_element_node , element_level);
         
         }
-        if(builder_impl->soap_version == AXIS2_SOAP12)
+        else if(builder_impl->soap_version == AXIS2_SOAP12)
         {
-            status = AXIS2_SOAP12_BUILDER_HELPER_HANDLE_EVENT(((axis2_soap12_builder_helper_t *)
-            (builder_impl->builder_helper)), env,  om_element_node , element_level);
+            status = AXIS2_SOAP12_BUILDER_HELPER_HANDLE_EVENT(
+                ((axis2_soap12_builder_helper_t *)(builder_impl->builder_helper)), 
+                env,  om_element_node , element_level);
         }
         
     }
@@ -595,8 +654,10 @@
     axis2_char_t *ns_uri = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK((*env)->error, om_node, AXIS2_FAILURE);
+
     if(!is_soap_element)
         return AXIS2_SUCCESS;
+    
     if(AXIS2_OM_NODE_GET_NODE_TYPE(om_node, env) == AXIS2_OM_ELEMENT)
     {
         om_ele = (axis2_om_element_t *) AXIS2_OM_NODE_GET_DATA_ELEMENT(om_node, env);
@@ -604,15 +665,18 @@
         {
             om_ns = AXIS2_OM_ELEMENT_GET_NAMESPACE(om_ele, env);
             if(om_ns)
+            {
                 ns_uri = AXIS2_OM_NAMESPACE_GET_URI(om_ns, env);
-        }
-        if(ns_uri && 
-                (AXIS2_STRCMP(ns_uri, AXIS2_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI) != 0) &&
-                (AXIS2_STRCMP(ns_uri, AXIS2_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI) != 0))
-        {
-            AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_INVALID_SOAP_NAMESPACE_URI, AXIS2_FAILURE);                
-            AXIS2_LOG_DEBUG((*env)->log, AXIS2_LOG_SI, "AXIS2_ERROR_INVALID_SOAP_NAMESPACE_URI");
-            return AXIS2_FAILURE;
+                if(ns_uri && 
+                    (AXIS2_STRCMP(ns_uri, AXIS2_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI) != 0) &&
+                    (AXIS2_STRCMP(ns_uri, AXIS2_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI) != 0))
+                {
+                    AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_INVALID_SOAP_NAMESPACE_URI, AXIS2_FAILURE);                
+                    AXIS2_LOG_DEBUG((*env)->log, AXIS2_LOG_SI, "AXIS2_ERROR_INVALID_SOAP_NAMESPACE_URI");
+                    return AXIS2_FAILURE;
+                }
+                
+            }
         }
     }        
     return AXIS2_SUCCESS;
@@ -628,12 +692,14 @@
     axis2_om_node_t *envelope_node = NULL;
     axis2_om_element_t *om_ele = NULL;
     axis2_char_t *ns_uri = NULL;
-    AXIS2_PARAM_CHECK((*env)->error, soap_version_uri_from_transport, AXIS2_FAILURE);    
     
+    AXIS2_PARAM_CHECK((*env)->error, soap_version_uri_from_transport, AXIS2_FAILURE);    
+    if(!builder)
+        return AXIS2_FAILURE;
     
     builder_impl = AXIS2_INTF_TO_IMPL(builder);
-    builder_impl->soap_envelope = 
-        axis2_soap_builder_get_soap_envelope(builder, env);
+    
+    builder_impl->soap_envelope = axis2_soap_builder_get_soap_envelope(builder, env);
     if(builder_impl->soap_envelope == NULL)
     {
         AXIS2_ERROR_SET((*env)->error, 
@@ -641,34 +707,54 @@
         AXIS2_LOG_CRITICAL((*env)->log, AXIS2_LOG_SI, "SOAP message does not have a SOAP envelope element ");        
         return AXIS2_FAILURE;
     }
+    
     envelope_node = AXIS2_SOAP_ENVELOPE_GET_BASE_NODE(builder_impl->soap_envelope, env);
+    if(!envelope_node)
+        return AXIS2_FAILURE;
+        
     om_ele = (axis2_om_element_t *) AXIS2_OM_NODE_GET_DATA_ELEMENT(envelope_node, env);
-    
+    if(!om_ele)
+        return AXIS2_FAILURE;
+        
     om_ns = AXIS2_OM_ELEMENT_GET_NAMESPACE(om_ele, env);
-    
+    if(!om_ns)
+        return AXIS2_FAILURE;
+        
     ns_uri = AXIS2_OM_NAMESPACE_GET_URI(om_ns, env);
+    
     if(ns_uri != NULL)
     {        
        if(soap_version_uri_from_transport && AXIS2_STRCMP(soap_version_uri_from_transport, ns_uri) != 0)
         {
-            AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_TRANSPORT_LEVEL_INFORMATION_DOES_NOT_MATCH_WITH_SOAP, AXIS2_FAILURE);
-            AXIS2_LOG_ERROR((*env)->log , AXIS2_LOG_SI, "AXIS2_ERROR_TRANSPORT_LEVEL_INFORMATION_DOES_NOT_MATCH_WITH_SOAP");            
+            AXIS2_ERROR_SET((*env)->error, 
+                AXIS2_ERROR_TRANSPORT_LEVEL_INFORMATION_DOES_NOT_MATCH_WITH_SOAP, AXIS2_FAILURE);
+            
+            AXIS2_LOG_ERROR((*env)->log , AXIS2_LOG_SI, 
+                "AXIS2_ERROR_TRANSPORT_LEVEL_INFORMATION_DOES_NOT_MATCH_WITH_SOAP");            
             return AXIS2_FAILURE;
         }            
         if(AXIS2_STRCMP(AXIS2_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI, ns_uri) == 0)
         {
             builder_impl->soap_version = AXIS2_SOAP11;        
+      
             AXIS2_LOG_DEBUG((*env)->log, AXIS2_LOG_SI, "Identified soap version is soap11");
+
+            AXIS2_SOAP_ENVELOPE_SET_SOAP_VERSION(builder_impl->soap_envelope, 
+                env, builder_impl->soap_version);        
+
+            return AXIS2_SUCCESS;
         }
         else if(AXIS2_STRCMP(AXIS2_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI, ns_uri) == 0)
         {
             builder_impl->soap_version = AXIS2_SOAP12;          
+        
             AXIS2_LOG_DEBUG((*env)->log, AXIS2_LOG_SI, "identified soap version is soap12");
             
+            AXIS2_SOAP_ENVELOPE_SET_SOAP_VERSION(builder_impl->soap_envelope, 
+                env, builder_impl->soap_version);        
+
+            return AXIS2_SUCCESS;                
         }
-        AXIS2_SOAP_ENVELOPE_SET_SOAP_VERSION(builder_impl->soap_envelope, env, builder_impl->soap_version);        
-       
-        return AXIS2_SUCCESS;
     }
     return AXIS2_FAILURE;
 } 
@@ -681,17 +767,29 @@
     axis2_om_node_t *om_node = NULL;
     axis2_soap_header_t *soap_header = NULL;
     int status = AXIS2_SUCCESS;
+    if(!builder)
+    {
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_INVALID_NULL_PARAM, AXIS2_FAILURE);
+        return AXIS2_FAILURE;
+    }
     builder_impl = AXIS2_INTF_TO_IMPL(builder);
+    
+    if(!builder_impl->soap_envelope)
+        return AXIS2_FAILURE;
+        
     soap_header = AXIS2_SOAP_ENVELOPE_GET_HEADER(builder_impl->soap_envelope, env);
+    
     if(soap_header != NULL)
     {
         om_node = AXIS2_SOAP_HEADER_GET_BASE_NODE(soap_header, env);
-        while(!AXIS2_OM_NODE_GET_BUILD_STATUS(om_node, env))
-        {
-            status = axis2_soap_builder_next(builder, env);
-            if(status == AXIS2_FAILURE)
-                return AXIS2_FAILURE;
-        }
+        if(om_node)
+        {        while(!AXIS2_OM_NODE_GET_BUILD_STATUS(om_node, env))
+                {
+                    status = axis2_soap_builder_next(builder, env);
+                    if(status == AXIS2_FAILURE)
+                        return AXIS2_FAILURE;
+                }
+        }                
     }
     return AXIS2_SUCCESS;
 } 

Modified: webservices/axis2/trunk/c/modules/xml/soap/soap_envelope.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/soap/soap_envelope.c?rev=385453&r1=385452&r2=385453&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/soap/soap_envelope.c (original)
+++ webservices/axis2/trunk/c/modules/xml/soap/soap_envelope.c Mon Mar 13 00:11:01 2006
@@ -25,7 +25,7 @@
  #include <axis2_soap_fault_reason.h>
  #include <axis2_soap_fault_detail.h>
  #include <axis2_soap_fault_role.h>
- 
+ #include <axis2_soap_fault_value.h> 
  /******************* impl struct *********************************************/
  
  typedef struct axis2_soap_envelope_impl_t
@@ -51,7 +51,7 @@
  /****************** Function prototypes **************************************/
 
 axis2_soap_header_t* AXIS2_CALL
- axis2_soap_envelope_get_header(axis2_soap_envelope_t *envelope,
+axis2_soap_envelope_get_header(axis2_soap_envelope_t *envelope,
                                 axis2_env_t **env);
                                 
                                 
@@ -111,7 +111,11 @@
                                 axis2_env_t **env,
                                 axis2_soap_builder_t *soap_builder);                                  
 
-                                   
+static axis2_status_t
+check_and_set_soap_version(axis2_soap_envelope_t *env_impl, 
+                           axis2_env_t **env, 
+                           axis2_om_namespace_t *ns);
+
 /*************** function implementations *************************************/
 
 AXIS2_DECLARE(axis2_soap_envelope_t*)
@@ -181,8 +185,10 @@
 {
     axis2_soap_envelope_impl_t *envelope_impl = NULL;
     axis2_om_element_t *ele = NULL;
-    
+    int status = AXIS2_SUCCESS;
     AXIS2_ENV_CHECK(env, NULL);
+    AXIS2_PARAM_CHECK((*env)->error, ns, NULL);
+    
     envelope_impl = (axis2_soap_envelope_impl_t*)AXIS2_MALLOC(
                     (*env)->allocator,
                     sizeof(axis2_soap_envelope_impl_t));
@@ -198,6 +204,13 @@
     envelope_impl->body = NULL;
     envelope_impl->soap_builder =  NULL;
     
+    status =  check_and_set_soap_version(&(envelope_impl->soap_envelope), env, ns);
+    if(status == AXIS2_FAILURE)
+    {
+        AXIS2_FREE((*env)->allocator, envelope_impl); 
+        return NULL; 
+    }
+ 
     ele = axis2_om_element_create(env, NULL, 
                                   AXIS2_SOAP_ENVELOPE_LOCAL_NAME, ns, 
                                   &(envelope_impl->om_ele_node));
@@ -395,7 +408,9 @@
     envelope_impl = AXIS2_INTF_TO_IMPL(envelope);
     
     /* TODO : cache SOAP header and envelope instead of looking them up?*/
-
+    if(!envelope_impl->header)
+        return NULL;
+    
     if (namespace_uri)
     {
         ns = axis2_om_namespace_create(env, namespace_uri, NULL);
@@ -439,6 +454,9 @@
 {
     axis2_soap_envelope_impl_t *envelope_impl = NULL;
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, envelope, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, om_output, AXIS2_FAILURE);
+    
     envelope_impl = AXIS2_INTF_TO_IMPL(envelope);
 /*
    if soap version is soap11 we modify the soap fault part.
@@ -469,42 +487,86 @@
                         axis2_om_element_t *fault_code_om_ele = NULL;
                         axis2_om_node_t *fault_value_om_node = NULL;
                         axis2_om_element_t *fault_value_om_ele = NULL;
+                        axis2_soap_fault_value_t *fault_value = NULL;
                         axis2_char_t *text = NULL;
+
                         fault_code_om_node = AXIS2_SOAP_FAULT_CODE_GET_BASE_NODE(fault_code, env);
-                        fault_code_om_ele = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(fault_code_om_node, env);
-                        AXIS2_OM_ELEMENT_SET_LOCALNAME(fault_code_om_ele, env, AXIS2_SOAP11_SOAP_FAULT_CODE_LOCAL_NAME); 
-                        fault_value_om_node = AXIS2_OM_NODE_GET_FIRST_CHILD(fault_code_om_node, env);
-                        AXIS2_OM_NODE_DETACH(fault_value_om_node, env);
-                        fault_value_om_ele = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(fault_value_om_node, env);
-                        text = AXIS2_OM_ELEMENT_GET_TEXT(fault_value_om_ele, env, fault_value_om_node);
-                        AXIS2_OM_ELEMENT_SET_TEXT(fault_code_om_ele, env, text, fault_code_om_node);
-                        AXIS2_FREE((*env)->allocator, text);
-                        AXIS2_OM_NODE_FREE_TREE(fault_value_om_node, env);                                                                                              
+                        if(fault_code_om_node)
+                        {
+                           fault_code_om_ele = (axis2_om_element_t *)
+                           AXIS2_OM_NODE_GET_DATA_ELEMENT(fault_code_om_node, env);
+                           if(fault_code_om_ele)
+                           {                               
+                                AXIS2_OM_ELEMENT_SET_LOCALNAME(fault_code_om_ele, 
+                                    env, AXIS2_SOAP11_SOAP_FAULT_CODE_LOCAL_NAME); 
+                                
+                                fault_value = AXIS2_SOAP_FAULT_VALUE_GET_BASE_NODE(fault_code, env);
+                                if(fault_value)
+                               {
+                                fault_value_om_node = AXIS2_OM_NODE_GET_FIRST_CHILD(fault_code_om_node, env);
+                                if(fault_value_om_node)
+                                {
+                                   fault_value_om_node =  AXIS2_OM_NODE_DETACH(fault_value_om_node, env);
+                                    fault_value_om_ele = (axis2_om_element_t *)
+                                        AXIS2_OM_NODE_GET_DATA_ELEMENT(fault_value_om_node, env);
+                                    if(fault_value_om_ele)
+                                    {
+                                        text = AXIS2_OM_ELEMENT_GET_TEXT(fault_value_om_ele, env, fault_value_om_node);
+                                        if(NULL != text)
+                                        {
+                                            AXIS2_OM_ELEMENT_SET_TEXT(fault_code_om_ele, env, text, fault_code_om_node);
+                                            AXIS2_FREE((*env)->allocator, text);
+                                        }
+                                    }
+                                }
+                               }
+                            }
+                        }                            
                     }
                     fault_reason = AXIS2_SOAP_FAULT_GET_REASON(soap_fault, env);
                     if(fault_reason)
                     {
                         axis2_om_node_t *fault_reason_om_node = NULL;
                         axis2_om_element_t *fault_reason_om_ele = NULL;
-                        
                         axis2_om_node_t *fault_text_om_node = NULL;
                         axis2_om_element_t *fault_text_om_ele = NULL;
 
                         axis2_char_t *text =  NULL;                        
                     
                         fault_reason_om_node = AXIS2_SOAP_FAULT_REASON_GET_BASE_NODE(fault_reason, env);
-                        fault_reason_om_ele  = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(fault_reason_om_node, env);
-                        AXIS2_OM_ELEMENT_SET_LOCALNAME(fault_reason_om_ele, env, AXIS2_SOAP11_SOAP_FAULT_STRING_LOCAL_NAME);
+                        if(fault_reason_om_node)
+                        {
+                            fault_reason_om_ele  = (axis2_om_element_t *)
+                                AXIS2_OM_NODE_GET_DATA_ELEMENT(fault_reason_om_node, env);
                         
+                            if(fault_reason_om_ele)
+                            {
+                                AXIS2_OM_ELEMENT_SET_LOCALNAME(fault_reason_om_ele, 
+                                    env, AXIS2_SOAP11_SOAP_FAULT_STRING_LOCAL_NAME);
                         
-                        fault_text_om_node = AXIS2_OM_NODE_GET_FIRST_CHILD(fault_reason_om_node, env);
-                        fault_text_om_ele  = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(fault_text_om_node, env);
-                        AXIS2_OM_NODE_DETACH(fault_text_om_node, env);                        
+                                
+                                fault_text_om_node =  AXIS2_OM_NODE_GET_FIRST_CHILD(fault_reason_om_node, env);
+                                if(fault_text_om_node)
+                                {
+                                    
+                                     fault_text_om_node = AXIS2_OM_NODE_DETACH(fault_text_om_node, env);                        
+                                    fault_text_om_ele  = (axis2_om_element_t *)
+                                        AXIS2_OM_NODE_GET_DATA_ELEMENT(fault_text_om_node, env);
+                                    if(fault_text_om_ele)
+                                    {
                         
-                        text = AXIS2_OM_ELEMENT_GET_TEXT(fault_text_om_ele, env, fault_text_om_node);
-                        AXIS2_OM_ELEMENT_SET_TEXT( fault_reason_om_ele, env, text, fault_reason_om_node);   
-                        AXIS2_FREE((*env)->allocator, text); 
-                        AXIS2_OM_NODE_FREE_TREE(fault_text_om_node, env);
+                                        text = AXIS2_OM_ELEMENT_GET_TEXT(fault_text_om_ele, env, fault_text_om_node);
+                                        if(NULL != text)
+                                        {
+                                            AXIS2_OM_ELEMENT_SET_TEXT( fault_reason_om_ele, 
+                                                env, text, fault_reason_om_node);   
+                                
+                                            AXIS2_FREE((*env)->allocator, text); 
+                                        }                        
+                                    }
+                                }
+                            }
+                        }
                     }
                    
                     fault_role = AXIS2_SOAP_FAULT_GET_ROLE(soap_fault, env);
@@ -514,8 +576,16 @@
                         axis2_om_element_t *fault_role_om_ele = NULL;
                         
                         fault_role_om_node = AXIS2_SOAP_FAULT_ROLE_GET_BASE_NODE(fault_role, env);
-                        fault_role_om_ele = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(fault_role_om_node, env);
-                        AXIS2_OM_ELEMENT_SET_LOCALNAME(fault_role_om_ele, env, AXIS2_SOAP11_SOAP_FAULT_ACTOR_LOCAL_NAME);
+                        if(fault_role_om_node)
+                        {
+                            fault_role_om_ele = (axis2_om_element_t *)
+                                AXIS2_OM_NODE_GET_DATA_ELEMENT(fault_role_om_node, env);
+                            if(fault_role_om_ele)
+                            {
+                                AXIS2_OM_ELEMENT_SET_LOCALNAME(fault_role_om_ele, env, 
+                                    AXIS2_SOAP11_SOAP_FAULT_ACTOR_LOCAL_NAME);
+                            }                                
+                        }
                     }
                 
                     fault_detail = AXIS2_SOAP_FAULT_GET_DETAIL(soap_fault, env);
@@ -523,10 +593,17 @@
                     {
                         axis2_om_node_t *fault_detail_om_node = NULL;
                         axis2_om_element_t *fault_detail_om_ele = NULL;
-                        
                         fault_detail_om_node = AXIS2_SOAP_FAULT_DETAIL_GET_BASE_NODE(fault_detail, env);
-                        fault_detail_om_ele = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(fault_detail_om_node, env);
-                        AXIS2_OM_ELEMENT_SET_LOCALNAME(fault_detail_om_ele, env, AXIS2_SOAP11_SOAP_FAULT_DETAIL_LOCAL_NAME);
+                        if(fault_detail_om_node)
+                        {
+                            fault_detail_om_ele = (axis2_om_element_t *)
+                                AXIS2_OM_NODE_GET_DATA_ELEMENT(fault_detail_om_node, env);
+                            if(fault_detail_om_ele)
+                            {
+                            AXIS2_OM_ELEMENT_SET_LOCALNAME(fault_detail_om_ele, 
+                                env, AXIS2_SOAP11_SOAP_FAULT_DETAIL_LOCAL_NAME);
+                            }
+                        }
                     }
                 }  
             }
@@ -555,7 +632,8 @@
     }
     else
     {
-        AXIS2_LOG_ERROR((*env)->log, AXIS2_LOG_SI, "trying to set a soap bedy to envelope when a soap body alrady exists");
+        AXIS2_LOG_ERROR((*env)->log, AXIS2_LOG_SI, 
+            "trying to set a soap bedy to envelope when a soap body alrady exists");
         return AXIS2_FAILURE;
     }
     return AXIS2_SUCCESS;
@@ -574,7 +652,8 @@
     }
     else
     {
-       AXIS2_LOG_ERROR((*env)->log, AXIS2_LOG_SI, " trying to set a soap header to envelope when a soap header alrady exists");
+       AXIS2_LOG_ERROR((*env)->log, AXIS2_LOG_SI, 
+        " trying to set a soap header to envelope when a soap header alrady exists");
         return AXIS2_FAILURE;
     }
     return AXIS2_SUCCESS;
@@ -706,3 +785,39 @@
     AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_INVALID_SOAP_VERSION, AXIS2_FAILURE);
     return NULL;    
 }
+
+static axis2_status_t
+check_and_set_soap_version(axis2_soap_envelope_t *envelope,
+                           axis2_env_t **env,
+                           axis2_om_namespace_t *ns)
+{
+    axis2_soap_envelope_impl_t *envelope_impl = NULL;
+    axis2_char_t *uri = NULL;
+    if(!envelope)
+        return AXIS2_FAILURE;
+    if(!ns)
+        return AXIS2_FAILURE;
+         
+    envelope_impl = AXIS2_INTF_TO_IMPL(envelope);
+    
+    uri = AXIS2_OM_NAMESPACE_GET_URI(ns, env);
+    if(!uri)
+        return AXIS2_FAILURE;
+        
+    if(AXIS2_STRCMP(uri, AXIS2_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI) == 0)
+    {
+        envelope_impl->soap_version = AXIS2_SOAP11;
+        return AXIS2_SUCCESS;
+    }
+    else if(AXIS2_STRCMP(uri, AXIS2_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI) == 0)
+    {
+        envelope_impl->soap_version = AXIS2_SOAP12;
+        return AXIS2_SUCCESS;
+    }
+    else
+    {
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_INVALID_SOAP_NAMESPACE_URI, AXIS2_FAILURE);
+    }
+    return AXIS2_FAILURE;
+}                           
+

Modified: webservices/axis2/trunk/c/modules/xml/soap/soap_fault.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/soap/soap_fault.c?rev=385453&r1=385452&r2=385453&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/soap/soap_fault.c (original)
+++ webservices/axis2/trunk/c/modules/xml/soap/soap_fault.c Mon Mar 13 00:11:01 2006
@@ -48,8 +48,6 @@
     axis2_soap_fault_detail_t *fdetail;
     
     axis2_char_t *exception;
-    /* soap version */
-    int soap_version;
     /* reference to soap builder */
     axis2_soap_builder_t *soap_builder;
     
@@ -120,14 +118,6 @@
 axis2_soap_fault_get_base_node(axis2_soap_fault_t *fault,
                                axis2_env_t **env);  
                                                 
-axis2_status_t AXIS2_CALL 
-axis2_soap_fault_set_soap_version(axis2_soap_fault_t *fault,
-                                  axis2_env_t **env,
-                                  int soap_version);
-                                    
-int AXIS2_CALL 
-axis2_soap_fault_get_soap_version(axis2_soap_fault_t *fault,
-                                  axis2_env_t **env);    
                                   
 axis2_char_t * AXIS2_CALL 
 axis2_soap_fault_get_exception(axis2_soap_fault_t *fault,
@@ -166,8 +156,7 @@
     fault_impl->frole = NULL;
     fault_impl->om_ele_node = NULL;
     fault_impl->soap_fault.ops = NULL;
-    fault_impl->soap_version = AXIS2_SOAP_VERSION_NOT_SET;
-
+    fault_impl->soap_builder = NULL;
     fault_impl->soap_fault.ops = (axis2_soap_fault_ops_t*)AXIS2_MALLOC(
                                  (*env)->allocator,
                                  sizeof(axis2_soap_fault_ops_t));
@@ -179,10 +168,6 @@
         return NULL;    
     }
 
-    fault_impl->soap_fault.ops->get_soap_version =
-        axis2_soap_fault_get_soap_version;
-    fault_impl->soap_fault.ops->set_soap_version =
-        axis2_soap_fault_set_soap_version;
     fault_impl->soap_fault.ops->free_fn =
         axis2_soap_fault_free;
     fault_impl->soap_fault.ops->get_base_node =
@@ -324,22 +309,16 @@
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK((*env)->error, code, AXIS2_FAILURE);
     fault_impl = AXIS2_INTF_TO_IMPL(fault);
-    /* axis2_soap_fault_get_code(fault_code, env); 
-    if(fault_impl->fcode)
+    if(!(fault_impl->fcode))
     {
-        my_node = AXIS2_SOAP_FAULT_CODE_GET_BASE_NODE(
-                            fault_impl->fcode, env);
-        AXIS2_SOAP_FAULT_CODE_FREE(fault_impl->fcode, env);
-        fault_impl->fcode = NULL;
+        fault_impl->fcode = code;
+        return AXIS2_SUCCESS;
+    }
+    else
+    {
+        AXIS2_LOG_DEBUG((*env)->log,  AXIS2_LOG_SI, "tring to set multiple code elements to fault ");
+       
     }
-    code_node = AXIS2_SOAP_FAULT_CODE_GET_BASE_NODE(
-                            code, env);
-    axis2_soap_utils_set_new_node(env, 
-                    fault_impl->om_ele_node,
-                    &my_node, 
-                    code_node);
-    */                    
-    fault_impl->fcode = code;
     return AXIS2_SUCCESS;  
 }
                                         
@@ -364,21 +343,6 @@
                 break;
         }            
     }
-    /*
-    axis2_om_node_t *code_node = NULL;
-    axis2_om_node_t *this_node = NULL;
-    axis2_soap_fault_code_t* code = NULL;
-    this_node = fault_impl->om_ele_node;
-    if(!(fault_impl->fcode))
-    {
-        code_node = axis2_soap_utils_get_child_with_name(env, 
-                                            this_node, 
-                                            AXIS2_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME);
-        code = axis2_soap_fault_code_create(env);
-        AXIS2_SOAP_FAULT_CODE_SET_BASE_NODE(code , env, code_node);
-        fault_impl->fcode = code;
-    }
-    */
     return fault_impl->fcode; 
 }
                                     
@@ -391,26 +355,16 @@
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK((*env)->error, reason, AXIS2_FAILURE);
     fault_impl = AXIS2_INTF_TO_IMPL(fault);
-   /*
-    axis2_om_node_t *reason_node = NULL;
-    axis2_om_node_t *my_node = NULL;
-    axis2_soap_fault_get_reason(fault_reason, env); 
-    if(fault_impl->freason)
+    if(!(fault_impl->freason))
     {
-        my_node = AXIS2_SOAP_FAULT_REASON_GET_BASE_NODE(
-                            fault_impl->freason, env);
-        AXIS2_SOAP_FAULT_REASON_FREE(fault_impl->freason, env);
-        fault_impl->freason = NULL;
+        fault_impl->freason = reason;
+        return AXIS2_SUCCESS;
     }
-    reason_node = AXIS2_SOAP_FAULT_REASON_GET_BASE_NODE(
-                            reason, env);
-    axis2_soap_utils_set_new_node(env, 
-                    fault_impl->om_ele_node,
-                    &my_node, 
-                    reason_node);
-    */                    
-    fault_impl->freason = reason;
-    return AXIS2_SUCCESS;  
+    else
+    {
+        AXIS2_LOG_DEBUG((*env)->log, AXIS2_LOG_SI, "tring to set fault reason twice");
+    }
+    return AXIS2_FAILURE;  
 }
                                         
 axis2_soap_fault_reason_t* AXIS2_CALL 
@@ -434,21 +388,6 @@
                 break;
         }            
     }
-    /*
-    axis2_om_node_t *reason_node = NULL;
-    axis2_om_node_t *this_node = NULL;
-    axis2_soap_fault_reason_t* reason = NULL;
-    this_node = fault_impl->om_ele_node;
-    if(!(fault_impl->freason))
-    {
-        reason_node = axis2_soap_utils_get_child_with_name(env, 
-                                            this_node, 
-                                            AXIS2_SOAP12_SOAP_FAULT_REASON_LOCAL_NAME);
-        reason = axis2_soap_fault_reason_create(env);
-        AXIS2_SOAP_FAULT_REASON_SET_BASE_NODE(reason , env, reason_node);
-        fault_impl->freason = reason;
-    }
-    */
     return fault_impl->freason; 
 }
                                         
@@ -461,26 +400,16 @@
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK((*env)->error, node, AXIS2_FAILURE);
     fault_impl = AXIS2_INTF_TO_IMPL(fault);
-   /* 
-    axis2_om_node_t *node_node = NULL;
-    axis2_om_node_t *my_node = NULL;
-    axis2_soap_fault_get_node(fault_node, env); 
-    if(fault_impl->fnode)
+    if(!(fault_impl->fnode))
     {
-        my_node = AXIS2_SOAP_FAULT_NODE_GET_BASE_NODE(
-                            fault_impl->fnode, env);
-        AXIS2_SOAP_FAULT_NODE_FREE(fault_impl->fnode, env);
-        fault_impl->fnode = NULL;
+        fault_impl->fnode = node;
+        return AXIS2_SUCCESS;
     }
-    node_node = AXIS2_SOAP_FAULT_NODE_GET_BASE_NODE(
-                            node, env);
-    axis2_soap_utils_set_new_node(env, 
-                    fault_impl->om_ele_node,
-                    &my_node, 
-                    node_node);
-    */                    
-    fault_impl->fnode = node;
-    return AXIS2_SUCCESS;
+    else
+    {
+        AXIS2_LOG_DEBUG((*env)->log, AXIS2_LOG_SI, "tring to set fault node more than once");
+    }
+    return AXIS2_FAILURE;
 }
                                         
 axis2_soap_fault_node_t* AXIS2_CALL 
@@ -505,21 +434,6 @@
                 break;
         }            
     }
-    /*
-    axis2_om_node_t *node_node = NULL;
-    axis2_om_node_t *this_node = NULL;
-    axis2_soap_fault_node_t* node = NULL;
-    this_node = fault_impl->om_ele_node;
-    if(!(fault_impl->fnode))
-    {
-        node_node = axis2_soap_utils_get_child_with_name(env, 
-                                            this_node, 
-                                            AXIS2_SOAP12_SOAP_FAULT_NODE_LOCAL_NAME);
-        node = axis2_soap_fault_node_create(env);
-        AXIS2_SOAP_FAULT_NODE_SET_BASE_NODE(node , env, node_node);
-        fault_impl->fnode = node;
-    }
-    */
     return fault_impl->fnode; 
 }
                                         
@@ -534,26 +448,16 @@
     AXIS2_PARAM_CHECK((*env)->error, role, AXIS2_FAILURE);
     
     fault_impl = AXIS2_INTF_TO_IMPL(fault);
-   /* 
-    axis2_om_node_t *role_node = NULL;
-    axis2_om_node_t *my_node = NULL;
-    axis2_soap_fault_get_role(fault_role, env); 
-    if(fault_impl->frole)
+    if(!(fault_impl->frole))
     {
-        my_node = AXIS2_SOAP_FAULT_ROLE_GET_BASE_NODE(
-                            fault_impl->frole, env);
-        AXIS2_SOAP_FAULT_ROLE_FREE(fault_impl->frole, env);
-        fault_impl->frole = NULL;
+        fault_impl->frole = role;
+        return AXIS2_FAILURE;
     }
-    role_node = AXIS2_SOAP_FAULT_ROLE_GET_BASE_NODE(
-                            role, env);
-    axis2_soap_utils_set_new_node(env, 
-                    fault_impl->om_ele_node,
-                    &my_node, 
-                    role_node);
-    */                    
-    fault_impl->frole = role;
-    return AXIS2_SUCCESS;  
+    else
+    {
+        AXIS2_LOG_DEBUG((*env)->log, AXIS2_LOG_SI, "tring to set fault role more than once ");
+    }
+    return AXIS2_FAILURE;  
 
 }
                                         
@@ -578,22 +482,6 @@
                 break;
         }            
     }
-    /*
-    axis2_om_node_t *role_node = NULL;
-    axis2_om_node_t *this_node = NULL;
-    axis2_soap_fault_role_t* role = NULL;
-    this_node = fault_impl->om_ele_node;
-    if(!(fault_impl->frole))
-    {
-        role_node = axis2_soap_utils_get_child_with_name(env, 
-                                            this_node, 
-                                            AXIS2_SOAP12_SOAP_FAULT_ROLE_LOCAL_NAME);
-                                                    
-        role = axis2_soap_fault_role_create(env);
-        AXIS2_SOAP_FAULT_ROLE_SET_BASE_NODE(role , env, role_node);
-        fault_impl->frole = role;
-    }
-    */
     return fault_impl->frole; 
 }
 
@@ -608,30 +496,17 @@
     AXIS2_PARAM_CHECK((*env)->error, detail, AXIS2_FAILURE);
     
     fault_impl = AXIS2_INTF_TO_IMPL(fault);
-   /* 
-    axis2_om_node_t *detail_node = NULL;
-    axis2_om_node_t *my_node = NULL;
-    axis2_soap_fault_get_detail(fault_detail, env); 
-    if(fault_impl->fdetail)
+    if(!(fault_impl->fdetail))
     {
-        my_node = AXIS2_SOAP_FAULT_DETAIL_GET_BASE_NODE(
-                            fault_impl->fdetail, env);
-        AXIS2_SOAP_FAULT_DETAIL_FREE(fault_impl->fdetail, env);
-        fault_impl->fdetail = NULL;
+        fault_impl->fdetail = detail;
+        return AXIS2_SUCCESS;  
     }
+    else
+    {
+        AXIS2_LOG_DEBUG((*env)->log, AXIS2_LOG_SI," tring to set fault detail more than once");
     
-    detail_node = AXIS2_SOAP_FAULT_DETAIL_GET_BASE_NODE(
-                            detail, env);
-    
-    axis2_soap_utils_set_new_node(env, 
-                    fault_impl->om_ele_node,
-                    &my_node, 
-                    detail_node);
-    */                    
-    fault_impl->fdetail = detail;
-    return AXIS2_SUCCESS;  
-
-
+    }
+    return AXIS2_FAILURE;
 }
                                 
 axis2_soap_fault_detail_t* AXIS2_CALL 
@@ -655,23 +530,6 @@
                 break;
         }            
     }
-    /*
-    axis2_om_node_t *detail_node = NULL;
-    axis2_om_node_t *this_node = NULL;
-    axis2_soap_fault_detail_t* detail = NULL;
-    this_node = fault_impl->om_ele_node;
-    
-    if(!(fault_impl->fdetail))
-    {
-        detail_node = axis2_soap_utils_get_child_with_name(env, 
-                                            this_node, 
-                                            AXIS2_SOAP12_SOAP_FAULT_DETAIL_LOCAL_NAME);
-                                                    
-        detail = axis2_soap_fault_detail_create(env);
-        AXIS2_SOAP_FAULT_DETAIL_SET_BASE_NODE(detail , env, detail_node);
-        fault_impl->fdetail = detail;
-    }
-    */
     return fault_impl->fdetail; 
 }   
 
@@ -703,25 +561,6 @@
     return AXIS2_INTF_TO_IMPL(fault)->om_ele_node;
 }  
                                                 
-axis2_status_t AXIS2_CALL 
-axis2_soap_fault_set_soap_version(axis2_soap_fault_t *fault,
-                                  axis2_env_t **env,
-                                  int soap_version)
-{
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK((*env)->error, soap_version, AXIS2_FAILURE);
-    AXIS2_INTF_TO_IMPL(fault)->soap_version = soap_version;
-    return AXIS2_SUCCESS;
-
-}
-                                    
-int AXIS2_CALL 
-axis2_soap_fault_get_soap_version(axis2_soap_fault_t *fault,
-                                  axis2_env_t **env)
-{
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    return AXIS2_INTF_TO_IMPL(fault)->soap_version;
-}
                                   
 axis2_char_t * AXIS2_CALL 
 axis2_soap_fault_get_exception(axis2_soap_fault_t *fault,
@@ -772,17 +611,17 @@
     detail = axis2_soap_fault_get_detail(fault, env);
     if(!detail)
     {
-        if(fault_impl->soap_version == AXIS2_SOAP11)
-            detail = axis2_soap11_fault_detail_create(env, fault);
-        if(fault_impl->soap_version == AXIS2_SOAP12)
-            detail = axis2_soap12_fault_detail_create(env, fault);
+            detail = axis2_soap_fault_detail_create_with_parent(env, fault);
     }
-    axis2_soap_fault_set_detail(fault, env, detail);
 
     fault_detail_ele = axis2_om_element_create(env, NULL, 
                             AXIS2_SOAP_FAULT_DETAIL_EXCEPTION_ENTRY,
                             NULL, &fault_detail_entry_node);
-
+    if(!fault_detail_ele)
+    {
+        return AXIS2_FAILURE;
+    }
+    
     AXIS2_OM_ELEMENT_SET_TEXT(fault_detail_ele,
          env, exception, fault_detail_entry_node);
 
@@ -825,29 +664,49 @@
     AXIS2_PARAM_CHECK((*env)->error, reason_text, NULL);
 
     soap_fault = axis2_soap_fault_create_with_parent(env, parent);
-    if(soap_fault)
+    if(!soap_fault)
+        return NULL;
+
+    soap_fault_code = axis2_soap_fault_code_create_with_parent(env, soap_fault);
+    if(!soap_fault_code)
     {
-        AXIS2_SOAP_FAULT_SET_SOAP_VERSION(soap_fault, env, soap_version);
-        if(soap_version == AXIS2_SOAP11)
-        {
-            soap_fault_code = axis2_soap11_fault_code_create_with_parent(env, soap_fault);
-            soap_fault_reason = axis2_soap11_fault_reason_create_with_parent(env, soap_fault);
-        }
-        else if(soap_version == AXIS2_SOAP12)
-        {
-            soap_fault_code = axis2_soap12_fault_code_create_with_parent(env, soap_fault);
-            soap_fault_reason = axis2_soap12_fault_reason_create_with_parent(env, soap_fault);    
-        }
+        return NULL;
+    }
+    soap_fault_reason = axis2_soap_fault_reason_create_with_parent(env, soap_fault);
+    if(!soap_fault_reason)
+    {
+        return NULL;
+    }
         
-        soap_fault_value = axis2_soap_fault_value_create_with_code( env,soap_fault_code);
-        value_node = AXIS2_SOAP_FAULT_VALUE_GET_BASE_NODE(soap_fault_value, env);
-        value_ele  = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(value_node, env);
-        AXIS2_OM_ELEMENT_SET_TEXT(value_ele, env, code_value, value_node);
-    
-        soap_fault_text = axis2_soap_fault_text_create_with_parent( env, soap_fault_reason);
-        text_node = AXIS2_SOAP_FAULT_TEXT_GET_BASE_NODE(soap_fault_text, env);
-        text_ele  = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(text_node, env);
-        AXIS2_OM_ELEMENT_SET_TEXT(text_ele, env, reason_text, text_node);
+    soap_fault_value = axis2_soap_fault_value_create_with_code( env,soap_fault_code);
+    if(!soap_fault_value)
+    {
+        return NULL;
+    }
+    
+    value_node = AXIS2_SOAP_FAULT_VALUE_GET_BASE_NODE(soap_fault_value, env);
+    if(!value_node)
+    {
+        return NULL;
+    }
+    value_ele  = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(value_node, env);
+    
+    AXIS2_OM_ELEMENT_SET_TEXT(value_ele, env, code_value, value_node);
+    
+    soap_fault_text = axis2_soap_fault_text_create_with_parent( env, soap_fault_reason);
+    if(!soap_fault_text)
+    {
+        return NULL;
     }
+    
+    text_node = AXIS2_SOAP_FAULT_TEXT_GET_BASE_NODE(soap_fault_text, env);
+    if(!text_node)
+    {
+        return NULL;
+    }
+    text_ele  = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(text_node, env);
+    
+    AXIS2_OM_ELEMENT_SET_TEXT(text_ele, env, reason_text, text_node);
+    
     return soap_fault;
 }

Modified: webservices/axis2/trunk/c/modules/xml/soap/soap_fault_code.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/soap/soap_fault_code.c?rev=385453&r1=385452&r2=385453&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/soap/soap_fault_code.c (original)
+++ webservices/axis2/trunk/c/modules/xml/soap/soap_fault_code.c Mon Mar 13 00:11:01 2006
@@ -30,8 +30,6 @@
     
     axis2_om_node_t *om_ele_node;
     
-    int soap_version;
-    
     axis2_soap_fault_sub_code_t *subcode;
     
     axis2_soap_fault_value_t *value;
@@ -77,14 +75,6 @@
 axis2_soap_fault_code_get_base_node(axis2_soap_fault_code_t *fault_code,
                                     axis2_env_t **env);
  
-axis2_status_t AXIS2_CALL
-axis2_soap_fault_code_set_soap_version(axis2_soap_fault_code_t *fault_code,
-                                  axis2_env_t **env,
-                                  int soap_version);
-
-axis2_status_t AXIS2_CALL
-axis2_soap_fault_code_get_soap_version(axis2_soap_fault_code_t *fault_code,
-                                  axis2_env_t **env);
                                   
 axis2_status_t AXIS2_CALL
 axis2_soap_fault_code_set_builder(axis2_soap_fault_code_t *fault_code,
@@ -112,7 +102,6 @@
     fault_code_impl->om_ele_node = NULL;
     fault_code_impl->subcode = NULL;
     fault_code_impl->value = NULL;
-    fault_code_impl->soap_version = AXIS2_SOAP_VERSION_NOT_SET;
     fault_code_impl->builder = NULL;
     
     fault_code_impl->fault_code.ops = 
@@ -147,11 +136,6 @@
     fault_code_impl->fault_code.ops->get_base_node =
         axis2_soap_fault_code_get_base_node;
         
-    fault_code_impl->fault_code.ops->get_soap_version =
-        axis2_soap_fault_code_get_soap_version; 
-        
-    fault_code_impl->fault_code.ops->set_soap_version =
-        axis2_soap_fault_code_set_soap_version;   
     fault_code_impl->fault_code.ops->set_builder =
         axis2_soap_fault_code_set_builder;                         
                                 
@@ -160,8 +144,7 @@
 
 AXIS2_DECLARE(axis2_soap_fault_code_t *)
 axis2_soap_fault_code_create_with_parent(axis2_env_t **env,
-                            axis2_soap_fault_t *fault,
-                            axis2_bool_t extract_ns_from_parent)
+                            axis2_soap_fault_t *fault)
 {
     axis2_soap_fault_code_impl_t *fault_code_impl = NULL;
     axis2_soap_fault_code_t *fault_code = NULL;
@@ -181,21 +164,27 @@
     fault_code_impl = AXIS2_INTF_TO_IMPL(fault_code);
     
     parent_node = AXIS2_SOAP_FAULT_GET_BASE_NODE(fault, env);
-    
+    if(!parent_node)
+        return NULL;
+
     parent_ele  = (axis2_om_element_t *)AXIS2_OM_NODE_GET_DATA_ELEMENT(
                         parent_node, env);
     
-    if(extract_ns_from_parent)
-    {
-        parent_ns = AXIS2_OM_ELEMENT_GET_NAMESPACE(parent_ele, env);
-    }
+    if(!parent_ele)
+        return NULL;
+    
+    parent_ns = AXIS2_OM_ELEMENT_GET_NAMESPACE(parent_ele, env);
     
     this_ele = axis2_om_element_create(env, 
                                        parent_node,                             
                                        AXIS2_SOAP12_SOAP_FAULT_CODE_LOCAL_NAME,
                                        parent_ns,
                                        &this_node);
-    fault_code_impl->om_ele = this_ele;
+
+    if(!this_ele)
+    {
+        return NULL;
+    }
     fault_code_impl->om_ele_node = this_node;    
     AXIS2_SOAP_FAULT_SET_CODE(fault, env, fault_code);
     return  &(fault_code_impl->fault_code);            
@@ -237,31 +226,21 @@
     axis2_soap_fault_code_impl_t *fault_code_impl = NULL;
     
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+   
     AXIS2_PARAM_CHECK((*env)->error, fault_val, AXIS2_FAILURE);
     
     fault_code_impl = AXIS2_INTF_TO_IMPL(fault_code);
-   /* 
-    axis2_om_node_t *value_node = NULL;
-    axis2_om_node_t *my_node = NULL;
-    axis2_soap_fault_code_get_value(fault_code, env); 
-    if(fault_code_impl->value)
+    if(!(fault_code_impl->value))
     {
-        my_node = AXIS2_SOAP_FAULT_VALUE_GET_BASE_NODE(
-                            fault_code_impl->value, env);
-        AXIS2_SOAP_FAULT_VALUE_FREE(fault_code_impl->value, env);
-        fault_code_impl->value = NULL;
+        fault_code_impl->value = fault_val;
+        return AXIS2_SUCCESS;    
     }
-    
-    value_node = AXIS2_SOAP_FAULT_VALUE_GET_BASE_NODE(
-                            fault_val, env);
-    
-    axis2_soap_utils_set_new_node(env, 
-                    fault_code_impl->om_ele_node,
-                    &my_node, 
-                    value_node);
-    */                    
-    fault_code_impl->value = fault_val;
-    return AXIS2_SUCCESS;    
+    else
+    {
+        AXIS2_LOG_DEBUG((*env)->log , AXIS2_LOG_SI, 
+        "trying to set fault value to fault code more than once");
+    }
+    return AXIS2_FAILURE;    
 }
 
 axis2_status_t AXIS2_CALL 
@@ -273,28 +252,16 @@
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK((*env)->error, fault_subcode, AXIS2_FAILURE);
     fault_code_impl = AXIS2_INTF_TO_IMPL(fault_code);
-   /* 
-    axis2_om_node_t *subcode_node = NULL;
-    axis2_om_node_t *my_node = NULL;
-    
-    axis2_soap_fault_code_get_sub_code(fault_code, env); 
-    if(fault_code_impl->subcode)
+    if(!(fault_code_impl->subcode))
     {
-        my_node = AXIS2_SOAP_FAULT_SUB_CODE_GET_BASE_NODE(
-                            fault_code_impl->subcode, env);
-        AXIS2_SOAP_FAULT_SUB_CODE_FREE(fault_code_impl->subcode, env);
-        fault_code_impl->subcode = NULL;
+        fault_code_impl->subcode = fault_subcode;
+        return AXIS2_SUCCESS;    
     }
-    subcode_node = AXIS2_SOAP_FAULT_SUB_CODE_GET_BASE_NODE(
-                            fault_subcode, env);
-    
-    axis2_soap_utils_set_new_node(env, 
-                    fault_code_impl->om_ele_node,
-                    &my_node, 
-                    subcode_node);
-    */               
-    fault_code_impl->subcode = fault_subcode;
-    return AXIS2_SUCCESS;    
+    else
+    {
+        AXIS2_LOG_DEBUG((*env)->log , AXIS2_LOG_SI, "trying to set fault subcode to fault code more than once ");
+    }
+    return AXIS2_FAILURE;
 }                                                                         
         
 axis2_soap_fault_sub_code_t* AXIS2_CALL 
@@ -321,23 +288,6 @@
             }
         }
     }
-    
-   /*
-    axis2_om_node_t *subcode_node = NULL;
-    axis2_om_node_t *this_node = NULL;
-    axis2_soap_fault_sub_code_t* subcode = NULL;
-    this_node = fault_code_impl->om_ele_node;
-    if(!(fault_code_impl->subcode))
-    {
-        subcode_node = axis2_soap_utils_get_child_with_name(env, 
-                                            this_node, 
-                                            AXIS2_SOAP12_SOAP_FAULT_SUB_CODE_LOCAL_NAME);
-                                                    
-        subcode = axis2_soap_fault_sub_code_create(env);
-        AXIS2_SOAP_FAULT_SUB_CODE_SET_BASE_NODE(subcode , env, subcode_node);
-        fault_code_impl->subcode = subcode;
-    }
-    */
     return fault_code_impl->subcode;
 }
                                      
@@ -366,24 +316,6 @@
             }
         }
     }
-    /*
-    
-    axis2_om_node_t *value_node = NULL;
-    axis2_om_node_t *this_node = NULL;
-    axis2_soap_fault_value_t* fault_value = NULL;
-    this_node = AXIS2_SOAP_FAULT_SUB_CODE_GET_BASE_NODE(fault_code, env);
-    if(!(fault_code_impl->value))
-    {
-        value_node = axis2_soap_utils_get_child_with_name(env, 
-                                            this_node, 
-                                            AXIS2_SOAP12_SOAP_FAULT_VALUE_LOCAL_NAME);
-                                                    
-        fault_value = axis2_soap_fault_value_create(env);
-        AXIS2_SOAP_FAULT_VALUE_SET_BASE_NODE(fault_value, env, value_node);
-        AXIS2_SOAP_FAULT_VALUE_SET_SOAP_VERSION(fault_value, env, AXIS2_SOAP11);
-        fault_code_impl->value = fault_value;
-    }
-    */
     return fault_code_impl->value;    
 }
                                      
@@ -416,25 +348,6 @@
 }
  
 axis2_status_t AXIS2_CALL
-axis2_soap_fault_code_set_soap_version(axis2_soap_fault_code_t *fault_code,
-                                  axis2_env_t **env,
-                                  int soap_version)
-{
-    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-    AXIS2_PARAM_CHECK((*env)->error, soap_version, AXIS2_FAILURE);
-    AXIS2_INTF_TO_IMPL(fault_code)->soap_version = soap_version;
-    return AXIS2_SUCCESS;
-}
-
-axis2_status_t AXIS2_CALL
-axis2_soap_fault_code_get_soap_version(axis2_soap_fault_code_t *fault_code,
-                                  axis2_env_t **env)
-{
-     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-     return AXIS2_INTF_TO_IMPL(fault_code)->soap_version;
-} 
-
-axis2_status_t AXIS2_CALL
 axis2_soap_fault_code_set_builder(axis2_soap_fault_code_t *fault_code,
                                   axis2_env_t **env,
                                   axis2_soap_builder_t *soap_builder)
@@ -446,24 +359,4 @@
     fault_code_impl->builder = soap_builder;
     return AXIS2_SUCCESS;
 }                                                             
-/*********************** soap11 create function *******************************/
-
-AXIS2_DECLARE(axis2_soap_fault_code_t *)
-axis2_soap11_fault_code_create_with_parent(axis2_env_t **env,
-                             axis2_soap_fault_t *fault)
-{
-    AXIS2_ENV_CHECK(env, NULL);
-    AXIS2_PARAM_CHECK((*env)->error, fault, NULL);
-    return axis2_soap_fault_code_create_with_parent(env, fault, AXIS2_TRUE);
 
-}                             
-
-/********************** soap12 create function ********************************/
-AXIS2_DECLARE(axis2_soap_fault_code_t *)
-axis2_soap12_fault_code_create_with_parent(axis2_env_t **env,
-                             axis2_soap_fault_t *fault)
-{
-    AXIS2_ENV_CHECK(env, NULL);
-    AXIS2_PARAM_CHECK((*env)->error, fault, NULL);
-    return axis2_soap_fault_code_create_with_parent(env, fault, AXIS2_TRUE);
-}



Mime
View raw message