The patch adds a method to soap_fault_value to get the code text.
(This is a good to have function to cut down the code length when accessing fault struct)
Please review and apply.

thanks
-Nabeel

Index: include/axis2_soap_fault_value.h
===================================================================
--- include/axis2_soap_fault_value.h    (revision 389779)
+++ include/axis2_soap_fault_value.h    (working copy)
@@ -55,6 +55,16 @@
         axis2_status_t (AXIS2_CALL *
                free_fn)(axis2_soap_fault_value_t *fault_value,
                  axis2_env_t **env);
+               
+               /**
+                 * Get the text value of the env:Value element directly under 
env:Code element
+                 * @param fault_value pointer to axis2_soap_fault_t
+                 * @param env Environment. MUST NOT BE NULL
+                 * @return text value 
+                 */
+               axis2_char_t* (AXIS2_CALL *
+               get_text)(axis2_soap_fault_value_t *fault_value,
+                               axis2_env_t **env);             
 
         axis2_om_node_t* (AXIS2_CALL *
                get_base_node)(axis2_soap_fault_value_t *fault_value,
@@ -98,6 +108,8 @@
 #define AXIS2_SOAP_FAULT_VALUE_GET_BASE_NODE(fault_value, env) \
         ((fault_value)->ops->get_base_node(fault_value, env))         
 
+#define AXIS2_SOAP_FAULT_VALUE_GET_TEXT(fault_value, env) \
+               ((fault_value)->ops->get_text(fault_value, env))
 /** @} */
 
 #ifdef __cplusplus
Index: modules/xml/soap/soap_fault_value.c
===================================================================
--- modules/xml/soap/soap_fault_value.c (revision 389779)
+++ modules/xml/soap/soap_fault_value.c (working copy)
@@ -16,8 +16,9 @@
  #include <axis2_soap_fault_value.h>
  #include <_axis2_soap_fault_sub_code.h>
  #include <_axis2_soap_fault_code.h>
+ #include <axis2_om_element.h>
+ #include <axis2_om_text.h>
  
- 
 /****************************** impl struct  *********************************/
 
 typedef struct axis2_soap_fault_value_impl_t
@@ -45,7 +46,9 @@
 axis2_soap_fault_value_get_base_node(axis2_soap_fault_value_t *fault_value,
                                      axis2_env_t **env);
                                   
-
+axis2_char_t* AXIS2_CALL
+axis2_soap_fault_value_get_text(axis2_soap_fault_value_t *fault_value,
+                                                                       
axis2_env_t **env);
 /*************************** function implementations 
*************************/
 
 AXIS2_DECLARE(axis2_soap_fault_value_t *)
@@ -80,6 +83,9 @@
         
     fault_val_impl->fault_value.ops->get_base_node =
         axis2_soap_fault_value_get_base_node;
+
+       fault_val_impl->fault_value.ops->get_text =
+               axis2_soap_fault_value_get_text;
         
     return &(fault_val_impl->fault_value);
 }
@@ -246,3 +252,24 @@
     fault_val_impl = AXIS2_INTF_TO_IMPL(fault_value);
     return fault_val_impl->om_ele_node;
 }
+
+axis2_char_t* AXIS2_CALL
+axis2_soap_fault_value_get_text(axis2_soap_fault_value_t *fault_value,
+                                                               axis2_env_t 
**env)
+{
+       axis2_om_node_t *value_node = NULL;
+       axis2_om_element_t *value_element = NULL;
+       
+       value_node = axis2_soap_fault_value_get_base_node(fault_value, env);
+       
+       if (!value_node)
+               return NULL;
+
+       value_element = (axis2_om_element_t*)AXIS2_OM_NODE_GET_DATA_ELEMENT(
+               value_node, env);
+       
+       if (!value_element)
+               return NULL;
+       
+       return AXIS2_OM_ELEMENT_GET_TEXT(value_element, env, value_node);
+}
Index: test/xml/soap/test_soap.c
===================================================================
--- test/xml/soap/test_soap.c   (revision 390003)
+++ test/xml/soap/test_soap.c   (working copy)
@@ -19,6 +19,7 @@
 #include <axis2_soap_fault.h>
 #include <axis2_soap_fault_code.h>
 #include <axis2_soap_fault_role.h>
+#include <axis2_soap_fault_value.h>
 
 FILE *f = NULL;
 
@@ -322,6 +323,32 @@
 return 0;
 }
 
+int test_soap_fault_value(axis2_env_t **env)
+{
+       axis2_soap_envelope_t *soap_envelope = NULL;
+       axis2_soap_body_t *soap_body = NULL;
+       axis2_soap_fault_t *soap_fault = NULL;
+       axis2_soap_fault_code_t *soap_code = NULL;
+       axis2_soap_fault_value_t *value = NULL;
+       axis2_char_t *value_text = NULL;
+
+       printf("TEST SOAP FAULT VALUE\n");
+       soap_envelope = axis2_soap_envelope_create_default_soap_fault_envelope(
+                       env, "env:Receiver", "Something went wrong!", 
AXIS2_SOAP12);
+       soap_body = AXIS2_SOAP_ENVELOPE_GET_BODY(soap_envelope, env);
+       soap_fault = AXIS2_SOAP_BODY_GET_FAULT(soap_body, env);
+       soap_code = AXIS2_SOAP_FAULT_GET_CODE(soap_fault, env);
+       value = AXIS2_SOAP_FAULT_CODE_GET_VALUE(soap_code, env);
+       value_text = AXIS2_SOAP_FAULT_VALUE_GET_TEXT(value, env);       
+       
+       printf ("Actual = %s Expected = %s |", value_text, "env:Receiver");
+       if (0 == strcmp(value_text, "env:Receiver"))
+               printf("SUCCESS\n");
+       else
+               printf("FAILURE\n");
+
+       AXIS2_SOAP_ENVELOPE_FREE(soap_envelope, env);
+}      
 int main(int argc, char *argv[])
 {
     axis2_env_t *env = NULL;
@@ -349,6 +376,7 @@
 /*    build_soap_programatically(&env);   */
     build_soap(&env, filename,uri); 
     create_soap_fault(&env); 
+       test_soap_fault_value(&env);
     axis2_env_free(env); 
     axis2_allocator_free(allocator);
     return 0;        

Reply via email to