Exemple #1
0
/** @brief test uri 
 *  * create URI and get the values of it's components  
 *   */
void test_uri(axutil_env_t *env)
{   
    axis2_char_t * uri_str = "http://*****:*****@example.com:80/foo?bar#item5";
    axis2_char_t * host = "home.netscape.com:443";
    axis2_char_t * uri_str_base = "http://*****:*****@example.com:80/foo?bar";
    axis2_char_t * scheme_str = "http";
    axutil_uri_t * base = NULL;
    axutil_uri_t * hostinfo = NULL;
    axutil_uri_t * uri = NULL;
    axutil_uri_t * clone = NULL;
    axutil_uri_t * rel = NULL;
    axis2_port_t scheme_port;
    axis2_port_t port;
	axis2_char_t * str;

    hostinfo = axutil_uri_parse_hostinfo(env,host);
    CUT_ASSERT_PTR_NOT_EQUAL(hostinfo, NULL, 0);
    
    scheme_port = axutil_uri_port_of_scheme(scheme_str); 
    CUT_ASSERT_INT_NOT_EQUAL(scheme_port, 0, 0);
    
    uri = axutil_uri_parse_string(env,uri_str);    
    CUT_ASSERT_PTR_NOT_EQUAL(uri, NULL, 0);
    str = axutil_uri_get_protocol(uri,env);
	CUT_ASSERT_STR_EQUAL(str, "http", 0);
    port = axutil_uri_get_port(uri,env);
    CUT_ASSERT_INT_EQUAL(port, 80, 0);
    str = axutil_uri_get_path(uri,env);
	CUT_ASSERT_STR_EQUAL(str, "/foo", 0);
    str = axutil_uri_get_host(uri,env);
	CUT_ASSERT_STR_EQUAL(str, "example.com", 0);

    base = axutil_uri_parse_string(env,uri_str_base);
    CUT_ASSERT_PTR_NOT_EQUAL(base, NULL, 0);
	if (base)
    {
        str = axutil_uri_to_string(base,env,0);
		CUT_ASSERT_STR_EQUAL(str, "http://*****:*****@example.com/foo?bar", 0);
    }

    clone = axutil_uri_clone(uri,env);
    CUT_ASSERT_PTR_NOT_EQUAL(clone, NULL, 0);
	if (clone)
    {
        str = axutil_uri_to_string(clone,env,0);
		CUT_ASSERT_STR_EQUAL(str, "http://*****:*****@example.com/foo?bar#item5", 0);
        axutil_uri_free(clone,env);
   }
    
    rel = axutil_uri_resolve_relative(env,base,uri);
    CUT_ASSERT_PTR_NOT_EQUAL(rel, NULL, 0);
	if (rel)
    {
        str = axutil_uri_to_string(rel,env,0);
		CUT_ASSERT_STR_EQUAL(str, "http://*****:*****@example.com/foo?bar#item5", 0);
    }
    
    axutil_uri_free(uri,env);
}
/** @brief test uri 
 *  * create URI and get the values of it's components  
 *   */
axis2_status_t test_uri(axutil_env_t *env)
{   
    axis2_char_t * uri_str = "http://*****:*****@example.com:80/foo?bar#item5";
    axis2_char_t * host = "home.netscape.com:443";
    axis2_char_t * uri_str_base = "http://*****:*****@example.com:80/foo?bar";
    axis2_char_t * scheme_str = "http";
    axutil_uri_t * base = NULL;
    axutil_uri_t * hostinfo = NULL;
    axutil_uri_t * uri = NULL;
    axutil_uri_t * clone = NULL;
    axutil_uri_t * rel = NULL;
    axis2_char_t * protocol = NULL;
    axis2_char_t * server = NULL;
    axis2_char_t * path = NULL;
    axis2_port_t scheme_port;
    axis2_port_t port;

    hostinfo = axutil_uri_parse_hostinfo(env,host);
    if(hostinfo)
    {
        printf("The host information of uri is %s\n",axutil_uri_to_string(hostinfo,env,0));
    }
    else
    {
        printf("Test hostinfo faild\n");
    } 
    
    scheme_port = axutil_uri_port_of_scheme(scheme_str); 
    if(scheme_port)
    {
        printf("port of scheme is %u\n", scheme_port);
    }
    else
    {
        printf("Test port failed\n");
    }
    
    uri = axutil_uri_parse_string(env,uri_str);    
    if(uri)
    {
        printf("The uri is %s\n",axutil_uri_to_string(uri,env,0));
        axutil_uri_free(uri, env);
    }
    else     
    { 
         return AXIS2_FAILURE;
    }

    base = axutil_uri_parse_string(env,uri_str_base);
    if(base)
    {
         printf("The base of uri is %s\n",axutil_uri_to_string(base,env,0));
    }
    else 
    {
       printf("Test base failed\n");
    }

    clone = axutil_uri_clone(uri,env);
    if(clone)
    {
        printf("The clone of uri is %s\n",axutil_uri_to_string(clone,env,0));
        axutil_uri_free(clone,env);
    }
    else
    {
        printf("Test clone failed");
    }
    
    rel = axutil_uri_resolve_relative(env,base,clone);
    if(rel)
    {
        printf("The resolved relative uri is %s\n",axutil_uri_to_string(rel,env,0));
    }
    else
    {
        printf("Test resolve relative failed");
    }
    
    protocol = axutil_uri_get_protocol(uri,env);
    if (!protocol)
    {
        axutil_uri_free(uri,env);
        return AXIS2_FAILURE;
    }
    
    server = axutil_uri_get_server(uri,env);
    if (!server)
    {
        axutil_uri_free(uri,env);
        return AXIS2_FAILURE;
    }
    
    port = axutil_uri_get_port(uri,env);
    if (!port)
    {
        axutil_uri_free(uri,env);
        return AXIS2_FAILURE;
    }
    
    path = axutil_uri_get_path(uri,env);
    if (!path)
    {
        axutil_uri_free(uri,env);
        return AXIS2_FAILURE;
    }
   
    printf("The protocol is %s\n",protocol);
    printf("The server is %s \n",server);
    printf("The port is %u \n",port);
    printf("The path is %s\n",path); 
    axutil_uri_free(uri,env);
    return AXIS2_SUCCESS;
}
        axiom_node_t* AXIS2_CALL
        adb_CanonicalizationMethodType_serialize_obj(
                adb_CanonicalizationMethodType_t* _CanonicalizationMethodType,
                const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index)
        {
            
            
               axiom_attribute_t *text_attri = NULL;
             
             axis2_char_t *string_to_stream;
            
         
         axiom_node_t* current_node = NULL;
         int tag_closed = 0;
         axis2_char_t* xsi_prefix = NULL;
         axiom_namespace_t* xsi_ns = NULL;
         axiom_attribute_t* xsi_type_attri = NULL;
         
         axis2_char_t* type_attrib = NULL;
         
                axiom_namespace_t *ns1 = NULL;

                axis2_char_t *qname_uri = NULL;
                axis2_char_t *qname_prefix = NULL;
                axis2_char_t *p_prefix = NULL;
                axis2_bool_t ns_already_defined;
            
               int i = 0;
               int count = 0;
               void *element = NULL;
             
                    axis2_char_t *text_value_1;
                    axis2_char_t *text_value_1_temp;
                    
                    axis2_char_t *text_value_2;
                    axis2_char_t *text_value_2_temp;
                    
                axis2_char_t *text_value = NULL;
             
               axis2_char_t *start_input_str = NULL;
               axis2_char_t *end_input_str = NULL;
               unsigned int start_input_str_len = 0;
               unsigned int end_input_str_len = 0;
            
            
               axiom_data_source_t *data_source = NULL;
               axutil_stream_t *stream = NULL;

            

            AXIS2_ENV_CHECK(env, NULL);
            AXIS2_PARAM_CHECK(env->error, _CanonicalizationMethodType, NULL);
            
            
                    current_node = parent;
                    data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, env);
                    if (!data_source)
                        return NULL;
                    stream = axiom_data_source_get_stream(data_source, env); /* assume parent is of type data source */
                    if (!stream)
                        return NULL;
                  
            if(!parent_tag_closed)
            {
            
                if(_CanonicalizationMethodType->is_valid_Algorithm)
                {
                
                        p_prefix = NULL;
                      
                           text_value = axutil_uri_to_string(_CanonicalizationMethodType->property_Algorithm, env, AXIS2_URI_UNP_OMITUSERINFO);
                           string_to_stream = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) *
                                                            (5  + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT +
                                                             axutil_strlen(text_value) + 
                                                             axutil_strlen("Algorithm")));
                           sprintf(string_to_stream, " %s%s%s=\"%s\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"",
                                                "Algorithm",  text_value);
                           axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream));
                           AXIS2_FREE(env-> allocator, string_to_stream);
                        
                   }
                   
                   else
                   {
                      AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-optional attribute Algorithm");
                      return NULL;
                   }
                   
              string_to_stream = ">"; 
              axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream));
              tag_closed = 1;
            
            }
        
                       p_prefix = NULL;
                      

                   if (!_CanonicalizationMethodType->is_valid_extraElement)
                   {
                      
                           /* no need to complain for minoccurs=0 element */
                            
                          
                   }
                   else
                   {
                     start_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (4 + axutil_strlen(p_prefix) + 
                                  axutil_strlen("extraElement"))); 
                                 
                                 /* axutil_strlen("<:>") + 1 = 4 */
                     end_input_str = (axis2_char_t*)AXIS2_MALLOC(env->allocator, sizeof(axis2_char_t) *
                                 (5 + axutil_strlen(p_prefix) + axutil_strlen("extraElement")));
                                  /* axutil_strlen("</:>") + 1 = 5 */
                                  
                     

                   
                   
                     /*
                      * Parsing extraElement array
                      */
                     if (_CanonicalizationMethodType->property_extraElement != NULL)
                     {
                        
                            sprintf(start_input_str, "<%s%sextraElement>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":""); 
                            
                         start_input_str_len = axutil_strlen(start_input_str);

                         sprintf(end_input_str, "</%s%sextraElement>",
                                 p_prefix?p_prefix:"",
                                 (p_prefix && axutil_strcmp(p_prefix, ""))?":":"");
                         end_input_str_len = axutil_strlen(end_input_str);

                         count = axutil_array_list_size(_CanonicalizationMethodType->property_extraElement, env);
                         for(i = 0; i < count; i ++)
                         {
                            element = axutil_array_list_get(_CanonicalizationMethodType->property_extraElement, env, i);

                            if(NULL == element) 
                            {
                                continue;
                            }
                    
                     
                     /*
                      * parsing extraElement element
                      */

                    
                    
                                text_value_1 = axiom_node_to_string((axiom_node_t*)element, env);
                                
                                axutil_stream_write(stream, env, text_value_1, axutil_strlen(text_value_1));
                                
                         }
                     }
                   
                     
                     AXIS2_FREE(env->allocator,start_input_str);
                     AXIS2_FREE(env->allocator,end_input_str);
                 } 

                 
                    
                    if(parent_tag_closed)
                    {
                       if(_CanonicalizationMethodType->is_valid_Algorithm)
                       {
                       
                           p_prefix = NULL;
                           ns1 = NULL;
                         
                           text_value = axutil_uri_to_string(_CanonicalizationMethodType->property_Algorithm, env, AXIS2_URI_UNP_OMITUSERINFO);
                           text_attri = axiom_attribute_create (env, "Algorithm", text_value, ns1);
                           axiom_element_add_attribute (parent_element, env, text_attri, parent);
                        
                      }
                      
                      else
                      {
                         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-optional attribute Algorithm");
                         return NULL;
                      }
                       
                  }
                

            return parent;
        }
        axiom_node_t* AXIS2_CALL
        adb_audio_type0_serialize_obj(
                adb_audio_type0_t* _audio_type0,
                const axutil_env_t *env, axiom_node_t *parent, axiom_element_t *parent_element, int parent_tag_closed, axutil_hash_t *namespaces, int *next_ns_index)
        {
            
            
               axiom_attribute_t *text_attri = NULL;
             
             axis2_char_t *string_to_stream;
            
         
         axiom_node_t* current_node = NULL;
         int tag_closed = 0;
         axis2_char_t* xsi_prefix = NULL;
         axiom_namespace_t* xsi_ns = NULL;
         axiom_attribute_t* xsi_type_attri = NULL;
         
         axis2_char_t* type_attrib = NULL;
         
                axiom_namespace_t *ns1 = NULL;

                axis2_char_t *qname_uri = NULL;
                axis2_char_t *qname_prefix = NULL;
                axis2_char_t *p_prefix = NULL;
                axis2_bool_t ns_already_defined;
            
                    axis2_char_t *text_value_1;
                    axis2_char_t *text_value_1_temp;
                    
                    axis2_char_t text_value_2[ADB_DEFAULT_DIGIT_LIMIT];
                    
                    axis2_char_t text_value_3[ADB_DEFAULT_DIGIT_LIMIT];
                    
                    axis2_char_t text_value_4[ADB_DEFAULT_DIGIT_LIMIT];
                    
                axis2_char_t *text_value = NULL;
             
            
               axiom_data_source_t *data_source = NULL;
               axutil_stream_t *stream = NULL;

            

            AXIS2_ENV_CHECK(env, NULL);
            AXIS2_PARAM_CHECK(env->error, _audio_type0, NULL);
            
            
                    current_node = parent;
                    data_source = (axiom_data_source_t *)axiom_node_get_data_element(current_node, env);
                    if (!data_source)
                        return NULL;
                    stream = axiom_data_source_get_stream(data_source, env); /* assume parent is of type data source */
                    if (!stream)
                        return NULL;
                  
            if(!parent_tag_closed)
            {
            
                if(_audio_type0->is_valid_uri)
                {
                
                        p_prefix = NULL;
                      
                           text_value = axutil_uri_to_string(_audio_type0->property_uri, env, AXIS2_URI_UNP_OMITUSERINFO);
                           string_to_stream = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) *
                                                            (5  + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT +
                                                             axutil_strlen(text_value) + 
                                                             axutil_strlen("uri")));
                           sprintf(string_to_stream, " %s%s%s=\"%s\"", p_prefix?p_prefix:"", (p_prefix && axutil_strcmp(p_prefix, ""))?":":"",
                                                "uri",  text_value);
                           axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream));
                           AXIS2_FREE(env-> allocator, string_to_stream);
                        
                   }
                   
                   else
                   {
                      AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-optional attribute uri");
                      return NULL;
                   }
                   
                if(_audio_type0->is_valid_rangeBegin)
                {
                
                        p_prefix = NULL;
                      
                           text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * 
                                                            (ADB_DEFAULT_DIGIT_LIMIT + 5  + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT + 
                                                                axutil_strlen("rangeBegin")));
                           sprintf(text_value, " %s%s%s=\"" AXIS2_PRINTF_INT64_FORMAT_SPECIFIER  "\"", p_prefix?p_prefix:"", 
                                                (p_prefix && axutil_strcmp(p_prefix, ""))?":":"",
                                                "rangeBegin", _audio_type0->property_rangeBegin);
                           axutil_stream_write(stream, env, text_value, axutil_strlen(text_value));
                           AXIS2_FREE(env-> allocator, text_value);
                        
                   }
                   
                if(_audio_type0->is_valid_rangeEnd)
                {
                
                        p_prefix = NULL;
                      
                           text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * 
                                                            (ADB_DEFAULT_DIGIT_LIMIT + 5  + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT + 
                                                                axutil_strlen("rangeEnd")));
                           sprintf(text_value, " %s%s%s=\"" AXIS2_PRINTF_INT64_FORMAT_SPECIFIER  "\"", p_prefix?p_prefix:"", 
                                                (p_prefix && axutil_strcmp(p_prefix, ""))?":":"",
                                                "rangeEnd", _audio_type0->property_rangeEnd);
                           axutil_stream_write(stream, env, text_value, axutil_strlen(text_value));
                           AXIS2_FREE(env-> allocator, text_value);
                        
                   }
                   
                if(_audio_type0->is_valid_size)
                {
                
                        p_prefix = NULL;
                      
                           text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * 
                                                            (ADB_DEFAULT_DIGIT_LIMIT + 5  + ADB_DEFAULT_NAMESPACE_PREFIX_LIMIT + 
                                                                axutil_strlen("size")));
                           sprintf(text_value, " %s%s%s=\"" AXIS2_PRINTF_INT64_FORMAT_SPECIFIER  "\"", p_prefix?p_prefix:"", 
                                                (p_prefix && axutil_strcmp(p_prefix, ""))?":":"",
                                                "size", _audio_type0->property_size);
                           axutil_stream_write(stream, env, text_value, axutil_strlen(text_value));
                           AXIS2_FREE(env-> allocator, text_value);
                        
                   }
                   
              string_to_stream = ">"; 
              axutil_stream_write(stream, env, string_to_stream, axutil_strlen(string_to_stream));
              tag_closed = 1;
            
            }
        
                    
                    if(parent_tag_closed)
                    {
                       if(_audio_type0->is_valid_uri)
                       {
                       
                           p_prefix = NULL;
                           ns1 = NULL;
                         
                           text_value = axutil_uri_to_string(_audio_type0->property_uri, env, AXIS2_URI_UNP_OMITUSERINFO);
                           text_attri = axiom_attribute_create (env, "uri", text_value, ns1);
                           axiom_element_add_attribute (parent_element, env, text_attri, parent);
                        
                      }
                      
                      else
                      {
                         AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Nil value found in non-optional attribute uri");
                         return NULL;
                      }
                       
                  }
                
                    
                    if(parent_tag_closed)
                    {
                       if(_audio_type0->is_valid_rangeBegin)
                       {
                       
                           p_prefix = NULL;
                           ns1 = NULL;
                         
                           text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * ADB_DEFAULT_DIGIT_LIMIT);
                           sprintf (text_value, AXIS2_PRINTF_INT64_FORMAT_SPECIFIER, (int64_t)_audio_type0->property_rangeBegin);
                           text_attri = axiom_attribute_create (env, "rangeBegin", text_value, ns1);
                           axiom_element_add_attribute (parent_element, env, text_attri, parent);
                           AXIS2_FREE(env-> allocator, text_value);
                        
                      }
                       
                  }
                
                    
                    if(parent_tag_closed)
                    {
                       if(_audio_type0->is_valid_rangeEnd)
                       {
                       
                           p_prefix = NULL;
                           ns1 = NULL;
                         
                           text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * ADB_DEFAULT_DIGIT_LIMIT);
                           sprintf (text_value, AXIS2_PRINTF_INT64_FORMAT_SPECIFIER, (int64_t)_audio_type0->property_rangeEnd);
                           text_attri = axiom_attribute_create (env, "rangeEnd", text_value, ns1);
                           axiom_element_add_attribute (parent_element, env, text_attri, parent);
                           AXIS2_FREE(env-> allocator, text_value);
                        
                      }
                       
                  }
                
                    
                    if(parent_tag_closed)
                    {
                       if(_audio_type0->is_valid_size)
                       {
                       
                           p_prefix = NULL;
                           ns1 = NULL;
                         
                           text_value = (axis2_char_t*) AXIS2_MALLOC (env-> allocator, sizeof (axis2_char_t) * ADB_DEFAULT_DIGIT_LIMIT);
                           sprintf (text_value, AXIS2_PRINTF_INT64_FORMAT_SPECIFIER, (int64_t)_audio_type0->property_size);
                           text_attri = axiom_attribute_create (env, "size", text_value, ns1);
                           axiom_element_add_attribute (parent_element, env, text_attri, parent);
                           AXIS2_FREE(env-> allocator, text_value);
                        
                      }
                       
                  }
                

            return parent;
        }
Exemple #5
0
axis2_status_t
wsclient_set_attachment (const axutil_env_t *env,
						 axiom_node_t *node,
						 axis2_char_t *base_dir,
						 int is_mtom_enabled)
{
	axiom_node_t *child_node = NULL;
	axiom_element_t *element;
	if (!node || !env)
		return AXIS2_FAILURE;

	if (axiom_node_get_node_type (node, env) == AXIOM_ELEMENT)
	{
		axis2_char_t *local_name;
		axiom_namespace_t *ns;
		axis2_char_t *ns_uri;
		element = (axiom_element_t *) axiom_node_get_data_element (node, env);
		local_name = axiom_element_get_localname (element, env);
		if (local_name)
		{
			if (!strcmp (local_name, "Include"))
			{
				ns = axiom_element_get_namespace(element, env, node);
				if (ns && (ns_uri = axiom_namespace_get_uri (ns, env))
					&& (!strcmp (ns_uri, "http://www.w3.org/2004/08/xop/include")))
				{
					axis2_char_t *file_path;
					axiom_data_handler_t *data_handler;
					axiom_text_t *data_text;
					axiom_node_t *data_node;
					axiom_node_t *parent;
					axutil_uri_t *file_uri = NULL;
					axutil_uri_t *base_uri = NULL;
					axutil_uri_t *real_uri = NULL;
					axis2_char_t *real_path = NULL;

					parent = axiom_node_get_parent (node, env);
					axiom_node_detach (node, env);
					file_path = axiom_element_get_attribute_value_by_name (element, env, "href");
					file_uri = axutil_uri_parse_string (env, file_path);

					if (base_dir)
						base_uri = axutil_uri_parse_string (env, base_dir);
					else 
						return AXIS2_FAILURE;


					if (base_uri)
						real_uri = axutil_uri_parse_relative (env, base_uri, file_path);
					else
						return AXIS2_FAILURE;

					if (real_uri)
						real_path = axutil_uri_to_string (real_uri, env, 1);
					else 
						return AXIS2_FAILURE;


					if (real_path)
						data_handler = axiom_data_handler_create (env, real_path, "image/jpeg");
					else
						return AXIS2_FAILURE;

					if (data_handler)
						data_text = axiom_text_create_with_data_handler (env, parent, data_handler, &data_node);
					else
						return AXIS2_FAILURE;

					if (data_text)
					{
						if (!is_mtom_enabled)
							axiom_text_set_optimize (data_text, env, AXIS2_FALSE);
					}
				}
			}
		}

		child_node = axiom_node_get_first_element (node, env);
		while (child_node)
		{
			wsclient_set_attachment (env, child_node, base_dir, is_mtom_enabled); 
			child_node = axiom_node_get_next_sibling (child_node, env);
		}
	}
	else
		return AXIS2_FAILURE;

	return AXIS2_SUCCESS;
}
AXIS2_EXTERN axiom_node_t *AXIS2_CALL
axis2_svc_client_send_receive_with_op_qname(
    axis2_svc_client_t * svc_client,
    const axutil_env_t * env,
    const axutil_qname_t * op_qname,
    const axiom_node_t * payload)
{
    axiom_soap_envelope_t *soap_envelope = NULL;
    axiom_soap_body_t *soap_body = NULL;
    axiom_node_t *soap_node = NULL;
    axis2_op_t *op = NULL;
    axutil_param_t *param = NULL;
    axutil_uri_t *action_uri = NULL;
    axis2_char_t *action_str = NULL;
    axis2_bool_t qname_free_flag = AXIS2_FALSE;

    axis2_msg_ctx_t *res_msg_ctx = NULL;
    axis2_msg_ctx_t *msg_ctx = NULL;

    AXIS2_PARAM_CHECK(env->error, svc_client, NULL);

    svc_client->last_response_soap_envelope = NULL;
    svc_client->last_response_has_fault = AXIS2_FALSE;
    svc_client->auth_failed = AXIS2_FALSE;
    svc_client->required_auth_is_http = AXIS2_FALSE;
    if(svc_client->auth_type)
    {
        AXIS2_FREE(env->allocator, svc_client->auth_type);
    }
    svc_client->auth_type = NULL;

    op = axis2_svc_get_op_with_qname(svc_client->svc, env, op_qname);
    if(op)
    {
        param = axis2_op_get_param(op, env, AXIS2_SOAP_ACTION);
        if(param)
        {
            action_uri = (axutil_uri_t *)axutil_param_get_value(param, env);
            action_str = axutil_uri_to_string(action_uri, env, AXIS2_URI_UNP_OMITUSERINFO);
            axis2_options_set_action(svc_client->options, env, action_str);
        }
    }

    if(!op_qname)
    {
        op_qname = axutil_qname_create(env, AXIS2_ANON_OUT_IN_OP, NULL, NULL);
        if(!op_qname)
            return NULL;

        qname_free_flag = AXIS2_TRUE;
    }

    /* If dual channel blocking. We come to this block if the client indicate to use
     * a separate listener but don't provide a callback function to acted upon when
     * response is received in the listener thread. What we do here is we create a callback
     * and call axis2_svc_client_send_receive_non_blocking_with_op_qname with it. */
    if(axis2_options_get_use_separate_listener(svc_client->options, env))
    {
        axis2_callback_t *callback = NULL;
        axis2_msg_ctx_t *msg_ctx = NULL;
        long index = 0;

        /* This means doing a Request-Response invocation using two channels.
         If the transport is a two way transport (e.g. http), only one channel is used
         (e.g. in http cases 202 OK is sent to say no response available).
         Axis2 gets blocked and return when the response is available. */

        callback = axis2_callback_create(env);
        if(!callback)
        {
            return NULL;
        }

        /* Call two channel non blocking invoke to do the work and wait on the callback. We don't 
         * set a callback function for the callback. That functionality is handled here. 
         */
        axis2_svc_client_send_receive_non_blocking_with_op_qname(svc_client, env, op_qname,
            payload, callback);

        index = axis2_options_get_timeout_in_milli_seconds(svc_client->options, env) / 10;

        while(!axis2_callback_get_complete(callback, env))
        {
            if(index-- >= 0)
            {
                AXIS2_USLEEP(10000);
            }
            else
            {
                AXIS2_ERROR_SET(env->error, AXIS2_ERROR_RESPONSE_TIMED_OUT, AXIS2_FAILURE);
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Response time out.");
                return NULL;
            }
        }

        soap_envelope = axis2_callback_get_envelope(callback, env);
        msg_ctx = axis2_callback_get_msg_ctx(callback, env);
        axis2_op_client_add_in_msg_ctx(svc_client->op_client, env, msg_ctx);

        /* start of hack to get rid of memory leak */
        /*msg_ctx = axis2_msg_ctx_create(env, axis2_svc_ctx_get_conf_ctx(svc_client-> svc_ctx, env),
            NULL, NULL);
        if(!msg_ctx)
            return NULL;

        axis2_op_client_add_in_msg_ctx(svc_client->op_client, env, msg_ctx);

        axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope);*/
        /* end of hack to get rid of memory leak */

        /* process the result of the invocation */
        if(!soap_envelope)
        {
            if(axis2_callback_get_error(callback, env) != AXIS2_ERROR_NONE)
            {
                AXIS2_ERROR_SET(env->error, axis2_callback_get_error(callback, env), AXIS2_FAILURE);
                return NULL;
            }
        }
    }
    else
    {
        msg_ctx = axis2_msg_ctx_create(env, axis2_svc_ctx_get_conf_ctx(svc_client->svc_ctx, env),
            NULL, NULL);
        if(!msg_ctx)
            return NULL;

        if(!axis2_svc_client_fill_soap_envelope(env, svc_client, msg_ctx, payload))
        {
            return NULL;
        }

        if(!axis2_svc_client_create_op_client(svc_client, env, op_qname))
        {
            return NULL;
        }

        axis2_op_client_add_msg_ctx(svc_client->op_client, env, msg_ctx);
        axis2_op_client_execute(svc_client->op_client, env, AXIS2_TRUE);
        axis2_svc_client_set_http_info(svc_client, env, msg_ctx);
        svc_client->auth_failed = axis2_msg_ctx_get_auth_failed(msg_ctx, env);
        svc_client->required_auth_is_http = axis2_msg_ctx_get_required_auth_is_http(msg_ctx, env);
        if(axis2_msg_ctx_get_auth_type(msg_ctx, env))
        {
            svc_client->auth_type = axutil_strdup(env, axis2_msg_ctx_get_auth_type(msg_ctx, env));
        }
        res_msg_ctx = (axis2_msg_ctx_t *)axis2_op_client_get_msg_ctx(svc_client-> op_client, env,
            AXIS2_WSDL_MESSAGE_LABEL_IN);

        if(res_msg_ctx)
        {
            soap_envelope = axis2_msg_ctx_get_soap_envelope(res_msg_ctx, env);
        }
        else
        {
            axis2_op_client_add_msg_ctx(svc_client->op_client, env, res_msg_ctx);
            /* set in msg_ctx to be NULL to reset */
        }
    }

    if(qname_free_flag)
    {
        axutil_qname_free((axutil_qname_t *)op_qname, env);
    }

    if(!soap_envelope)
    {
        return NULL;
    }
    svc_client->last_response_soap_envelope = soap_envelope;

    soap_body = axiom_soap_envelope_get_body(soap_envelope, env);

    if(!soap_body)
    {
        axiom_node_t *node = axiom_soap_envelope_get_base_node(soap_envelope, env);
        if(node)
        {
            axiom_element_t *envelope_element = (axiom_element_t *)axiom_node_get_data_element(
                node, env);
            axiom_util_get_first_child_element_with_localname(envelope_element, env, node,
                AXIOM_SOAP_BODY_LOCAL_NAME, &soap_node);
            if(soap_node)
            {
                return axiom_node_get_first_element(soap_node, env);
            }
        }
        return NULL;
    }

    if(axis2_msg_ctx_get_doing_rest(res_msg_ctx, env))
    {
        /* All HTTP 4xx and 5xx status codes are treated as errors */
        if(axis2_msg_ctx_get_status_code(res_msg_ctx, env) >= 400)
        {
            svc_client->last_response_has_fault = AXIS2_TRUE;
        }
        else
        {
            svc_client->last_response_has_fault = AXIS2_FALSE;
        }
    }
    else
    {
        svc_client->last_response_has_fault = axiom_soap_body_has_fault(soap_body, env);
    }

    if(AXIOM_SOAP11 == axiom_soap_envelope_get_soap_version(soap_envelope, env))
    {
        axiom_soap_body_convert_fault_to_soap11(soap_body, env);
    }

    soap_node = axiom_soap_body_get_base_node(soap_body, env);
    if(!soap_node)
    {
        return NULL;
    }
    return axiom_node_get_first_element(soap_node, env);
}