Beispiel #1
0
/************************ Basic Stream Operations *****************************/
AXIS2_EXTERN axutil_stream_t *AXIS2_CALL
axutil_stream_create_basic(
    const axutil_env_t *env)
{
    axutil_stream_t *stream = NULL;

    AXIS2_ENV_CHECK(env, NULL);
    stream = axutil_stream_create_internal(env);
    if(!stream)
    {
        /*
         * We leave the error returned by the 
         * axutil_stream_create_internal intact
         */
        return NULL;
    }
    stream->stream_type = AXIS2_STREAM_BASIC;
    stream->read = axutil_stream_read_basic;
    stream->write = axutil_stream_write_basic;
    stream->skip = axutil_stream_skip_basic;
    stream->buffer = (axis2_char_t *)AXIS2_MALLOC(env->allocator, AXIS2_STREAM_DEFAULT_BUF_SIZE
        * sizeof(axis2_char_t));
    stream->buffer_head = stream->buffer;
    stream->len = 0;
    stream->max_len = AXIS2_STREAM_DEFAULT_BUF_SIZE;

    if(!stream->buffer)
    {
        axutil_stream_free(stream, env);
        return NULL;
    }
    return stream;
}
Beispiel #2
0
void AXIS2_CALL
axutil_stream_free_void_arg(
    void *stream,
    const axutil_env_t *env)
{
    axutil_stream_t *stream_l = NULL;

    stream_l = (axutil_stream_t *)stream;
    axutil_stream_free(stream_l, env);
    return;
}
Beispiel #3
0
/** Close down a stream and perform any cleanup.
 * @param env
 * @param sstream
 */
void
sp_stream_cleanup(
    const axutil_env_t *env,
    axutil_stream_t    *sstream)
{
	if (AXIS2_SUCCESS != axutil_stream_close (sstream, env) )
	{
		p_log_error(env, "Error closing socket stream");
	}
	axutil_stream_free  (sstream, env);
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_simple_http_svr_conn_close(
    axis2_simple_http_svr_conn_t * svr_conn,
    const axutil_env_t * env)
{
    axutil_stream_free(svr_conn->stream, env);
    if(-1 != svr_conn->socket)
    {
        axutil_network_handler_close_socket(env, svr_conn->socket);
        svr_conn->socket = -1;
    }
    return AXIS2_SUCCESS;
}
AXIS2_EXTERN axiom_soap_envelope_t* AXIS2_CALL
axis2_amqp_util_get_soap_envelope(
    axis2_amqp_response_t* response,
    const axutil_env_t* env,
    axis2_msg_ctx_t* msg_ctx)
{
    axiom_xml_reader_t* xml_reader = NULL;
    axiom_stax_builder_t* stax_builder = NULL;
    axiom_soap_builder_t* soap_builder = NULL;
    axiom_soap_envelope_t* soap_envelope = NULL;
    const axis2_char_t* soap_ns_uri = NULL;
    axis2_char_t *soap_body_str = NULL;
    int soap_body_len = 0;
    axis2_bool_t is_mtom = AXIS2_FALSE;
    axutil_hash_t *binary_data_map = NULL;
    axis2_bool_t is_soap_11 = AXIS2_FALSE;

    if(!response || !response->data || !response->content_type)
    {
        return NULL;
    }

    is_soap_11 = axis2_msg_ctx_get_is_soap_11(msg_ctx, env);

    /* Handle MTOM */
    if(strstr(response->content_type, AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED))
    {
        axis2_char_t* mime_boundary = axis2_amqp_util_get_value_from_content_type(env,
            response->content_type, AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY);

        if(mime_boundary)
        {
            axiom_mime_parser_t *mime_parser = NULL;
            int soap_body_len = 0;
            axutil_param_t *buffer_size_param = NULL;
            axutil_param_t *max_buffers_param = NULL;
            axutil_param_t *attachment_dir_param = NULL;
            axis2_char_t *value_size = NULL;
            axis2_char_t *value_num = NULL;
            axis2_char_t *value_dir = NULL;
            int size = 0;
            int num = 0;

            mime_parser = axiom_mime_parser_create(env);

            buffer_size_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_BUFFER_SIZE);

            if(buffer_size_param)
            {
                value_size = (axis2_char_t *)axutil_param_get_value(buffer_size_param, env);

                if(value_size)
                {
                    size = atoi(value_size);
                    axiom_mime_parser_set_buffer_size(mime_parser, env, size);
                }
            }

            max_buffers_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_MAX_BUFFERS);

            if(max_buffers_param)
            {
                value_num = (axis2_char_t*)axutil_param_get_value(max_buffers_param, env);

                if(value_num)
                {
                    num = atoi(value_num);
                    axiom_mime_parser_set_max_buffers(mime_parser, env, num);
                }
            }

            attachment_dir_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_ATTACHMENT_DIR);

            if(attachment_dir_param)
            {
                value_dir = (axis2_char_t*)axutil_param_get_value(attachment_dir_param, env);

                if(value_dir)
                {
                    axiom_mime_parser_set_attachment_dir(mime_parser, env, value_dir);
                }
            }

            if(mime_parser)
            {
                axis2_callback_info_t* callback_ctx = NULL;
                axutil_stream_t* stream = NULL;

                callback_ctx = (axis2_callback_info_t*)AXIS2_MALLOC(env->allocator,
                    sizeof(axis2_callback_info_t));

                stream = axutil_stream_create_basic(env);

                if(stream)
                {
                    axutil_stream_write(stream, env, response->data, response->length);
                    callback_ctx->env = env;
                    callback_ctx->in_stream = stream;
                    callback_ctx->content_length = response->length;
                    callback_ctx->unread_len = response->length;
                    callback_ctx->chunked_stream = NULL;
                }

                /*binary_data_map = 
                 axiom_mime_parser_parse(mime_parser, env,
                 axis2_amqp_util_on_data_request,
                 (void*)callback_ctx,
                 mime_boundary);*/

                if(!binary_data_map)
                {
                    return AXIS2_FAILURE;
                }

                soap_body_len = axiom_mime_parser_get_soap_body_len(mime_parser, env);

                soap_body_str = axiom_mime_parser_get_soap_body_str(mime_parser, env);

                axutil_stream_free(stream, env);
                AXIS2_FREE(env->allocator, callback_ctx);
                axiom_mime_parser_free(mime_parser, env);
            }

            AXIS2_FREE(env->allocator, mime_boundary);
        }

        is_mtom = AXIS2_TRUE;
    }
    else
    {
        soap_body_str = response->data;
        soap_body_len = axutil_strlen(response->data);
    }

    soap_body_len = axutil_strlen(soap_body_str);

    xml_reader = axiom_xml_reader_create_for_memory(env, soap_body_str, soap_body_len, NULL,
        AXIS2_XML_PARSER_TYPE_BUFFER);
    if(!xml_reader)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Reader");
        return NULL;
    }

    stax_builder = axiom_stax_builder_create(env, xml_reader);
    if(!stax_builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create StAX Builder");
        return NULL;
    }

    soap_ns_uri = is_soap_11 ? AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI
        : AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;

    soap_builder = axiom_soap_builder_create(env, stax_builder, soap_ns_uri);
    if(!soap_builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create SOAP Builder");
        return NULL;
    }

    if(binary_data_map)
    {
        axiom_soap_builder_set_mime_body_parts(soap_builder, env, binary_data_map);
    }

    soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env);
    return soap_envelope;
}
Beispiel #6
0
/** executes as new entry arises */
void *AXIS2_CALL
tcpmon_entry_new_entry_funct(
    axutil_thread_t * thd,
    void *data)
{
    tcpmon_entry_request_data_t *req_data = (tcpmon_entry_request_data_t *) data;
    const axutil_env_t *env = NULL;
    int client_socket = -1;
    int host_socket = -1;
    tcpmon_session_t *session;
    TCPMON_SESSION_TRANS_ERROR_FUNCT on_trans_fault_funct;
    TCPMON_SESSION_NEW_ENTRY_FUNCT on_new_entry;

    axutil_stream_t *client_stream = NULL;
    axutil_stream_t *host_stream = NULL;
    int buffer_size = 0;
    axis2_char_t *headers = NULL;
    axis2_char_t *content = NULL;
    axis2_char_t *buffer = NULL;
    time_t now;
    struct tm *localTime = NULL;
    int arrived_secs = 0;
    int sent_secs = 0;
    int time_diff_i = 0;
    int target_port = 0;
    axis2_char_t *target_host = NULL;
    int test_bit = 0;
    int format_bit = 0;
    tcpmon_entry_t *entry = NULL;
    tcpmon_entry_impl_t *entry_impl = NULL;

    env = req_data->env;
    client_socket = req_data->socket;
    session = req_data->session;
    on_trans_fault_funct = tcpmon_session_get_on_trans_fault(session, env);
    on_new_entry = tcpmon_session_get_on_new_entry(session, env);

    entry = tcpmon_entry_create(env);
    entry_impl = AXIS2_INTF_TO_IMPL(entry);

    target_port = TCPMON_SESSION_GET_TARGET_PORT(session, env);
    target_host = TCPMON_SESSION_GET_TARGET_HOST(session, env);
    if (target_port == -1 || target_host == NULL)
    {
        axutil_network_handler_close_socket(env, client_socket);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Missing target port and host"
                        "input missing");
        if (on_trans_fault_funct)
        {
            (on_trans_fault_funct) (env, "Missing target port and host");
        }
        if (thd)
        {
            AXIS2_FREE(env->allocator, thd);
        }
        if (data)
        {
            AXIS2_FREE(env->allocator, (tcpmon_entry_request_data_t *)data);
        }
        return NULL;
    }
    client_stream = axutil_stream_create_socket(env, client_socket);
    if (!client_stream)
    {
        axutil_network_handler_close_socket(env, client_socket);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Error in creating client stream" "handling response");

                          /** call the callback */
        if (on_trans_fault_funct)
        {
            (on_trans_fault_funct) (env, "error in creating the client stream");
        }
        if (thd)
        {
            AXIS2_FREE(env->allocator, thd);
        }
        if (data)
        {
            AXIS2_FREE(env->allocator, (tcpmon_entry_request_data_t *)data);
        }
        return NULL;
    }

    buffer = tcpmon_util_read_current_stream(env, client_stream, &buffer_size,
            &headers, &content);

    headers =(char *) tcpmon_util_str_replace(env, headers,"localhost", target_host);
    test_bit = TCPMON_SESSION_GET_TEST_BIT(session, env);

    if (test_bit)
    {
        tcpmon_util_write_to_file("reqest", buffer);
    }

    format_bit = TCPMON_SESSION_GET_FORMAT_BIT(session, env);
    TCPMON_ENTRY_SET_FORMAT_BIT(entry, env, format_bit);

    now = time(NULL);
    localTime = localtime(&now);

    sprintf(entry_impl->sent_time, "%d:%d:%d", localTime->tm_hour,
            localTime->tm_min, localTime->tm_sec);
    sent_secs =
        localTime->tm_hour * 60 * 60 + localTime->tm_min * 60 +
        localTime->tm_sec;

    /*free ( localTime); */

    entry_impl->sent_headers = headers; 
    entry_impl->sent_data = content;
    entry_impl->sent_data_length = buffer_size;

    if (on_new_entry)
    {
        (on_new_entry) (env, entry, 0);
    }

    host_socket =
        (int)axutil_network_handler_open_socket(env, target_host, target_port);
    if (-1 == host_socket)
    {
        axutil_stream_write(client_stream, env, NULL, 0);
        axutil_stream_free(client_stream, env);
        axutil_network_handler_close_socket(env, client_socket);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in creating host_socket"
                        "creating socket");

                          /** call the callback */
        if (on_trans_fault_funct)
        {
            (on_trans_fault_funct) (env, "error in creating the host socket");
        }
        if (thd)
        {
            AXIS2_FREE(env->allocator, thd);
        }
        if (data)
        {
            AXIS2_FREE(env->allocator, (tcpmon_entry_request_data_t *)data);
        }
        return NULL;
    }

    host_stream = axutil_stream_create_socket(env, host_socket);
    if (!host_stream)
    {
        axutil_stream_write(client_stream, env, NULL, 0);
        axutil_stream_free(client_stream, env);
        axutil_network_handler_close_socket(env, client_socket);
        axutil_network_handler_close_socket(env, host_socket);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Error in creating host stream"
                        "handling response");

                          /** call the callback */
        if (on_trans_fault_funct)
        {
            (on_trans_fault_funct) (env, "error in creating the host stream");
        }
        if (thd)
        {
            AXIS2_FREE(env->allocator, thd);
        }
        if (data)
        {
            AXIS2_FREE(env->allocator, (tcpmon_entry_request_data_t *)data);
        }
        return NULL;
    }

    axutil_stream_write(host_stream, env, buffer, buffer_size);
    AXIS2_FREE(env->allocator, buffer);

    buffer = tcpmon_util_read_current_stream(env, host_stream, &buffer_size,
                                 &headers, &content);

    test_bit = TCPMON_SESSION_GET_TEST_BIT(session, env);
    if (test_bit)
    {
        tcpmon_util_write_to_file("response", buffer);
    }

    now = time(NULL);
    localTime = localtime(&now);

    sprintf(entry_impl->arrived_time, "%d:%d:%d", localTime->tm_hour,
            localTime->tm_min, localTime->tm_sec);
    arrived_secs =
        localTime->tm_hour * 60 * 60 + localTime->tm_min * 60 +
        localTime->tm_sec;
    /*free ( localTime); */

    time_diff_i = arrived_secs - sent_secs;
    if (time_diff_i < 0)
    {
        time_diff_i += 24 * 60 * 60;
    }
    sprintf(entry_impl->time_diff, "%d sec(s)", time_diff_i);

    entry_impl->arrived_headers = headers;
    entry_impl->arrived_data = content;
    entry_impl->arrived_data_length = buffer_size;
    if (buffer == NULL || buffer_size == 0)
    {
        entry_impl->is_success = 0;
    }
    else
    {
        entry_impl->is_success = 1;
    }

    if (on_new_entry)
    {
        (on_new_entry) (env, entry, 1);
    }

    axutil_stream_write(client_stream, env, buffer, buffer_size);
    AXIS2_FREE(env->allocator, buffer);

    axutil_stream_free(client_stream, env);
    axutil_stream_free(host_stream, env);
    axutil_network_handler_close_socket(env, client_socket);
    axutil_network_handler_close_socket(env, host_socket);

    if (entry_impl)
    {
        tcpmon_entry_free(&(entry_impl->entry), env);
    }
    if (thd)
    {
        AXIS2_FREE(env->allocator, thd);
    }
    if (data)
    {
        AXIS2_FREE(env->allocator, (tcpmon_entry_request_data_t *)data);
    }
    return NULL;
}
axis2_status_t
axis2_amqp_process_request(
    const axutil_env_t* env,
    axis2_amqp_request_processor_resource_pack_t* request_resource_pack)
{
    axiom_xml_reader_t* xml_reader = NULL;
    axiom_stax_builder_t* stax_builder = NULL;
    axiom_soap_builder_t* soap_builder = NULL;
    axis2_transport_out_desc_t* out_desc = NULL;
    axis2_transport_in_desc_t* in_desc = NULL;
    axis2_msg_ctx_t* msg_ctx = NULL;
    axiom_soap_envelope_t* soap_envelope = NULL;
    axis2_engine_t* engine = NULL;
    const axis2_char_t* soap_ns_uri = NULL;
    axis2_bool_t is_soap_11 = AXIS2_FALSE;
    axis2_char_t *soap_body_str = NULL;
    int soap_body_len = 0;
    axis2_bool_t is_mtom = AXIS2_FALSE;
    axis2_status_t status = AXIS2_FAILURE;
    axutil_hash_t *binary_data_map = NULL;
    axiom_soap_body_t *soap_body = NULL;
    axutil_property_t* reply_to_property = NULL;

    /* Create msg_ctx */
    if(!request_resource_pack->conf_ctx)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Conf Context not Available");
        return AXIS2_FAILURE;
    }

    out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf(
        request_resource_pack->conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_AMQP);
    if(!out_desc)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport Out Descriptor not Found");
        return AXIS2_FAILURE;
    }

    in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(request_resource_pack->conf_ctx,
        env), env, AXIS2_TRANSPORT_ENUM_AMQP);
    if(!in_desc)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport In Descriptor not Found");
        return AXIS2_FAILURE;
    }

    /* Create msg_ctx */
    msg_ctx = axis2_msg_ctx_create(env, request_resource_pack->conf_ctx, in_desc, out_desc);

    axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);

    /* Handle MTOM */
    if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED))
    {
        axis2_char_t* mime_boundary = axis2_amqp_util_get_value_from_content_type(env,
            request_resource_pack->content_type, AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY);

        if(mime_boundary)
        {
            axiom_mime_parser_t *mime_parser = NULL;
            int soap_body_len = 0;
            axutil_param_t *buffer_size_param = NULL;
            axutil_param_t *max_buffers_param = NULL;
            axutil_param_t *attachment_dir_param = NULL;
            axis2_char_t *value_size = NULL;
            axis2_char_t *value_num = NULL;
            axis2_char_t *value_dir = NULL;
            int size = 0;
            int num = 0;

            mime_parser = axiom_mime_parser_create(env);

            buffer_size_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_BUFFER_SIZE);
            if(buffer_size_param)
            {
                value_size = (axis2_char_t*)axutil_param_get_value(buffer_size_param, env);
                if(value_size)
                {
                    size = atoi(value_size);
                    axiom_mime_parser_set_buffer_size(mime_parser, env, size);
                }
            }

            max_buffers_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_MAX_BUFFERS);
            if(max_buffers_param)
            {
                value_num = (axis2_char_t*)axutil_param_get_value(max_buffers_param, env);
                if(value_num)
                {
                    num = atoi(value_num);
                    axiom_mime_parser_set_max_buffers(mime_parser, env, num);
                }
            }

            /* If this paramter is there mime_parser will cached the attachment 
             * using to the directory for large attachments. */
            attachment_dir_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_ATTACHMENT_DIR);
            if(attachment_dir_param)
            {
                value_dir = (axis2_char_t*)axutil_param_get_value(attachment_dir_param, env);
                if(value_dir)
                {
                    axiom_mime_parser_set_attachment_dir(mime_parser, env, value_dir);
                }
            }

            if(mime_parser)
            {
                axis2_callback_info_t *callback_ctx = NULL;
                axutil_stream_t *stream = NULL;

                callback_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_callback_info_t));

                stream = axutil_stream_create_basic(env);
                if(stream)
                {
                    axutil_stream_write(stream, env, request_resource_pack->request_content,
                        request_resource_pack->content_length);
                    callback_ctx->env = env;
                    callback_ctx->in_stream = stream;
                    callback_ctx->content_length = request_resource_pack->content_length;
                    callback_ctx->unread_len = request_resource_pack->content_length;
                    callback_ctx->chunked_stream = NULL;
                }

                /*binary_data_map = 
                 axiom_mime_parser_parse(mime_parser, env,
                 axis2_amqp_util_on_data_request,
                 (void*)callback_ctx,
                 mime_boundary);*/
                if(!binary_data_map)
                {
                    return AXIS2_FAILURE;
                }

                soap_body_str = axiom_mime_parser_get_soap_body_str(mime_parser, env);
                soap_body_len = axiom_mime_parser_get_soap_body_len(mime_parser, env);

                axutil_stream_free(stream, env);
                AXIS2_FREE(env->allocator, callback_ctx);
                axiom_mime_parser_free(mime_parser, env);
            }

            AXIS2_FREE(env->allocator, mime_boundary);
        }

        is_mtom = AXIS2_TRUE;
    }
    else
    {
        soap_body_str = request_resource_pack->request_content;
        soap_body_len = request_resource_pack->content_length;
    }

    soap_body_len = axutil_strlen(soap_body_str);

    xml_reader = axiom_xml_reader_create_for_memory(env, soap_body_str, soap_body_len, NULL,
        AXIS2_XML_PARSER_TYPE_BUFFER);
    if(!xml_reader)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Reader");
        return AXIS2_FAILURE;
    }

    stax_builder = axiom_stax_builder_create(env, xml_reader);
    if(!stax_builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create StAX Builder");
        return AXIS2_FAILURE;
    }

    soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;

    if(request_resource_pack->content_type)
    {
        if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML))
        {
            is_soap_11 = AXIS2_TRUE;
            soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI;
        }
        /*if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_APPL_SOAP))
         {
         is_soap_11 = AXIS2_FALSE;
         soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
         }
         else if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML))
         {
         is_soap_11 = AXIS2_TRUE;
         soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI;
         }*/
    }

    soap_builder = axiom_soap_builder_create(env, stax_builder, soap_ns_uri);
    if(!soap_builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create SOAP Builder");
        return AXIS2_FAILURE;
    }

    if(binary_data_map)
    {
        axiom_soap_builder_set_mime_body_parts(soap_builder, env, binary_data_map);
    }

    soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env);
    axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope);

    soap_body = axiom_soap_envelope_get_body(soap_envelope, env);

    if(!soap_body)
    {
        return AXIS2_FAILURE;
    }

    /* SOAPAction */
    if(request_resource_pack->soap_action)
    {
        axis2_msg_ctx_set_soap_action(msg_ctx, env, axutil_string_create(env,
            request_resource_pack->soap_action));
    }

    /* SOAP version */
    axis2_msg_ctx_set_is_soap_11(msg_ctx, env, is_soap_11);

    /* Set ReplyTo in the msg_ctx as a property. This is used by the server when
     * 1. WS-A is not in use
     * 2. ReplyTo is an anonymous EPR - Sandesha2/Dual-channel */
    reply_to_property = axutil_property_create_with_args(env, AXIS2_SCOPE_REQUEST, 0, 0,
        (void*)request_resource_pack->reply_to);
    axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO,
        reply_to_property);

    engine = axis2_engine_create(env, request_resource_pack->conf_ctx);

    if(AXIS2_TRUE == axiom_soap_body_has_fault(soap_body, env))
    {
        status = axis2_engine_receive_fault(engine, env, msg_ctx);
    }
    else
    {
        status = axis2_engine_receive(engine, env, msg_ctx);
    }

    if(engine)
    {
        axis2_engine_free(engine, env);
    }

    if(soap_body_str && is_mtom)
    {
        AXIS2_FREE(env->allocator, soap_body_str);
    }

    return status;
}
AXIS2_EXTERN void AXIS2_CALL
axis2_http_client_free(
    axis2_http_client_t * http_client,
    const axutil_env_t * env)
{
    if(http_client->proxy_host)
    {
        AXIS2_FREE(env->allocator, http_client->proxy_host);
    }
    if(http_client->proxy_host_port)
    {
        AXIS2_FREE(env->allocator, http_client->proxy_host_port);
    }
    if(http_client->url)
    {
        axutil_url_free(http_client->url, env);
    }
    if(http_client->response)
    {
        axis2_http_simple_response_free(http_client->response, env);
    }
    if(-1 != http_client->sockfd)
    {
#ifdef AXIS2_SSL_ENABLED
        if(http_client->data_stream)
        {
            if(http_client->data_stream->stream_type == AXIS2_STREAM_SOCKET)
            {
                axutil_network_handler_close_socket(env, http_client->sockfd);
                /** ssl streams of type AXIS2_STREAM_BASIC  will be handled by SSL_shutdown(); */
            }
        }
#else
		axutil_network_handler_close_socket(env, http_client->sockfd);
#endif
        http_client->sockfd = -1;

    }

    if(http_client->data_stream && http_client->owns_stream)
    {
        axutil_stream_free(http_client->data_stream,env);
    }

    if(http_client->req_body)
    {
        AXIS2_FREE(env->allocator, http_client->req_body);
    }

    /* There is no other appropriate place to free the mime_part list when a 
     * particular client send requests. */

    if(http_client->mime_parts)
    {
        int i = 0;
        for(i = 0; i < axutil_array_list_size(http_client->mime_parts, env); i++)
        {
            axiom_mime_part_t *mime_part = NULL;
            mime_part = (axiom_mime_part_t *)axutil_array_list_get(http_client->mime_parts, env, i);
            if(mime_part)
            {
                axiom_mime_part_free(mime_part, env);
            }
        }
        axutil_array_list_free(http_client->mime_parts, env);
    }

    AXIS2_FREE(env->allocator, http_client);
    return;
}