axis2_status_t AXIS2_CALL
axis2_cgi_out_transport_info_set_content_type(
    axis2_http_out_transport_info_t *info,
    const axutil_env_t *env,
    const axis2_char_t *content_type)
{
    axis2_cgi_out_transport_info_t *info_impl = NULL;

    axis2_char_t *temp1 = NULL;
    axis2_char_t *temp2 = NULL;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, content_type, AXIS2_FAILURE);
    info_impl = AXIS2_INTF_TO_IMPL(info);
    if (info_impl->encoding)
    {
        temp1 = axutil_stracat(env, content_type, ";charset=");
        temp2 = axutil_stracat(env, temp1, info_impl->encoding);
        info_impl->request->content_type = axutil_strdup(env, temp2);
        AXIS2_FREE(env->allocator, temp1);
        AXIS2_FREE(env->allocator, temp2);
    }
    else
    {
        info_impl->request->content_type = axutil_strdup(env, content_type);
    }
    return AXIS2_SUCCESS;
}
axis2_status_t AXIS2_CALL
axis2_apache_out_transport_info_set_content_type(
    axis2_http_out_transport_info_t * out_transport_info,
    const axutil_env_t * env,
    const axis2_char_t * content_type)
{
    axis2_apache2_out_transport_info_t *info = NULL;

    axis2_char_t *tmp1 = NULL;
    axis2_char_t *tmp2 = NULL;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, content_type, AXIS2_FAILURE);
    info = AXIS2_INTF_TO_IMPL(out_transport_info);

    if(info->encoding)
    {

        tmp1 = axutil_stracat(env, content_type, ";charset=");
        tmp2 = axutil_stracat(env, tmp1, info->encoding);
        info->request->content_type = apr_pstrdup(info->request->pool, tmp2);
        AXIS2_FREE(env->allocator, tmp1);
        AXIS2_FREE(env->allocator, tmp2);
    }
    else
    {
        /* info->request->content_type = apr_pstrdup(info->request->pool, content_type); */
        tmp1 = axutil_stracat(env, content_type, ";charset=UTF-8");
        info->request->content_type = apr_pstrdup(info->request->pool, tmp1);
        AXIS2_FREE(env->allocator, tmp1);
    }
    return AXIS2_SUCCESS;
}
예제 #3
0
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axiom_output_get_root_content_id(
    axiom_output_t * om_output,
    const axutil_env_t * env)
{
    axis2_char_t *temp_str = NULL;
    axis2_char_t *uuid = NULL;
    AXIS2_ENV_CHECK(env, NULL);
    AXIS2_PARAM_CHECK(env->error, om_output, NULL);

    if(!om_output->root_content_id)
    {
        uuid = axutil_uuid_gen(env);

        temp_str = axutil_stracat(env, "0.", uuid);

        om_output->root_content_id = axutil_stracat(env, temp_str, "@apache.org");

        if(temp_str)
        {
            AXIS2_FREE(env->allocator, temp_str);
            temp_str = NULL;
        }
        if(uuid)
        {
            AXIS2_FREE(env->allocator, uuid);
            uuid = NULL;
        }
    }

    return om_output->root_content_id;
}
예제 #4
0
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axiom_namespace_to_string(
    axiom_namespace_t * om_namespace,
    const axutil_env_t * env)
{
    axis2_char_t *temp_str = NULL;
    AXIS2_ENV_CHECK(env, NULL);
    if(om_namespace->key)
    {
        AXIS2_FREE(env->allocator, om_namespace->key);
        om_namespace->key = NULL;
    }
    if((om_namespace->uri) && (NULL != om_namespace->prefix))
    {
        temp_str = axutil_stracat(env, axutil_string_get_buffer(om_namespace->uri, env), "|");
        om_namespace->key = axutil_stracat(env, temp_str, axutil_string_get_buffer(
            om_namespace->prefix, env));
        if(temp_str)
        {
            AXIS2_FREE(env->allocator, temp_str);
            temp_str = NULL;
        }
    }
    else if((om_namespace->uri) && !(om_namespace->prefix))
    {
        om_namespace->key = axutil_strdup(env, axutil_string_get_buffer(om_namespace->uri, env));
        if(!(om_namespace->key))
        {
            return NULL;
        }
    }
    return om_namespace->key;
}
예제 #5
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_repos_listener_check_modules(
    axis2_repos_listener_t * repos_listener,
    const axutil_env_t * env)
{
    axis2_char_t *module_path = NULL;
    axis2_char_t *temp_path = NULL;
    axis2_status_t status = AXIS2_FAILURE;
    axis2_bool_t axis2_flag = AXIS2_FALSE;
    axis2_conf_t *conf;

    axutil_param_t *module_param;
    axis2_char_t *module_dir;

    AXIS2_PARAM_CHECK(env->error, repos_listener, AXIS2_FAILURE);

    conf = axis2_repos_listener_get_conf(repos_listener, env);

    /* Configuration  is needed only to decide we are using axis2.xml. Other
     * case we don't need. Hence even if conf is NULL we can continue.
     */

    if(conf)
    {
        axis2_flag = axis2_conf_get_axis2_flag(conf, env);
    }

    if(!axis2_flag)
    {

        temp_path = axutil_stracat(env, repos_listener->folder_name, AXIS2_PATH_SEP_STR);
        module_path = axutil_stracat(env, temp_path, AXIS2_MODULE_PATH);
        AXIS2_FREE(env->allocator, temp_path);
    }
    else
    {
        module_param = axis2_conf_get_param(conf, env, AXIS2_MODULE_DIR);
        if(module_param)
        {
            module_dir = (axis2_char_t *)axutil_param_get_value(module_param, env);
            module_path = axutil_strdup(env, module_dir);
        }
        else
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "While creating axis2 configuration using "
                "axis2.xml, modulesDir  parameter not available.");
        }

    }

    status = axis2_repos_listener_search(repos_listener, env, module_path, AXIS2_MODULE);

    AXIS2_FREE(env->allocator, module_path);

    return status;
}
예제 #6
0
AXIS2_EXTERN axiom_mime_body_part_t *AXIS2_CALL
axiom_mime_body_part_create_from_om_text(
    const axutil_env_t *env,
    axiom_text_t *text)
{
    axiom_data_handler_t *data_handler = NULL;
    axiom_mime_body_part_t *mime_body_part = NULL;
    axis2_char_t *content_id = NULL;
    axis2_char_t *temp_content_id = NULL;
    const axis2_char_t *content_type = AXIOM_MIME_TYPE_OCTET_STREAM;

    mime_body_part = axiom_mime_body_part_create(env);
    if(!mime_body_part)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "MIME body part creation failed");
        return NULL;
    }

    /* Take the data_handler which is set by the sending applocation. */

    data_handler = axiom_text_get_data_handler(text, env);

    if(data_handler)
    {
        content_type = axiom_data_handler_get_content_type(data_handler, env);
    }

    axiom_mime_body_part_set_data_handler(mime_body_part, env, data_handler);
    content_id = (axis2_char_t *)"<";
    content_id = axutil_stracat(env, content_id, axiom_text_get_content_id(text, env));
    temp_content_id = axutil_stracat(env, content_id, ">");

    AXIS2_FREE(env->allocator, content_id);
    content_id = temp_content_id;

    /* Adding the content-id */
    axiom_mime_body_part_add_header(mime_body_part, env, AXIOM_MIME_HEADER_CONTENT_ID, content_id);

    /* Adding the content-type */
    axiom_mime_body_part_add_header(mime_body_part, env, AXIOM_MIME_HEADER_CONTENT_TYPE,
        axutil_strdup(env, content_type));

    /* Adding the content-transfer encoding */
    axiom_mime_body_part_add_header(mime_body_part, env,
        AXIOM_MIME_HEADER_CONTENT_TRANSFER_ENCODING, axutil_strdup(env,
            AXIOM_MIME_CONTENT_TRANSFER_ENCODING_BINARY));

    return mime_body_part;
}
예제 #7
0
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axutil_dll_desc_create_platform_specific_dll_name(
    axutil_dll_desc_t *dll_desc,
    const axutil_env_t *env,
    const axis2_char_t *class_name)
{
    axis2_char_t *temp_name = NULL;

    AXIS2_ENV_CHECK(env, NULL);

    temp_name = axutil_stracat(env, AXIS2_LIB_PREFIX, class_name);
    dll_desc->dll_name = axutil_stracat(env, temp_name, AXIS2_LIB_SUFFIX);
    AXIS2_FREE(env->allocator, temp_name);
    return dll_desc->dll_name;
}
예제 #8
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_repos_listener_check_svcs(
    axis2_repos_listener_t * repos_listener,
    const axutil_env_t * env)
{
    axis2_char_t *svc_path = NULL;
    axis2_char_t *temp_path = NULL;
    axis2_status_t status = AXIS2_FAILURE;

    axis2_conf_t *conf;
    axis2_bool_t axis2_flag = AXIS2_FALSE;

    axutil_param_t *svc_param;
    axis2_char_t *svc_dir;

    AXIS2_PARAM_CHECK(env->error, repos_listener, AXIS2_FAILURE);

    conf = axis2_repos_listener_get_conf(repos_listener, env);

    if(conf)
        axis2_flag = axis2_conf_get_axis2_flag(conf, env);

    if(!axis2_flag)
    {
        temp_path = axutil_stracat(env, repos_listener->folder_name, AXIS2_PATH_SEP_STR);
        svc_path = axutil_stracat(env, temp_path, AXIS2_SVC_PATH);
        AXIS2_FREE(env->allocator, temp_path);
    }
    else
    {
        svc_param = axis2_conf_get_param(conf, env, AXIS2_SERVICE_DIR);
        if(svc_param)
        {
            svc_dir = axutil_param_get_value(svc_param, env);
            svc_path = axutil_strdup(env, svc_dir);
        }
        else
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                "While creating axis2 configuration using axis2.xml, servicesDir"
                    " parameter not available.");
        }
    }

    status = axis2_repos_listener_search(repos_listener, env, svc_path, AXIS2_SVC);
    AXIS2_FREE(env->allocator, svc_path);
    return status;
}
예제 #9
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_msg_info_headers_set_message_id(
    struct axis2_msg_info_headers * msg_info_headers,
    const axutil_env_t * env,
    const axis2_char_t * message_id)
{
    (void)env;
    if(msg_info_headers->message_id)
    {
        AXIS2_FREE(env->allocator, msg_info_headers->message_id);
        msg_info_headers->message_id = NULL;
    }

    if(message_id)
    {
        msg_info_headers->message_id = axutil_stracat(env, AXIS2_MESSAGE_ID_PREFIX, message_id);
        if(!(msg_info_headers->message_id))
        {
            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
            return AXIS2_FAILURE;
        }
    }

    return AXIS2_SUCCESS;
}
예제 #10
0
axis2_endpoint_ref_t *AXIS2_CALL
axis2_udp_receiver_get_reply_to_epr(
    axis2_transport_receiver_t * receiver,
    const axutil_env_t * env,
    const axis2_char_t * svc_name)
{
	axis2_endpoint_ref_t *epr = NULL;
    const axis2_char_t *host_address = NULL;
    axis2_char_t *svc_path = NULL;
    axutil_url_t *url = NULL;

    AXIS2_PARAM_CHECK(env->error, svc_name, NULL);
    AXIS2_PARAM_CHECK(env->error, receiver, NULL);

    host_address = AXIS2_DEFAULT_HOST_ADDRESS; /* TODO : get from axis2.xml */
    svc_path = axutil_stracat(env, AXIS2_DEFAULT_SVC_PATH, svc_name);
    url = axutil_url_create(env, "soap.udp", host_address,
                            AXIS2_INTF_TO_IMPL(receiver)->port, svc_path);
    AXIS2_FREE(env->allocator, svc_path);
    if (!url)
    {
        return NULL;
    }
    epr = axis2_endpoint_ref_create(env, axutil_url_to_external_form(url, env));
    axutil_url_free(url, env);
    return epr;
}
예제 #11
0
axis2_endpoint_ref_t *AXIS2_CALL
axis2_tcp_server_get_reply_to_epr(
    axis2_transport_receiver_t * server,
    const axutil_env_t * env,
    const axis2_char_t * svc_name)
{
    axis2_endpoint_ref_t *epr = NULL;
    const axis2_char_t *host_address = NULL;
    axis2_char_t *svc_path = NULL;
    axutil_url_t *url = NULL;
    AXIS2_ENV_CHECK(env, NULL);
    AXIS2_PARAM_CHECK(env->error, svc_name, NULL);

    host_address = "127.0.0.1"; /* TODO : get from axis2.xml */
    svc_path = axutil_stracat(env, "/axis2/services/", svc_name);
    url = axutil_url_create(env, "tcp", host_address,
                            AXIS2_INTF_TO_IMPL(server)->port, svc_path);
    AXIS2_FREE(env->allocator, svc_path);
    if (!url)
    {
        return NULL;
    }
    epr = axis2_endpoint_ref_create(env, axutil_url_to_external_form(url, env));
    axutil_url_free(url, env);
    return epr;
}
예제 #12
0
/**
*  
*   <BinarySecurityToken ID="CertID">KJDSsdlDJjsd=</BinarySecurityToken>
*   <KeyInfo>
*       <SecurityTokenReference>
*           <Reference URI="CertID"/>
*       </SecurityTokenReference>
*   </KeyInfo>
*/
static axis2_status_t
oxs_xml_enc_populate_stref_with_bst(
    const axutil_env_t *env,
    oxs_asym_ctx_t *asym_ctx,
    axiom_node_t *stref_node,
    axiom_node_t *parent)
{
    axiom_node_t *ref_node = NULL;
    axiom_node_t *bst_node = NULL;
    axis2_char_t *bst_data = NULL;
    axis2_char_t *id = NULL;
    axis2_char_t *ref_id = NULL;
    oxs_x509_cert_t *cert = NULL;

    cert = oxs_asym_ctx_get_certificate(asym_ctx, env);
    bst_data = oxs_x509_cert_get_data(cert, env);

    if(!bst_data)
    {
        return AXIS2_FAILURE;
    }
    /*Generate an ID for BST*/
    id = oxs_util_generate_id(env, (axis2_char_t*)OXS_CERT_ID);

    /*Build BinarySecurityToken as a child of parent(wsse:Security)*/
    bst_node = oxs_token_build_binary_security_token_element(env, parent, id,
        OXS_ENCODING_BASE64BINARY, OXS_VALUE_X509V3, bst_data);

    /*Build a Reference to above BST*/
    ref_id = axutil_stracat(env, OXS_LOCAL_REFERENCE_PREFIX, id);
    ref_node = oxs_token_build_reference_element(env, stref_node, ref_id, OXS_VALUE_X509V3);

    return AXIS2_SUCCESS;
}
예제 #13
0
파일: url.c 프로젝트: Denisss025/wsfcpp
AXIS2_EXTERN axutil_url_t *AXIS2_CALL
axutil_url_clone(
    axutil_url_t *url,
    const axutil_env_t *env)
{
    axis2_char_t *temp = NULL;
    axutil_url_t *ret = NULL;
    AXIS2_ENV_CHECK(env, NULL);
    AXIS2_PARAM_CHECK(env->error, url, NULL);

    if(url->path && url->query)
    {
        temp = axutil_stracat(env, url->path, url->query);
    }
    else if(url->path)
    {
        temp = axutil_strdup(env, url->path);
    }
    else if(url->query)
    {
        temp = axutil_strdup(env, url->query);
    }

    ret = axutil_url_create(env, url->protocol, url->host, url->port, url->path);
    if(temp)
    {
        AXIS2_FREE(env->allocator, temp);
    }
    return ret;
}
예제 #14
0
rampart_saml_token_t * AXIS2_CALL
create_saml_token(const axutil_env_t *env)
{
    oxs_sign_ctx_t *sign_ctx = NULL;
	oxs_x509_cert_t *cert = NULL;
	openssl_pkey_t *prv_key = NULL;
	rampart_saml_token_t *saml = NULL;

	axutil_date_time_t *time = NULL;
	saml_assertion_t *assertion = NULL;
	axiom_node_t *node = NULL;
    axis2_char_t *prv_key_file = NULL;
    axis2_char_t *certificate_file = NULL;
    /* 
     * Create a rampart_saml_token_t to give to the Rampart/C 
     * Here the token type is protection token.
     */    
	saml = rampart_saml_token_create(env, NULL, RAMPART_ST_CONFIR_TYPE_HOLDER_OF_KEY);
	time = axutil_date_time_create(env);
	assertion = saml_assertion_create(env);
	if (assertion)	
	{
		saml_assertion_set_minor_version(assertion, env, 1);		
		saml_assertion_set_issue_instant(assertion, env, time);
		saml_assertion_set_issuer(assertion, env, "http://ws.apache.org/rampart/c");	
		saml_assertion_add_condition(assertion, env, create_condition(env));
		saml_assertion_set_not_before(assertion, env, axutil_date_time_create(env));
		saml_assertion_add_statement(assertion, env, create_auth_statement(env, saml));
	}
    /* Load the private key from file*/
    prv_key_file = axutil_stracat(env, axis2c_home, PRIVATE_KEY_FILE);  
    certificate_file = axutil_stracat(env, axis2c_home, CERTIFICATE_FILE);
    prv_key = oxs_key_mgr_load_private_key_from_pem_file(env, prv_key_file, PRIVATE_KEY_PASSWORD);
    cert = oxs_key_mgr_load_x509_cert_from_pem_file(env, certificate_file);

	sign_ctx = oxs_sign_ctx_create(env);
	saml_util_set_sig_ctx_defaults(sign_ctx, env, "AssertionID");
	oxs_sign_ctx_set_private_key(sign_ctx, env, prv_key);
    oxs_sign_ctx_set_certificate(sign_ctx, env, cert);
    saml_assertion_set_signature(assertion, env, sign_ctx);

	node = saml_assertion_to_om(assertion, NULL, env);	 
	rampart_saml_token_set_assertion(saml, env, node);
    rampart_saml_token_set_token_type(saml, env, RAMPART_ST_TYPE_PROTECTION_TOKEN);
	saml_assertion_free(assertion, env);
	return saml;
}
예제 #15
0
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axiom_output_get_next_content_id(
    axiom_output_t * om_output,
    const axutil_env_t * env)
{
    axis2_char_t *uuid = NULL;
    axis2_char_t *temp_str = NULL;
    axis2_char_t *temp_str1 = NULL;
    AXIS2_ENV_CHECK(env, NULL);
    AXIS2_PARAM_CHECK(env->error, om_output, NULL);
    axis2_char_t id[256];
    om_output->next_id++;

    /** free existing id */
    if(om_output->next_content_id)
    {
        AXIS2_FREE(env->allocator, om_output->next_content_id);
        om_output->next_content_id = NULL;
    }

    uuid = axutil_uuid_gen(env);
    if(!uuid)
    {
        return NULL;
    }

    sprintf(id, "%d", om_output->next_id);

    temp_str = axutil_stracat(env, id, ".");
    temp_str1 = axutil_stracat(env, temp_str, uuid);
    om_output->next_content_id = axutil_stracat(env, temp_str1, "@apache.org");
    if(temp_str)
    {
        AXIS2_FREE(env->allocator, temp_str);
        temp_str = NULL;
    }
    if(temp_str1)
    {
        AXIS2_FREE(env->allocator, temp_str1);
        temp_str1 = NULL;
    }
    AXIS2_FREE(env->allocator, uuid);
    return om_output->next_content_id;
}
예제 #16
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_http_out_transport_info_impl_set_content_type(
    axis2_http_out_transport_info_t * http_out_transport_info,
    const axutil_env_t * env,
    const axis2_char_t * content_type)
{
    axis2_char_t *tmp1 = NULL;
    axis2_char_t *tmp2 = NULL;

    AXIS2_PARAM_CHECK(env->error, content_type, AXIS2_FAILURE);
    if(http_out_transport_info->encoding)
    {
        axis2_char_t *charset_pos = axutil_strcasestr(content_type, AXIS2_CHARSET);
        if(!charset_pos)
        {
            /* if "charset" not found in content_type string */
            tmp1 = axutil_stracat(env, content_type, AXIS2_CONTENT_TYPE_CHARSET);
            tmp2 = axutil_stracat(env, tmp1, http_out_transport_info->encoding);
            axis2_http_simple_response_set_header(http_out_transport_info-> response, env,
                axis2_http_header_create(env, AXIS2_HTTP_HEADER_CONTENT_TYPE, tmp2));
            AXIS2_FREE(env->allocator, tmp1);
            AXIS2_FREE(env->allocator, tmp2);
        }
        else
        {
            /* "charset" is found in content_type string */
            axis2_http_simple_response_set_header(http_out_transport_info-> response, env,
                axis2_http_header_create(env, AXIS2_HTTP_HEADER_CONTENT_TYPE, content_type));
        }
    }
    else
    {
        /* no http_out_transport_info->encoding  */
        if(http_out_transport_info->response)
        {
            axis2_http_simple_response_set_header(http_out_transport_info-> response, env,
                axis2_http_header_create(env, AXIS2_HTTP_HEADER_CONTENT_TYPE, content_type));
        }
    }
    return AXIS2_SUCCESS;
}
예제 #17
0
AXIS2_EXTERN axis2_char_t* AXIS2_CALL 
service_admin_util_get_wsdl_for_service(axutil_env_t *env, 
									   axis2_char_t *service_name, 
									   axis2_conf_t *conf)
{
	axis2_transport_in_desc_t *transport_in = axis2_conf_get_transport_in(conf, env, AXIS2_TRANSPORT_ENUM_HTTP);
	
	if(transport_in)
	{
		axis2_endpoint_ref_t *epr = NULL;
		axis2_char_t *address = NULL;
		axis2_transport_receiver_t *receiver = axis2_transport_in_desc_get_recv(transport_in, env);
		if(!receiver)
		{
			AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Transport Receiver Not found ");
			return NULL;
		}
		epr = axis2_transport_receiver_get_epr_for_service(receiver, env, service_name);
		if(!epr)
		{
			AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Endpoint reference null");
			return NULL;
		}
		address = (axis2_char_t*)axis2_endpoint_ref_get_address(epr,env);
		if(address)
		{
			int length = axutil_strlen(address);
			if(address[length -1 ] == '\\')
			{
				address = axutil_stracat(env, address,"?wsdl");
			}else{
					address = axutil_stracat(env, address,"\?wsdl");
			}

		}
		return address;
	}
	return NULL;
}
예제 #18
0
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axutil_dll_desc_create_platform_specific_dll_name(
    axutil_dll_desc_t *dll_desc,
    const axutil_env_t *env,
    const axis2_char_t *class_name)
{
    axis2_char_t *temp_name = NULL;

    AXIS2_ENV_CHECK(env, NULL);

    /* allow config to give a literal lib name since it may want a 
     * versioned lib like "libfoo.so.0" */
    if (axutil_strstr(class_name, AXIS2_LIB_SUFFIX)) {
            /* assume the class_name is the literal lib file name */
            dll_desc->dll_name = axutil_strdup(env,class_name);
            return dll_desc->dll_name;
    }

    temp_name = axutil_stracat(env, AXIS2_LIB_PREFIX, class_name);
    dll_desc->dll_name = axutil_stracat(env, temp_name, AXIS2_LIB_SUFFIX);
    AXIS2_FREE(env->allocator, temp_name);
    return dll_desc->dll_name;
}
예제 #19
0
AXIS2_EXTERN axis2_char_t* AXIS2_CALL
axis2_amqp_util_conf_ctx_get_dual_channel_queue_name(
    axis2_conf_ctx_t* conf_ctx,
    const axutil_env_t* env)
{
    axutil_property_t* property = NULL;
    axis2_char_t* queue_name = NULL;
    axis2_char_t* value = NULL;

    /* Get property */
    property = axis2_conf_ctx_get_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_QUEUE_NAME);
    if(!property) /* Very first call */
    {
        property = axutil_property_create(env);

        axis2_conf_ctx_set_property(conf_ctx, env, AXIS2_AMQP_CONF_CTX_PROPERTY_QUEUE_NAME,
            property);
    }

    /* Get queue name */
    value = (axis2_char_t*)axutil_property_get_value(property, env);

    /* AMQP listener and the sender are the two parties that are
     * interested in the queue. Either party can create the queue.
     * If the queue is already created by one party, "value" is
     * not NULL. If "value" is NULL, that mean the caller of
     * this method is supposed to create the queue */
    if(value)
    {
        queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator, axutil_strlen(value) + 1);
        strcpy(queue_name, value);

        /*axutil_property_set_value(property, env, NULL);*/
    }
    else
    {
        /* Create new queue name */
        queue_name = axutil_stracat(env, AXIS2_AMQP_TEMP_QUEUE_NAME_PREFIX, axutil_uuid_gen(env));

        /* Put queue name in the conf_ctx so that the sender will know */
        axutil_property_set_value(property, env, (void*)queue_name);
    }

    return queue_name;
}
예제 #20
0
파일: qname.c 프로젝트: Denisss025/wsfcpp
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axutil_qname_to_string(
    axutil_qname_t *qname,
    const axutil_env_t *env)
{
    AXIS2_ENV_CHECK(env, NULL);
    if(qname->qname_string)
    {
        return qname->qname_string;
    }

    if(!(qname->namespace_uri) || axutil_strcmp(qname->namespace_uri, "") == 0)
    {
        qname->qname_string = axutil_strdup(env, qname->localpart);
    }
    else if(!(qname->prefix) || axutil_strcmp(qname->prefix, "") == 0)
    {
        axis2_char_t *temp_string1 = NULL;
        temp_string1 = axutil_stracat(env, qname->localpart, "|");
        qname->qname_string = axutil_stracat(env, temp_string1, qname->namespace_uri);
        if(temp_string1)
        {
            AXIS2_FREE(env->allocator, temp_string1);
        }
    }
    else
    {
        axis2_char_t *temp_string1 = NULL;
        axis2_char_t *temp_string2 = NULL;
        axis2_char_t *temp_string3 = NULL;

        temp_string1 = axutil_stracat(env, qname->localpart, "|");
        temp_string2 = axutil_stracat(env, temp_string1, qname->namespace_uri);
        temp_string3 = axutil_stracat(env, temp_string2, "|");
        qname->qname_string = axutil_stracat(env, temp_string3, qname->prefix);

        if(temp_string1)
        {
            AXIS2_FREE(env->allocator, temp_string1);
        }
        if(temp_string2)
        {
            AXIS2_FREE(env->allocator, temp_string2);
        }
        if(temp_string3)
        {
            AXIS2_FREE(env->allocator, temp_string3);
        }
    }
    return qname->qname_string;
}
예제 #21
0
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
axiom_output_get_mime_boundry(
    axiom_output_t * om_output,
    const axutil_env_t * env)
{
    axis2_char_t *uuid = NULL;
    AXIS2_ENV_CHECK(env, NULL);
    AXIS2_PARAM_CHECK(env->error, om_output, NULL);
    if(!om_output->mime_boundary)
    {
        uuid = axutil_uuid_gen(env);

        om_output->mime_boundary = axutil_stracat(env, "MIMEBoundary", uuid);
        if(uuid)
        {
            AXIS2_FREE(env->allocator, uuid);
            uuid = NULL;
        }
    }
    return om_output->mime_boundary;
}
예제 #22
0
axiom_node_t *  AXIS2_CALL
create_key_info(const axutil_env_t *env, rampart_saml_token_t *saml)
{
    axiom_node_t *key_info = NULL;
    oxs_key_t *session_key = NULL;
    axis2_status_t status = AXIS2_FAILURE;
    oxs_asym_ctx_t * asym_ctx = NULL;
    axis2_char_t *key_info_str = NULL;
	oxs_x509_cert_t *cert = NULL;
    /* Set the receiver certificate file. This public key will be used to encrypt the session key.*/
    axis2_char_t *certificate_file = axutil_stracat(env, axis2c_home, RECEIVER_CERTIFICATE_FILE);

    session_key = oxs_key_create(env);
    status = oxs_key_for_algo(session_key, env, NULL);    

    key_info = oxs_token_build_key_info_element(env, NULL);

    /* Create the asym_ctx_t and populate it.*/
    asym_ctx = oxs_asym_ctx_create(env);
    oxs_asym_ctx_set_algorithm(asym_ctx, env, OXS_HREF_RSA_PKCS1);
    oxs_asym_ctx_set_operation(asym_ctx, env,
                               OXS_ASYM_CTX_OPERATION_PUB_ENCRYPT);

	cert = oxs_key_mgr_load_x509_cert_from_pem_file(env, certificate_file);
	if (!cert)
	{
		AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                            "Certificate cannot be loaded");
		return NULL;
	}
	oxs_asym_ctx_set_certificate(asym_ctx, env, cert);
    status = oxs_xml_enc_encrypt_key(env,
                            asym_ctx,
                            key_info,
                            session_key,
                            NULL);
	rampart_saml_token_set_session_key(saml, env, session_key);
    key_info_str = axiom_node_to_string(key_info, env);
    return key_info;
}
예제 #23
0
파일: url.c 프로젝트: Denisss025/wsfcpp
AXIS2_EXTERN axutil_url_t *AXIS2_CALL
axutil_url_create(
    const axutil_env_t *env,
    const axis2_char_t *protocol,
    const axis2_char_t *host,
    const int port,
    const axis2_char_t *path)
{
    axutil_url_t *url = NULL;
    AXIS2_ENV_CHECK(env, NULL);
    AXIS2_PARAM_CHECK(env->error, protocol, NULL);

    if(!protocol || !*protocol || strstr(protocol, "://") || (host && strchr(host, '/')))
    {
        return NULL;
    }

    url = (axutil_url_t *)AXIS2_MALLOC(env->allocator, sizeof(axutil_url_t));

    if(!url)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory");
        return NULL;
    }
    url->protocol = axutil_strdup(env, protocol);
    url->host = NULL;
    url->path = NULL;
    url->server = NULL;
    url->query = NULL;

    if(host)
    {
        url->host = (axis2_char_t *)axutil_strdup(env, host);
        url->port = port;
    }
    else
    {
        url->port = 0;
    }

    /** if the path is not starting with / we have to make it so
     */
    if(path)
    {
        axis2_char_t *params = NULL;
        axis2_char_t *temp = NULL;
        if(path[0] == '/')
        {
            temp = (axis2_char_t *)axutil_strdup(env, path);
        }
        else
        {
            temp = axutil_stracat(env, "/", path);
        }
        params = strchr(temp, '?');
        if(!params)
        {
            params = strchr(temp, '#');
        }
        if(params)
        {
            url->query = (axis2_char_t *)axutil_strdup(env, params);
            *params = '\0';
        }
        url->path = (axis2_char_t *)axutil_strdup(env, temp);
        AXIS2_FREE(env->allocator, temp);
    }

    return url;
}
예제 #24
0
파일: om_text.c 프로젝트: Denisss025/wsfcpp
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_text_serialize(
    axiom_text_t * om_text,
    const axutil_env_t * env,
    axiom_output_t * om_output)
{
    int status = AXIS2_SUCCESS;
    axis2_char_t *attribute_value = NULL;
    const axis2_char_t *text = NULL;
    axiom_xml_writer_t *om_output_xml_writer = NULL;

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

    if(!axiom_text_get_is_binary(om_text, env))
    {
        if(om_text->value)
        {
            status = axiom_output_write(om_output, env, AXIOM_TEXT, 1, axutil_string_get_buffer(
                om_text->value, env));
        }
    }
    else
    {
        om_output_xml_writer = axiom_output_get_xml_writer(om_output, env);
        if(axiom_output_is_optimized(om_output, env) && om_text->optimize)
        {
            if(!(axiom_text_get_content_id(om_text, env)))
            {
                axis2_char_t *content_id = axiom_output_get_next_content_id(om_output, env);
                if(content_id)
                {
                    om_text->content_id = axutil_strdup(env, content_id);
                }
            }

            attribute_value = axutil_stracat(env, "cid:", om_text->content_id);

            /*send binary as MTOM optimised */
            if(om_text->om_attribute)
            {
                axiom_attribute_free(om_text->om_attribute, env);
                om_text->om_attribute = NULL;
            }

            om_text->om_attribute = axiom_attribute_create(env, "href", attribute_value, NULL);

            AXIS2_FREE(env->allocator, attribute_value);
            attribute_value = NULL;

            if(!om_text->is_swa) /* This is a hack to get SwA working */
            {
                axiom_text_serialize_start_part(om_text, env, om_output);
            }
            else
            {
                status = axiom_output_write(om_output, env, AXIOM_TEXT, 1, om_text->content_id);
            }

            axiom_output_write_optimized(om_output, env, om_text);

            axiom_output_write(om_output, env, AXIOM_ELEMENT, 0);
        }
        else
        {
            text = axiom_text_get_text(om_text, env);
            axiom_xml_writer_write_characters(om_output_xml_writer, env, (axis2_char_t *)text);
        }
    }
    return status;
}
예제 #25
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_mime_body_part_write_to_list(
    axiom_mime_body_part_t *mime_body_part,
    const axutil_env_t *env,
    axutil_array_list_t *list)
{
    axutil_hash_index_t *hash_index = NULL;
    const void *key = NULL;
    void *value = NULL;
    axis2_char_t *header_str = NULL;
    axis2_char_t *temp_header_str = NULL;
    int header_str_size = 0;
    axis2_status_t status = AXIS2_FAILURE;
    axiom_mime_part_t *mime_header_part = NULL;

    /* We have the mime headers in the hash with thier keys
     * So first concatenate them to a one string */

    for(hash_index = axutil_hash_first(mime_body_part->header_map, env); hash_index; hash_index
        = axutil_hash_next(env, hash_index))
    {
        axutil_hash_this(hash_index, &key, NULL, &value);
        if(key && value)
        {
            /* First conactenate to the already conacatenated stuff */

            temp_header_str = axutil_stracat(env, header_str, (axis2_char_t *)key);
            if(header_str)
            {
                AXIS2_FREE(env->allocator, header_str);
            }
            header_str = temp_header_str;
            temp_header_str = axutil_stracat(env, header_str, ": ");
            AXIS2_FREE(env->allocator, header_str);
            header_str = temp_header_str;

            /* Add the new stuff */
            temp_header_str = axutil_stracat(env, header_str, (axis2_char_t *)value);
            AXIS2_FREE(env->allocator, header_str);
            header_str = temp_header_str;

            /* Next header will be in a new line. So lets add it */

            temp_header_str = axutil_stracat(env, header_str, AXIS2_CRLF);
            AXIS2_FREE(env->allocator, header_str);
            header_str = temp_header_str;
        }
    }

    /* If there is a data handler that's mean there is an attachment. Attachment
     * will always start after an additional new line . So let's add it .*/

    if(mime_body_part->data_handler)
    {
        temp_header_str = axutil_stracat(env, header_str, AXIS2_CRLF);
        AXIS2_FREE(env->allocator, header_str);
        header_str = temp_header_str;
    }

    if(header_str)
    {
        header_str_size = axutil_strlen(header_str);
    }

    /* Now we have the complete mime_headers string for a particular mime part.
     * First wrap it as a mime_part_t .Then add it to the array list so
     * later through the transport this can be written to the wire. */

    mime_header_part = axiom_mime_part_create(env);

    if(mime_header_part)
    {
        mime_header_part->part = (axis2_byte_t *)header_str;
        mime_header_part->part_size = header_str_size;
        mime_header_part->type = AXIOM_MIME_PART_BUFFER;
    }
    else
    {
        return AXIS2_FAILURE;
    }

    axutil_array_list_add(list, env, mime_header_part);

    /* Then if the data_handler is there let's add the binary data, may be
     * buffer , may be file name and information. 
     */

    if(mime_body_part->data_handler)
    {
        status = axiom_data_handler_add_binary_data(mime_body_part->data_handler, env, list);
        if(status != AXIS2_SUCCESS)
        {
            return status;
        }
    }
    return AXIS2_SUCCESS;
}
예제 #26
0
static axis2_char_t *
axis2_simple_http_svr_conn_read_line(
    axis2_simple_http_svr_conn_t * svr_conn,
    const axutil_env_t * env)
{
    axis2_char_t* str_line = NULL;
    axis2_char_t tmp_buf[2048];
    int read = -1;

    /* peek for 2047 characters to verify whether it contains CRLF character */
    while((read = axutil_stream_peek_socket(svr_conn->stream, env, tmp_buf, 2048 - 1)) > 0)
    {
        axis2_char_t *start = tmp_buf;
        axis2_char_t *end = NULL;
        tmp_buf[read] = AXIS2_ESC_NULL;
        end = strstr(tmp_buf, AXIS2_HTTP_CRLF);
        if(end)
        {
            axis2_char_t *buffer = NULL;
            if(str_line)
            {
                /* header is more than 2048 character. this is not a common case, and not optimized
                 * for performance (reading in a temp buffer and then strcat to get final buffer */
                buffer = tmp_buf;
            }
            else
            {
                /* header is less than 2048 characters, this is the common case. So to improve
                 * the performance, the buffer is malloc and then used to read the stream. */
                buffer = (axis2_char_t *)AXIS2_MALLOC(env->allocator, end - start + 3);
            }

            /* read the data including CRLF (hence the size = end - start + 2) */
            read = axutil_stream_read(svr_conn->stream, env, buffer, end - start + 2);
            if(read > 0)
            {
                buffer[read] = AXIS2_ESC_NULL;

                if(str_line)
                {
                    axis2_char_t* tmp_str_line = NULL;
                    tmp_str_line = axutil_stracat(env, str_line, buffer);
                    if(tmp_str_line)
                    {
                        AXIS2_FREE(env->allocator, str_line);
                        str_line = tmp_str_line;
                    }
                }
                else
                {
                    str_line = buffer;
                }
            }
            else
            {
                /* read returns 0 or negative value, this could be an error */
                if(str_line)
                {
                    AXIS2_FREE(env->allocator, str_line);
                    str_line = NULL;
                }
                else
                {
                    AXIS2_FREE(env->allocator, buffer);
                }
            }
            break;
        }
        else
        {
            /* not reached end yet */
            read = axutil_stream_read(svr_conn->stream, env, tmp_buf, 2048 - 1);
            if(read > 0)
            {
                axis2_char_t* tmp_str_line = NULL;
                tmp_buf[read] = AXIS2_ESC_NULL;
                tmp_str_line = axutil_stracat(env, str_line, tmp_buf);
                if(tmp_str_line)
                {
                    if(str_line)
                    {
                        AXIS2_FREE(env->allocator, str_line);
                    }
                    str_line = tmp_str_line;
                }
            }
        }
    }

    return str_line;
}
static axis2_status_t AXIS2_CALL
axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync(
    axis2_msg_recv_t * msg_recv,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx,
    axis2_msg_ctx_t * new_msg_ctx)
{
    axis2_svc_skeleton_t *svc_obj = NULL;
    axis2_op_ctx_t *op_ctx = NULL;
    axis2_op_t *op_desc = NULL;
    const axis2_char_t *style = NULL;
    axiom_node_t *om_node = NULL;
    axiom_element_t *om_element = NULL;
    axis2_char_t *local_name = NULL;
    axiom_node_t *result_node = NULL;
    axiom_node_t *body_content_node = NULL;
    axiom_element_t *body_content_element = NULL;
    axiom_soap_envelope_t *default_envelope = NULL;
    axiom_soap_body_t *out_body = NULL;
    axiom_soap_header_t *out_header = NULL;
    axiom_soap_fault_t *soap_fault = NULL;
    axiom_node_t *out_node = NULL;
    axis2_status_t status = AXIS2_SUCCESS;
    axis2_bool_t skel_invoked = AXIS2_FALSE;
    const axis2_char_t *soap_ns = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
    int soap_version = AXIOM_SOAP12;
    axiom_namespace_t *env_ns = NULL;
    axiom_node_t *fault_node = NULL;
    axiom_soap_fault_detail_t *fault_detail;
    axis2_bool_t is_fault = AXIS2_FALSE;

    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, new_msg_ctx, AXIS2_FAILURE);

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
        "[axis2]Entry:axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync");

    /* get the implementation class for the Web Service */
    svc_obj = axis2_msg_recv_make_new_svc_obj(msg_recv, env, msg_ctx);

    if(!svc_obj)
    {
        const axis2_char_t *svc_name = NULL;
        axis2_svc_t *svc = axis2_msg_ctx_get_svc(msg_ctx, env);

        if(svc)
        {
            svc_name = axis2_svc_get_name(svc, env);
        }
        else
        {
            svc_name = "unknown";
        }

        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
            "Impl object for service '%s' not set in message receiver. %d :: %s", svc_name,
            env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error));

        status = AXIS2_FAILURE;
    }
    else
    {
        op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
        op_desc = axis2_op_ctx_get_op(op_ctx, env);

        style = axis2_op_get_style(op_desc, env);
        if(0 == axutil_strcmp(AXIS2_STYLE_DOC, style))
        {
            axiom_soap_envelope_t *envelope = NULL;
            axiom_soap_body_t *body = NULL;

            envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
            body = axiom_soap_envelope_get_body(envelope, env);
            om_node = axiom_soap_body_get_base_node(body, env);
            om_element = axiom_node_get_data_element(om_node, env);
            om_node = axiom_node_get_first_element(om_node, env);
        }
        else if(0 == axutil_strcmp(AXIS2_STYLE_RPC, style))
        {
            axiom_soap_envelope_t *envelope = NULL;
            axiom_soap_body_t *body = NULL;
            axiom_node_t *op_node = NULL;
            axiom_element_t *op_element = NULL;

            envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
            body = axiom_soap_envelope_get_body(envelope, env);
            op_node = axiom_soap_body_get_base_node(body, env);
            op_element = axiom_node_get_data_element(op_node, env);
            if(op_element)
            {
                local_name = axiom_element_get_localname(op_element, env);
                if(local_name)
                {
                    axutil_array_list_t *function_arr = NULL;
                    int i = 0;
                    int size = 0;
                    axis2_bool_t matches = AXIS2_FALSE;

                    function_arr = svc_obj->func_array;
                    if(function_arr)
                    {
                        size = axutil_array_list_size(function_arr, env);
                    }

                    for(i = 0; i < size; i++)
                    {
                        axis2_char_t *function_name = NULL;

                        function_name = (axis2_char_t *)axutil_array_list_get(function_arr, env, i);
                        if(!axutil_strcmp(function_name, local_name))
                        {
                            matches = AXIS2_TRUE;

                        }
                    }

                    if(matches)
                    {
                        om_node = axiom_node_get_first_child(op_node, env);
                        om_element = axiom_node_get_data_element(om_node, env);
                    }
                    else
                    {
                        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_OM_ELEMENT_MISMATCH, AXIS2_FAILURE);
                        status = AXIS2_FAILURE;
                    }
                }
                else
                {
                    AXIS2_ERROR_SET(env->error, AXIS2_ERROR_OM_ELEMENT_INVALID_STATE, AXIS2_FAILURE);
                    status = AXIS2_FAILURE;
                }
            }
            else
            {
                AXIS2_ERROR_SET(env->error, AXIS2_ERROR_RPC_NEED_MATCHING_CHILD, AXIS2_FAILURE);
                status = AXIS2_FAILURE;
            }
        }
        else
        {
            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_UNKNOWN_STYLE, AXIS2_FAILURE);
            status = AXIS2_FAILURE;
        }

        if(status == AXIS2_SUCCESS)
        {
            skel_invoked = AXIS2_TRUE;
            result_node = AXIS2_SVC_SKELETON_INVOKE(svc_obj, env, om_node, new_msg_ctx);
        }

        if(result_node)
        {
            if(0 == axutil_strcmp(style, AXIS2_STYLE_RPC))
            {
                axiom_namespace_t *ns = NULL;
                axis2_char_t *res_name = NULL;

                res_name = axutil_stracat(env, local_name, "Response");
                ns = axiom_namespace_create(env, "http://soapenc/", "res");
                if(!ns)
                {
                    status = AXIS2_FAILURE;
                }
                else
                {
                    body_content_element = axiom_element_create(env, NULL, res_name, ns,
                        &body_content_node);
                    axiom_node_add_child(body_content_node, env, result_node);
                }
            }
            else
            {
                body_content_node = result_node;
            }
        }
        else
        {
            axis2_char_t *mep = (axis2_char_t *)axis2_op_get_msg_exchange_pattern(op_desc, env);
            if(axutil_strcmp(mep, AXIS2_MEP_URI_IN_ONLY) && axutil_strcmp(mep,
				AXIS2_MEP_URI_ROBUST_IN_ONLY) && axutil_strcmp(mep, AXIS2_MEP_URI_IN_ONLY_WSDL2) &&						axutil_strcmp(mep, AXIS2_MEP_URI_ROBUST_IN_ONLY_WSDL2))
            {
                status = AXIS2_ERROR_GET_STATUS_CODE(env->error);
                if(status == AXIS2_SUCCESS)
                {
                    axis2_msg_ctx_set_no_content(new_msg_ctx, env, AXIS2_TRUE);
                }
                else
                {
                    axis2_msg_ctx_set_status_code(msg_ctx, env, axis2_msg_ctx_get_status_code(
                        new_msg_ctx, env));
                }
                /* The new_msg_ctx is passed to the service. The status code must
                 * be taken from here and set to the old message context which is
                 * used by the worker when the request processing fails.
                 */
                if(svc_obj->ops->on_fault)
                {
                    fault_node = AXIS2_SVC_SKELETON_ON_FAULT(svc_obj, env, om_node);
                }
                is_fault = AXIS2_TRUE;
            }
            else
            {
                /* If we have a in only message result node is NULL. We create fault only if
                 * an error is set
                 */
                status = AXIS2_ERROR_GET_STATUS_CODE(env->error);
                if(status == AXIS2_SUCCESS)
                {
                    axis2_msg_ctx_set_no_content(new_msg_ctx, env, AXIS2_TRUE);
                }
                else
                {
                    axis2_msg_ctx_set_status_code(msg_ctx, env, axis2_msg_ctx_get_status_code(
                        new_msg_ctx, env));
					if((!axutil_strcmp(mep, AXIS2_MEP_URI_ROBUST_IN_ONLY)) || 
						(!axutil_strcmp(mep, AXIS2_MEP_URI_ROBUST_IN_ONLY_WSDL2)))
                    {
                        /* The new_msg_ctx is passed to the service. The status code must
                         * be taken from here and set to the old message context which is
                         * used by the worker when the request processing fails.
                         */
                        if(svc_obj->ops->on_fault)
                        {
                            fault_node = AXIS2_SVC_SKELETON_ON_FAULT(svc_obj, env, om_node);
                        }
                        is_fault = AXIS2_TRUE;
                    }
                }
            }
        }
    }

    if(msg_ctx && axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
    {
        soap_ns = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; /* default is 1.2 */
        soap_version = AXIOM_SOAP11;
    }

    if(axis2_msg_ctx_get_soap_envelope(new_msg_ctx, env))
    {
        /* service implementation has set the envelope,
         useful when setting a SOAP fault.
         No need to further process */
        return AXIS2_SUCCESS;
    }

    /* create the soap envelope here */
    env_ns = axiom_namespace_create(env, soap_ns, "soapenv");
    if(!env_ns)
    {
        return AXIS2_FAILURE;
    }

    default_envelope = axiom_soap_envelope_create(env, env_ns);
	axiom_namespace_free(env_ns, env);

    if(!default_envelope)
    {
        return AXIS2_FAILURE;
    }

    out_header = axiom_soap_header_create_with_parent(env, default_envelope);
    if(!out_header)
    {
        return AXIS2_FAILURE;
    }

    out_body = axiom_soap_body_create_with_parent(env, default_envelope);
    if(!out_body)
    {
        return AXIS2_FAILURE;
    }

    out_node = axiom_soap_body_get_base_node(out_body, env);
    if(!out_node)
    {
        return AXIS2_FAILURE;
    }

    if(status != AXIS2_SUCCESS || is_fault)
    {
        /* something went wrong. set a SOAP Fault */
        const axis2_char_t *fault_value_str = "soapenv:Sender";
        const axis2_char_t *fault_reason_str = NULL;
        const axis2_char_t *err_msg = NULL;

        if(!skel_invoked)
        {
            if(axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
            {
fault_value_str            =
            AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
            AXIOM_SOAP11_FAULT_CODE_RECEIVER;
        }
        else
        {
            fault_value_str =
            AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
            AXIOM_SOAP12_SOAP_FAULT_VALUE_RECEIVER;
        }
    }

    err_msg = AXIS2_ERROR_GET_MESSAGE(env->error);
    if (err_msg && axutil_strcmp(err_msg, ""))
    {
        if(!axutil_strcmp(err_msg, "No Error"))
        {
            fault_reason_str = "An error has occurred, but could not determine exact details";
        }
        else
        {
            fault_reason_str = err_msg;
        }
    }
    else
    {
        fault_reason_str = "An error has occurred, but could not determine exact details";
    }

    soap_fault = axiom_soap_fault_create_default_fault(env, out_body, fault_value_str,
        fault_reason_str, soap_version);

    if (fault_node)
    {
        axiom_node_t *fault_detail_node = NULL;
        axis2_char_t *om_str = NULL;

        fault_detail = axiom_soap_fault_detail_create_with_parent(env, soap_fault);
        fault_detail_node = axiom_soap_fault_detail_get_base_node(fault_detail, env);

        om_str = axiom_node_to_string(fault_detail_node, env);
        if (om_str)
        {
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "fault_detail:%s", om_str);
            AXIS2_FREE(env->allocator, om_str);
        }

        axiom_soap_fault_detail_add_detail_entry(fault_detail, env, fault_node);
    }
}

if (body_content_node)
{
    axiom_node_add_child(out_node, env, body_content_node);
    status = axis2_msg_ctx_set_soap_envelope(new_msg_ctx, env, default_envelope);
}
else if (soap_fault)
{
    axis2_msg_ctx_set_soap_envelope(new_msg_ctx, env, default_envelope);
    status = AXIS2_SUCCESS;
}
else
{
    /* we should free the memory as the envelope is not used, one way case */
    axiom_soap_envelope_free(default_envelope, env);
    default_envelope = NULL;
}

AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
    "[axis2]Exit:axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync");

return status;
}
예제 #28
0
axis2_status_t AXIS2_CALL
wsf_xml_msg_recv_invoke_business_logic_sync(
        axis2_msg_recv_t * msg_recv,
        const axutil_env_t * env,
        axis2_msg_ctx_t * in_msg_ctx,
        axis2_msg_ctx_t * out_msg_ctx)
{

    axis2_op_ctx_t *op_ctx = NULL;
    axis2_op_t *op_desc = NULL;

    axiom_namespace_t *env_ns = NULL;

    int soap_version = AXIOM_SOAP12;
    axis2_status_t status = AXIS2_SUCCESS;
    axis2_bool_t skel_invoked = AXIS2_FALSE;

    const axis2_char_t *style = NULL;
    axis2_char_t *local_name = NULL;
    axis2_char_t *soap_ns = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
    axis2_char_t *operation_name = NULL;
    char *classname = NULL;

    axutil_property_t *svc_info_prop = NULL;
    axutil_property_t *req_info_prop = NULL;
    wsf_svc_info_t *svc_info = NULL;
    wsf_request_info_t *req_info = NULL;

    /** store in_msg_ctx envelope */
    axiom_soap_envelope_t *envelope = NULL;
    axiom_soap_body_t *body = NULL;
    axiom_node_t *in_body_node = NULL;

    /* store out_msg_ctx envelope */
    axiom_soap_envelope_t *default_envelope = NULL;
    axiom_soap_body_t *out_body = NULL;
    axiom_soap_header_t *out_header = NULL;
    axiom_soap_fault_t *out_soap_fault = NULL;

    axiom_node_t *result_node = NULL;

    axiom_node_t *out_body_content_node = NULL;
    axiom_element_t *out_body_content_element = NULL;
    axiom_node_t *out_node = NULL;

    zval **output_headers_zval = NULL;

    TSRMLS_FETCH();

    AXIS2_PARAM_CHECK(env->error, in_msg_ctx, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, out_msg_ctx, AXIS2_FAILURE);

    op_ctx = axis2_msg_ctx_get_op_ctx(in_msg_ctx, env);
    op_desc = axis2_op_ctx_get_op(op_ctx, env);
    style = axis2_op_get_style(op_desc, env);

    envelope = axis2_msg_ctx_get_soap_envelope(in_msg_ctx, env);

    body = axiom_soap_envelope_get_body(envelope, env);

    in_body_node = axiom_soap_body_get_base_node(body, env);


    if (0 == axutil_strcmp(AXIS2_STYLE_DOC, style))
    {
        local_name = wsf_xml_msg_recv_get_method_name(in_msg_ctx, env);
        if (!local_name)
        {
            return AXIS2_FAILURE;
        }
    } else if (0 == axutil_strcmp(AXIS2_STYLE_RPC, style))
    {

        axiom_node_t *op_node = NULL;
        axiom_element_t *op_element = NULL;
        op_node = axiom_node_get_first_child(in_body_node, env);
        if (!op_node)
        {
            return AXIS2_FAILURE;
        }
        op_element = axiom_node_get_data_element(op_node, env);

        if (!op_element)
        {
            return AXIS2_FAILURE;
        }
        local_name = axiom_element_get_localname(op_element, env);
        if (!local_name)
        {
            return AXIS2_FAILURE;
        }
    }

    /** set soap version and soap namespace to local variables */
    if (in_msg_ctx && axis2_msg_ctx_get_is_soap_11(in_msg_ctx, env))
    {
        soap_ns = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; /* default is 1.2 */
        soap_version = AXIOM_SOAP11;
    }

    svc_info_prop = axis2_msg_ctx_get_property(in_msg_ctx, env, WSF_SVC_INFO);
    if (svc_info_prop)
    {
        svc_info = (wsf_svc_info_t *) axutil_property_get_value(svc_info_prop, env);
        if (svc_info)
        {
            operation_name = axutil_hash_get(svc_info->ops_to_functions, local_name,
                    AXIS2_HASH_KEY_STRING);
            if (!operation_name)
            {
                return AXIS2_FAILURE;
            }
        } else
        {
            return AXIS2_FAILURE;
        }
        if (svc_info->ops_to_classes)
        {
            classname = axutil_hash_get(svc_info->ops_to_classes, local_name, AXIS2_HASH_KEY_STRING);
        }
    }

    req_info_prop = axis2_msg_ctx_get_property(in_msg_ctx, env, WSF_REQ_INFO);
    if (req_info_prop)
    {
        req_info = (wsf_request_info_t *) axutil_property_get_value(req_info_prop, env);

        if (axis2_msg_ctx_get_doing_rest(in_msg_ctx, env))
        {
            axis2_op_t *op = NULL;
            axiom_node_t *body_child_node = NULL;
            axiom_element_t *body_child = NULL;
            int i = 0;

            body_child_node = axiom_node_get_first_child(in_body_node, env);

            if (!body_child_node)
            {
                op = axis2_msg_ctx_get_op(in_msg_ctx, env);
                if (op)
                {
                    body_child = axiom_element_create_with_qname(env, NULL,
                            axis2_op_get_qname(op, env), &body_child_node);
                    axiom_soap_body_add_child(body, env, body_child_node);
                }
            }
            if (req_info->param_keys && req_info->param_values)
            {
                int i = 0;
                for (i = 0; i < axutil_array_list_size(req_info->param_keys, env); i++)
                {
                    axiom_node_t *node = NULL;
                    axiom_element_t *element = NULL;

                    axis2_char_t *param_key = NULL;
                    axis2_char_t *param_value = NULL;

                    param_key = axutil_array_list_get(req_info->param_keys, env, i);
                    param_value = axutil_array_list_get(req_info->param_values, env, i);

                    element = axiom_element_create(env, NULL, param_key,
                            NULL, &node);
                    axiom_element_set_text(element, env, param_value, node);
                    axiom_node_add_child(body_child_node, env, node);

                    AXIS2_FREE(env->allocator, param_key);
                    AXIS2_FREE(env->allocator, param_value);
                }
                axutil_array_list_free(req_info->param_keys, env);
                axutil_array_list_free(req_info->param_values, env);
            }
        }
    }

    if (svc_info->ht_op_params)
    {
        zval **tmp;
        char *function_type = NULL;
        if (zend_hash_find(svc_info->ht_op_params,
                operation_name, strlen(operation_name) + 1,
                (void **) & tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_STRING)
        {
            function_type = Z_STRVAL_PP(tmp);

            if (strcmp(function_type, WSF_MIXED) == 0)
            {
                result_node = wsf_xml_msg_recv_invoke_mixed(env, svc_info,
                        in_msg_ctx, out_msg_ctx, operation_name,
                        classname, &output_headers_zval TSRMLS_CC);

            } else if (strcmp(function_type, WSF_WSMESSAGE) == 0)
            {
                result_node = wsf_xml_msg_recv_invoke_wsmsg(env, operation_name,
                        in_msg_ctx, out_msg_ctx, svc_info, classname, req_info->content_type TSRMLS_CC);
            }
        }
    } else
    {
        /* this is where the default value for opParam is set,
           If the wsdl option is set go for the MIXED mode by default */
		if (svc_info->wsdl == NULL || svc_info->omit_wsdl)
        {
            result_node = wsf_xml_msg_recv_invoke_wsmsg(env, operation_name,
                    in_msg_ctx, out_msg_ctx, svc_info, classname, req_info->content_type TSRMLS_CC);
        } else
        {
            result_node = wsf_xml_msg_recv_invoke_mixed(env, svc_info,
                    in_msg_ctx, out_msg_ctx, operation_name,
                    classname, &output_headers_zval TSRMLS_CC);
        }
    }
    if (!result_node)
    {
        status = AXIS2_ERROR_GET_STATUS_CODE(env->error);
    } else
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "Response node is not null");
    }

    if (result_node)
    {
        if (0 == axutil_strcmp(style, AXIS2_STYLE_RPC))
        {
            axiom_namespace_t *ns = NULL;
            axis2_char_t *response_name = NULL;

            response_name = axutil_stracat(env, local_name, "Response");
            ns = axiom_namespace_create(env, "http://soapenc/", "res");
            if (!ns)
            {
                return AXIS2_FAILURE;
            }

            out_body_content_element = axiom_element_create(env, NULL, response_name,
                    ns, &out_body_content_node);
            axiom_node_add_child(out_body_content_node, env, result_node);

        } else
        {
            out_body_content_node = result_node;
        }
    }

    if (axis2_msg_ctx_get_soap_envelope(out_msg_ctx, env))
    {
        /* service implementation has set the envelope, useful when setting a SOAP fault.
           No need to further process */
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "soap fault is set");
        return AXIS2_SUCCESS;
    }

    /* create the soap envelope here */
    env_ns = axiom_namespace_create(env, soap_ns, AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX);
    if (!env_ns)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] error seting the namespces for the "
                AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX);
        return AXIS2_FAILURE;
    }

    default_envelope = axiom_soap_envelope_create(env, env_ns);

    if (!default_envelope)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "failed in creating the response soap envelope");
        return AXIS2_FAILURE;
    }


    out_body = axiom_soap_body_create_with_parent(env, default_envelope);
    if (!out_body)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] failed in creating the response soap body");
        return AXIS2_FAILURE;
    }

    out_header = axiom_soap_header_create_with_parent(env, default_envelope);
    if (!out_header)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, WSF_PHP_LOG_PREFIX "failed in creating the response soap headers");
        return AXIS2_FAILURE;
    }

    if (output_headers_zval)
    {
        axiom_node_t *header_base_node = NULL;

        HashPosition pos;
        zval **param;
        char *header_str;
        axiom_node_t *header_node;

        for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(output_headers_zval), &pos);
                zend_hash_get_current_data_ex(Z_ARRVAL_PP(output_headers_zval),
                (void **) & param, &pos) == SUCCESS;
                zend_hash_move_forward_ex(Z_ARRVAL_PP(output_headers_zval), &pos))
        {

            if (Z_TYPE_PP(param) == IS_STRING)
            {

                header_base_node = axiom_soap_header_get_base_node(out_header, env);

                if (header_base_node)
                {
                    header_str = Z_STRVAL_PP(param);
                    header_node = wsf_util_deserialize_buffer(env, header_str);
                    axiom_node_add_child(header_base_node, env, header_node);
                } else
                {
                    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] failed in retrieving the response soap headers node");
                    return AXIS2_FAILURE;
                }
            }
        }
    }

    out_node = axiom_soap_body_get_base_node(out_body, env);
    if (!out_node)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[wsfphp] failed in retrieving the response soap body node");
        return AXIS2_FAILURE;
    }

    if (status != AXIS2_SUCCESS)
    {
        /* something went wrong, set a SOAP Fault */
        axis2_char_t *fault_value_str =
                AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":" AXIOM_SOAP12_SOAP_FAULT_VALUE_SENDER;

        axis2_char_t *fault_reason_str = NULL;
        axis2_char_t *err_msg = NULL;

        if (!skel_invoked)
            fault_value_str = AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":" AXIOM_SOAP12_SOAP_FAULT_VALUE_RECEIVER;
        ;

        err_msg = (char *) AXIS2_ERROR_GET_MESSAGE(env->error);

        if (err_msg)
        {
            fault_reason_str = err_msg;
        } else
        {
            fault_reason_str = "Error occurred while processing SOAP message";
        }

        out_soap_fault = axiom_soap_fault_create_default_fault(env, out_body,
                fault_value_str, fault_reason_str, soap_version);
    }

    if (out_body_content_node)
    {
        axiom_node_add_child(out_node, env, out_body_content_node);
        status = axis2_msg_ctx_set_soap_envelope(out_msg_ctx, env,
                default_envelope);
    } else if (out_soap_fault)
    {
        axis2_msg_ctx_set_soap_envelope(out_msg_ctx, env, default_envelope);
        status = AXIS2_FAILURE; /* if there is a failure we have to return a failure code */
    } else
    {
        /* we should free the memory as the envelope is not used, one way case */
        axiom_soap_envelope_free(default_envelope, env);
        default_envelope = NULL;
    }
    return AXIS2_SUCCESS;
}
예제 #29
0
int main(int argc, char** argv)
{
    const axutil_env_t *env = NULL;
    const axis2_char_t *address = NULL;
    const axis2_char_t *client_home = NULL;
    axis2_char_t *file_name = NULL;
    axis2_char_t *policy_file = NULL;
    axis2_endpoint_ref_t* endpoint_ref = NULL;
    axis2_options_t *options = NULL;
    axis2_svc_client_t* svc_client = NULL;
    axiom_node_t *payload = NULL;
    axiom_node_t *ret_node = NULL;
    axis2_status_t status = AXIS2_FAILURE;
    neethi_policy_t *policy = NULL;
    rampart_config_t* client_config = NULL;
    axutil_property_t *property = NULL;
    rampart_saml_token_t *saml = NULL;
    axiom_node_t *assertion = NULL;
	/* Set up the environment */
    env = axutil_env_create_all("echo.log", AXIS2_LOG_LEVEL_TRACE);

    /* Set end-point-reference of echo service */
    address = "http://localhost:9090/axis2/services/echo";
    if (argc > 2)
    {
        address = argv[1];
        client_home = argv[2];
        printf("Using endpoint : %s\n", address);
        printf("Using client_home : %s\n", client_home);
    }

    if ((axutil_strcmp(argv[1], "-h") == 0) || (axutil_strcmp(argv[1], "--help") == 0))
    {
        printf("Usage : %s [endpoint_url] [client_home]\n", argv[0]);
        printf("use -h for help\n");
        return 0;
    }

    /* Create end-point-reference with given address */
    endpoint_ref = axis2_endpoint_ref_create(env, address);

    /* Setup options */
    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);
    axis2_options_set_action(options, env,
            "http://example.com/ws/2004/09/policy/Test/EchoRequest");
    /*axis2_options_set_action(options, env,
            "urn:echo");*/


    /*If the client home is not specified, use the AXIS2C_HOME*/
    if (!client_home)
    {
        client_home = AXIS2_GETENV("AXIS2C_HOME");
        printf("\nNo client_home specified. Using default %s", client_home);
    }

    /* Create service client */
    printf("client_home= %s", client_home);
    svc_client = axis2_svc_client_create(env, client_home);
    if (!svc_client)
    {
        printf("Error creating service client\n");
        return -1;
    }

    client_config = rampart_config_create(env);
    if(!client_config)
    {
        printf("Cannot create rampart config\n");
        return 0;
    }
    assertion = create_saml_assertion(env);
    saml = rampart_saml_token_create(env, assertion, RAMPART_ST_CONFIR_TYPE_SENDER_VOUCHES);
	rampart_saml_token_set_token_type(saml, env, RAMPART_ST_TYPE_SIGNED_SUPPORTING_TOKEN);
    rampart_config_add_saml_token(client_config, env, saml);

    property = axutil_property_create_with_args(env, AXIS2_SCOPE_REQUEST ,
        AXIS2_TRUE, (void *)rampart_config_free, client_config);
    axis2_options_set_property(options, env, RAMPART_CLIENT_CONFIGURATION, property);

    /* Set service client options */
    axis2_svc_client_set_options(svc_client, env, options);

    /*We need to specify the client's policy file location*/
    if(client_home)
    {
        file_name = axutil_stracat(env, client_home, AXIS2_PATH_SEP_STR);
        policy_file = axutil_stracat(env, file_name, "policy.xml" );
        AXIS2_FREE(env->allocator, file_name);
        file_name = NULL;        
    }else{
        printf("Client Home not Specified\n");
        printf("echo client invoke FAILED!\n");
        return 0;
    }
    /*Create the policy, from file*/   
    policy = neethi_util_create_policy_from_file(env, policy_file);
    if(!policy)
    {
        printf("\nPolicy creation failed from the file. %s\n", policy_file);
    }
	if(policy_file){
        AXIS2_FREE(env->allocator, policy_file);
        policy_file = NULL;
    }

    status = axis2_svc_client_set_policy(svc_client, env, policy);

    if(status == AXIS2_FAILURE)
    {
        printf("Policy setting failed\n");
    }
    
    /* Build the SOAP request message payload using OM API.*/
    payload = build_om_payload_for_echo_svc(env);
    
    /*If not engaged in the client's axis2.xml, uncomment this line*/
    axis2_svc_client_engage_module(svc_client, env, "rampart");
    
    /* Send request */
    ret_node = axis2_svc_client_send_receive(svc_client, env, payload);


    if (axis2_svc_client_get_last_response_has_fault(svc_client, env))
    {
        axiom_soap_envelope_t *soap_envelope = NULL;
        axiom_soap_body_t *soap_body = NULL;
        axiom_soap_fault_t *soap_fault = NULL;

        printf ("\nResponse has a SOAP fault\n");
        soap_envelope =
            axis2_svc_client_get_last_response_soap_envelope(svc_client, env);
        if (soap_envelope)
            soap_body = axiom_soap_envelope_get_body(soap_envelope, env);
        if (soap_body)
            soap_fault = axiom_soap_body_get_fault(soap_body, env);
        if (soap_fault)
        {
            printf("\nReturned SOAP fault: %s\n",
            axiom_node_to_string(axiom_soap_fault_get_base_node(soap_fault,env),
                env));
        }
            printf("echo client invoke FAILED!\n");
            return -1;
    }
    
    if (ret_node)
    {
        axis2_char_t *om_str = NULL;
        om_str = axiom_node_to_string(ret_node, env);
        if (om_str)
        {
            printf("\nReceived OM : %s\n", om_str);
        }
        printf("\necho client invoke SUCCESSFUL!\n");
        AXIS2_FREE(env->allocator, om_str);
        ret_node = NULL;
    }
    else
    {
        printf("echo client invoke FAILED!\n");
        return -1;
    }

    if (svc_client)
    {
        axis2_svc_client_free(svc_client, env);
        svc_client = NULL;
    }
    if (env)
    {
        axutil_env_free((axutil_env_t *) env);
        env = NULL;
    }
    
    return 0;
}
예제 #30
0
axis2_status_t AXIS2_CALL
axis2_libcurl_send(
    axis2_libcurl_t *data,
    axiom_output_t * om_output,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx,
    axiom_soap_envelope_t * out,
    const axis2_char_t * str_url,
    const axis2_char_t * soap_action)
{
    struct curl_slist *headers = NULL;
    axiom_soap_body_t *soap_body;
    axis2_bool_t is_soap = AXIS2_TRUE;
    axis2_bool_t send_via_get = AXIS2_FALSE;
    axis2_bool_t send_via_head = AXIS2_FALSE;
    axis2_bool_t send_via_put = AXIS2_FALSE;
    axis2_bool_t send_via_delete = AXIS2_FALSE;
    axis2_bool_t doing_mtom = AXIS2_FALSE;
    axiom_node_t *body_node = NULL;
    axiom_node_t *data_out = NULL;
    axutil_property_t *method = NULL;
    axis2_char_t *method_value = NULL;
    axiom_xml_writer_t *xml_writer = NULL;
    axis2_char_t *buffer = NULL;
    unsigned int buffer_size = 0;
    int content_length = -1;
    axis2_char_t *content_type = NULL;
    /*axis2_char_t *content_len = AXIS2_HTTP_HEADER_CONTENT_LENGTH_; */
    const axis2_char_t *char_set_enc = NULL;
    axis2_char_t *content = AXIS2_HTTP_HEADER_CONTENT_TYPE_;
    axis2_char_t *soap_action_header = AXIS2_HTTP_HEADER_SOAP_ACTION_;
    axutil_stream_t *in_stream;
    axutil_property_t *trans_in_property;
    axutil_string_t *char_set_enc_str;
    axis2_byte_t *output_stream = NULL;
    int output_stream_size = 0;
    CURL *handler;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_conf_t *conf = NULL;
    axis2_transport_out_desc_t *trans_desc = NULL;
    axutil_param_t *write_xml_declaration_param = NULL;
    axutil_hash_t *transport_attrs = NULL;
    axis2_bool_t write_xml_declaration = AXIS2_FALSE;
    axutil_property_t *property;
    int *response_length = NULL;
    axis2_http_status_line_t *status_line = NULL;
    axis2_char_t *status_line_str = NULL;
    axis2_char_t *tmp_strcat = NULL;
    int status_code = 0;

    AXIS2_PARAM_CHECK(env->error, data, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, data->handler, AXIS2_FAILURE);

    handler = data->handler;
    curl_easy_reset(handler);
    curl_easy_setopt(handler, CURLOPT_ERRORBUFFER, data->errorbuffer);
    headers = curl_slist_append(headers, AXIS2_HTTP_HEADER_USER_AGENT_AXIS2C);
    headers = curl_slist_append(headers, AXIS2_HTTP_HEADER_ACCEPT_);
    headers = curl_slist_append(headers, AXIS2_HTTP_HEADER_EXPECT_);

    if(AXIS2_FAILURE == axis2_libcurl_set_options(handler, env, msg_ctx))
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[axis2libcurl]Setting options in Libcurl failed");
        return AXIS2_FAILURE;
    }

    if (AXIS2_TRUE == axis2_msg_ctx_get_doing_rest(msg_ctx, env))
    {
        is_soap = AXIS2_FALSE;
    }
    else
    {
        is_soap = AXIS2_TRUE;
    }

    if (!is_soap)
    {
        soap_body = axiom_soap_envelope_get_body(out, env);
        if (!soap_body)
        {
            AXIS2_HANDLE_ERROR(env,
                AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL,
                AXIS2_FAILURE);
            return AXIS2_FAILURE;
        }

        body_node = axiom_soap_body_get_base_node(soap_body, env);
        if (!body_node)
        {
            AXIS2_HANDLE_ERROR(env,
                AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL,
                AXIS2_FAILURE);

            return AXIS2_FAILURE;
        }
        data_out = axiom_node_get_first_element(body_node, env);

        method = (axutil_property_t *) axis2_msg_ctx_get_property(msg_ctx, env,
            AXIS2_HTTP_METHOD);

        if (method)
        {
            method_value =
            (axis2_char_t *) axutil_property_get_value(method, env);
        }

        /* The default is POST */
        if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_GET))
        {
            send_via_get = AXIS2_TRUE;
        }
        else if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_HEAD))
        {
            send_via_head = AXIS2_TRUE;
        }
        else if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_PUT))
        {
            send_via_put = AXIS2_TRUE;
        }
        else if (method_value && 0 == axutil_strcmp(method_value, AXIS2_HTTP_DELETE))
        {
            send_via_delete = AXIS2_TRUE;
        }
    }

    conf_ctx = axis2_msg_ctx_get_conf_ctx (msg_ctx, env);
    if (conf_ctx)
    {
        conf = axis2_conf_ctx_get_conf (conf_ctx, env);
    }

    if (conf)
    {
        trans_desc = axis2_conf_get_transport_out (conf,
            env, AXIS2_TRANSPORT_ENUM_HTTP);
    }

    if (trans_desc)
    {
        write_xml_declaration_param =
        axutil_param_container_get_param
        (axis2_transport_out_desc_param_container (trans_desc, env), env,
            AXIS2_XML_DECLARATION);
    }

    if (write_xml_declaration_param)
    {
        transport_attrs =
        axutil_param_get_attributes (write_xml_declaration_param, env);
        if (transport_attrs)
        {
            axutil_generic_obj_t *obj = NULL;
            axiom_attribute_t *write_xml_declaration_attr = NULL;
            axis2_char_t *write_xml_declaration_attr_value = NULL;

            obj = axutil_hash_get (transport_attrs, AXIS2_ADD_XML_DECLARATION,
                AXIS2_HASH_KEY_STRING);
            if (obj)
            {
                write_xml_declaration_attr = (axiom_attribute_t *)
                axutil_generic_obj_get_value (obj,
                    env);
            }
            if (write_xml_declaration_attr)
            {
                write_xml_declaration_attr_value =
                axiom_attribute_get_value (write_xml_declaration_attr, env);
            }
            if (write_xml_declaration_attr_value &&
                0 == axutil_strcasecmp (write_xml_declaration_attr_value,
                    AXIS2_VALUE_TRUE))
            {
                write_xml_declaration = AXIS2_TRUE;
            }
        }
    }

    if (write_xml_declaration)
    {
        axiom_output_write_xml_version_encoding (om_output, env);
    }

    if (!send_via_get && !send_via_head && !send_via_delete)
    {
        xml_writer = axiom_output_get_xml_writer(om_output, env);

        char_set_enc_str = axis2_msg_ctx_get_charset_encoding(msg_ctx, env);

        if (!char_set_enc_str)
        {
            char_set_enc = AXIS2_DEFAULT_CHAR_SET_ENCODING;
        }
        else
        {
            char_set_enc = axutil_string_get_buffer(char_set_enc_str, env);
        }

        if (!send_via_put && is_soap)
        {
            doing_mtom = axis2_msg_ctx_get_doing_mtom(msg_ctx, env);

            axiom_output_set_do_optimize(om_output, env, doing_mtom);
            axiom_soap_envelope_serialize(out, env, om_output, AXIS2_FALSE);
            if (AXIS2_TRUE == axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
            {
                if (AXIS2_ESC_DOUBLE_QUOTE != *soap_action)
                {
                    axis2_char_t *tmp_soap_action = NULL;
                    tmp_soap_action =
                    AXIS2_MALLOC(env->allocator,
                        (axutil_strlen(soap_action) +
                            5) * sizeof(axis2_char_t));
                    sprintf(tmp_soap_action, "\"%s\"", soap_action);
                    tmp_strcat = axutil_stracat(env, soap_action_header,tmp_soap_action);
                    headers = curl_slist_append(headers, tmp_strcat);
                    AXIS2_FREE(env->allocator, tmp_strcat);
                    AXIS2_FREE(env->allocator, tmp_soap_action);
                }
                else
                {
                    tmp_strcat = axutil_stracat(env, soap_action_header, soap_action);
                    headers = curl_slist_append(headers, tmp_strcat );
                    AXIS2_FREE(env->allocator, tmp_strcat);
                }
            }

            if (doing_mtom)
            {
                /*axiom_output_flush(om_output, env, &output_stream,
                 &output_stream_size);*/
                axiom_output_flush(om_output, env);
                content_type =
                (axis2_char_t *) axiom_output_get_content_type(om_output,
                    env);
                if (AXIS2_TRUE != axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
                {
                    if (axutil_strcmp(soap_action, ""))
                    {
                        /* handle SOAP action for SOAP 1.2 case */
                        axis2_char_t *temp_content_type = NULL;
                        temp_content_type = axutil_stracat (env,
                            content_type,
                            AXIS2_CONTENT_TYPE_ACTION);
                        content_type = temp_content_type;
                        temp_content_type = axutil_stracat (env,
                            content_type,
                            soap_action);
                        AXIS2_FREE (env->allocator, content_type);
                        content_type = temp_content_type;
                        temp_content_type =
                        axutil_stracat (env, content_type,
                            AXIS2_ESC_DOUBLE_QUOTE_STR);
                        AXIS2_FREE (env->allocator, content_type);
                        content_type = temp_content_type;
                    }
                }
            }
            else if (AXIS2_TRUE == axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
            {
                axis2_char_t *temp_content_type = NULL;
                content_type =
                (axis2_char_t *) AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML;
                content_type = axutil_stracat(env, content_type,
                    AXIS2_CONTENT_TYPE_CHARSET);
                temp_content_type =
                axutil_stracat(env, content_type, char_set_enc);
                AXIS2_FREE(env->allocator, content_type);
                content_type = temp_content_type;
            }
            else
            {
                axis2_char_t *temp_content_type = NULL;
                content_type =
                (axis2_char_t *) AXIS2_HTTP_HEADER_ACCEPT_APPL_SOAP;
                content_type = axutil_stracat(env, content_type,
                    AXIS2_CONTENT_TYPE_CHARSET);
                temp_content_type =
                axutil_stracat(env, content_type, char_set_enc);
                AXIS2_FREE(env->allocator, content_type);
                content_type = temp_content_type;
                if (axutil_strcmp(soap_action, ""))
                {
                    temp_content_type =
                    axutil_stracat(env, content_type,
                        AXIS2_CONTENT_TYPE_ACTION);
                    AXIS2_FREE(env->allocator, content_type);
                    content_type = temp_content_type;
                    temp_content_type =
                    axutil_stracat(env, content_type, soap_action);
                    AXIS2_FREE(env->allocator, content_type);
                    content_type = temp_content_type;
                }
                temp_content_type = axutil_stracat(env, content_type,
                    AXIS2_SEMI_COLON_STR);
                AXIS2_FREE(env->allocator, content_type);
                content_type = temp_content_type;
            }
        }
        else if (is_soap)
        {
            AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "Attempt to send SOAP"
                "message using HTTP PUT failed");
            return AXIS2_FAILURE;
        }
        else
        {
            axutil_property_t *content_type_property = NULL;
            axutil_hash_t *content_type_hash = NULL;
            axis2_char_t *content_type_value = NULL;

            axiom_node_serialize(data_out, env, om_output);
            content_type_property =
            (axutil_property_t *)
            axis2_msg_ctx_get_property(msg_ctx, env,
                AXIS2_USER_DEFINED_HTTP_HEADER_CONTENT_TYPE);

            if (content_type_property)
            {
                content_type_hash =
                (axutil_hash_t *)
                axutil_property_get_value(content_type_property, env);

                if (content_type_hash)
                {
                    content_type_value =
                    (char *) axutil_hash_get(content_type_hash,
                        AXIS2_HTTP_HEADER_CONTENT_TYPE,
                        AXIS2_HASH_KEY_STRING);
                }
            }

            if (content_type_value)
            {
                content_type = content_type_value;
            }
            else
            {
                content_type = axutil_strdup(env,AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML);
            }

        }

        buffer = axiom_xml_writer_get_xml(xml_writer, env);
        if (!doing_mtom)
        {
            buffer_size = axiom_xml_writer_get_xml_size(xml_writer, env);
        }
        else
        buffer_size = output_stream_size;
        {
            /*
             * Curl calculates the content-length automatically.
             * This commented section is not only unnecessary,
             * it interferes with authentication.
             *
             * NTLM, for example, will send an empty request
             * first (no body) to get the auth challenge
             * before resending with actual content.
             */
            /*char tmp_buf[10];
            sprintf(tmp_buf, "%d", buffer_size);
            tmp_strcat = axutil_stracat(env, content_len, tmp_buf);
            headers = curl_slist_append(headers, tmp_strcat);
            AXIS2_FREE(env->allocator, tmp_strcat);
            tmp_strcat = NULL;*/

            tmp_strcat = axutil_stracat(env, content, content_type);
            headers = curl_slist_append(headers, tmp_strcat);
            AXIS2_FREE(env->allocator, tmp_strcat);
            tmp_strcat = NULL;
        }

        if (!doing_mtom)
        {
            curl_easy_setopt(handler, CURLOPT_POSTFIELDSIZE, buffer_size);
            curl_easy_setopt(handler, CURLOPT_POSTFIELDS, buffer);
        }
        else
        {
            curl_easy_setopt(handler, CURLOPT_POSTFIELDSIZE,
                output_stream_size);
            curl_easy_setopt(handler, CURLOPT_POSTFIELDS, output_stream);
        }

        if (send_via_put)
        {
            curl_easy_setopt(handler, CURLOPT_CUSTOMREQUEST, AXIS2_HTTP_PUT);
        }
        curl_easy_setopt(handler, CURLOPT_URL, str_url);
    }
    else
    {
        axis2_char_t *request_param;
        axis2_char_t *url_encode;
        request_param =
        (axis2_char_t *) axis2_http_sender_get_param_string(NULL, env,
            msg_ctx);
        url_encode = axutil_strcat(env, str_url, AXIS2_Q_MARK_STR,
            request_param, NULL);
        if (send_via_get)
        {
            curl_easy_setopt(handler, CURLOPT_HTTPGET, 1);
        }
        else if (send_via_head)
        {
            curl_easy_setopt(handler, CURLOPT_NOBODY, 1);
        }
        else if (send_via_delete)
        {
            curl_easy_setopt(handler, CURLOPT_CUSTOMREQUEST, AXIS2_HTTP_DELETE);
        }
        curl_easy_setopt(handler, CURLOPT_URL, url_encode);
    }

    {
        axis2_bool_t manage_session;
        manage_session = axis2_msg_ctx_get_manage_session(msg_ctx, env);
        if (manage_session == AXIS2_TRUE)
        {
            if (data->cookies == AXIS2_FALSE)
            {
                /* Ensure cookies enabled to manage session */
                /* Pass empty cookie string to enable cookies */
                curl_easy_setopt(handler, CURLOPT_COOKIEFILE, " ");
                data->cookies = AXIS2_TRUE;
            }
        }
        else if (data->cookies == AXIS2_TRUE)
        {
            /* Pass special string ALL to reset cookies if any have been enabled. */
            /* If cookies have ever been enabled, we reset every time as long as 
             manage_session is false, as there is no clear curl option to
             turn off the cookie engine once enabled. */
            curl_easy_setopt(handler, CURLOPT_COOKIELIST, AXIS2_ALL);
        }
    }

    curl_easy_setopt(handler, CURLOPT_HTTPHEADER, headers);
    curl_easy_setopt(handler, CURLOPT_WRITEFUNCTION,
        axis2_libcurl_write_memory_callback);
    curl_easy_setopt(handler, CURLOPT_WRITEDATA, data);

    curl_easy_setopt (handler, CURLOPT_HEADERFUNCTION, axis2_libcurl_header_callback);

    curl_easy_setopt (handler, CURLOPT_WRITEHEADER, data);

    /* Free response data from previous request */
    if( data->size )
    {
        if (data->memory)
        {
            AXIS2_FREE(data->env->allocator, data->memory);
        }
        data->size = 0;
    }

    if (curl_easy_perform(handler))
    {
        AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "%s", &data->errorbuffer);
        AXIS2_HANDLE_ERROR(env, AXIS2_ERROR_HTTP_CLIENT_TRANSPORT_ERROR,
            AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }

    in_stream = axutil_stream_create_libcurl(env, data->memory, data->size);
    trans_in_property = axutil_property_create(env);
    axutil_property_set_scope(trans_in_property, env, AXIS2_SCOPE_REQUEST);
    axutil_property_set_free_func(trans_in_property, env,
        libcurl_stream_free);
    axutil_property_set_value(trans_in_property, env, in_stream);
    axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_TRANSPORT_IN,
        trans_in_property);

    if (axutil_array_list_size(data->alist, env) > 0)
    {
        status_line_str = axutil_array_list_get(data->alist, env, 0);
        if (status_line_str)
        {
            status_line = axis2_http_status_line_create(env, status_line_str);
        }
    }

    if (status_line)
    {
        status_code = axis2_http_status_line_get_status_code(status_line, env);
    }

    axis2_msg_ctx_set_status_code (msg_ctx, env, status_code);
    AXIS2_FREE(data->env->allocator, content_type);
    content_type = axis2_libcurl_get_content_type(data, env);

    if (content_type)
    {
        if (strstr (content_type, AXIS2_HTTP_HEADER_ACCEPT_MULTIPART_RELATED)
            && strstr (content_type, AXIS2_HTTP_HEADER_ACCEPT_XOP_XML))
        {
            axis2_ctx_t *axis_ctx =
            axis2_op_ctx_get_base (axis2_msg_ctx_get_op_ctx (msg_ctx, env),
                env);
            property = axutil_property_create (env);
            axutil_property_set_scope (property, env, AXIS2_SCOPE_REQUEST);
            axutil_property_set_value (property,
                env, axutil_strdup (env, content_type));
            axis2_ctx_set_property (axis_ctx,
                env, MTOM_RECIVED_CONTENT_TYPE, property);
        }
    }

    content_length = axis2_libcurl_get_content_length(data, env);
    if (content_length >= 0)
    {
        response_length = AXIS2_MALLOC (env->allocator, sizeof (int));
        memcpy (response_length, &content_length, sizeof (int));
        property = axutil_property_create (env);
        axutil_property_set_scope (property, env, AXIS2_SCOPE_REQUEST);
        axutil_property_set_value (property, env, response_length);
        axis2_msg_ctx_set_property (msg_ctx, env,
            AXIS2_HTTP_HEADER_CONTENT_LENGTH, property);
    }

    curl_slist_free_all (headers);
    /* release the read http headers. */
    /* (commenting out the call below is a clever way to force a premature EOF 
     condition in subsequent messages, as they will be read using the content-length
     of the first message.) */
    axis2_libcurl_free_headers(data, env);
    AXIS2_FREE(data->env->allocator, content_type);
    axis2_http_status_line_free( status_line, env);

    return AXIS2_SUCCESS;
}