Пример #1
0
axis2_bool_t AXIS2_CALL
sandesha2_msg_ctx_get_server_side(
    const sandesha2_msg_ctx_t * rm_msg_ctx,
    const axutil_env_t * env)
{
    return axis2_msg_ctx_get_server_side(rm_msg_ctx->msg_ctx, env);
}
Пример #2
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_engine_resume_receive(
    axis2_engine_t * engine,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axis2_status_t status = AXIS2_FAILURE;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_conf_t *conf = NULL;
    axutil_array_list_t *phases = NULL;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Start:axis2_engine_resume_receive");
    /* Find and invoke the phases */
    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    conf = axis2_conf_ctx_get_conf(conf_ctx, env);
    phases = axis2_conf_get_in_phases_upto_and_including_post_dispatch(conf, env);

    axis2_engine_resume_invocation_phases(engine, env, phases, msg_ctx);
    /* Invoking the message receiver */
    if(axis2_msg_ctx_get_server_side(msg_ctx, env) && !axis2_msg_ctx_is_paused(msg_ctx, env))
    {
        /* Invoke the message receivers */
        axis2_op_ctx_t *op_ctx = NULL;

        status = axis2_engine_check_must_understand_headers(env, msg_ctx);

        if(status != AXIS2_SUCCESS)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Checking for must understand headers failed");
            return status;
        }

        op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
        if(op_ctx)
        {
            axis2_op_t *op = axis2_op_ctx_get_op(op_ctx, env);
            if(op)
            {
                axis2_msg_recv_t *receiver = NULL;
                receiver = axis2_op_get_msg_recv(op, env);
                if(!receiver)
                {
                    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Message receiver not set in operation description");
                    return AXIS2_FAILURE;
                }
                status = axis2_msg_recv_receive(receiver, env, msg_ctx, axis2_msg_recv_get_derived(
                    receiver, env));
            }
        }
    }
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_engine_resume_receive");
    return status;
}
Пример #3
0
axis2_status_t AXIS2_CALL
sandesha2_out_handler_invoke(
    struct axis2_handler *handler, 
    const axutil_env_t *env,
    struct axis2_msg_ctx *msg_ctx)
{
    axutil_property_t *temp_prop = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_conf_t *conf = NULL;
    axis2_char_t *str_done = NULL;
    axis2_char_t *dummy_msg_str = NULL;
    axis2_bool_t dummy_msg = AXIS2_FALSE;
    axis2_svc_t *svc = NULL;
    axutil_qname_t *module_qname = NULL;
    sandesha2_msg_ctx_t *rm_msg_ctx = NULL;
    sandesha2_msg_processor_t *msg_processor = NULL;
    int msg_type = -1;

    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_out_handler_invoke");
            
    temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_SEQ_PROP_MAKE_CONNECTION_OUT_PATH);
    if (temp_prop)
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
            "[sandesha2] In make connection out path. So return here.");
        return AXIS2_SUCCESS;
        temp_prop = NULL;
    }

    if(sandesha2_util_is_rstr_msg(env, msg_ctx))
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
            "[sandesha2] A RSTR message. Sandesha don't process.");
        return AXIS2_SUCCESS;
    }

    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    if(!conf_ctx)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
            "[sandesha2] Configuration Context is NULL");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CONF_CTX_NULL, AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }
    svc = axis2_msg_ctx_get_svc(msg_ctx, env);
    if(!svc)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]Axis2 Service is NULL");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_SVC_NULL, AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }
    module_qname = axutil_qname_create(env, SANDESHA2_MODULE, NULL, NULL);
    if(!axis2_svc_is_module_engaged(svc, env, module_qname))
    {
        if(module_qname)
        {
            axutil_qname_free(module_qname, env);
        }

        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]RM is not engaged. So return here");
        return AXIS2_SUCCESS;
    }

    if(module_qname)
    {
        axutil_qname_free(module_qname, env);
    }

    temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE);
    if(temp_prop)
    {
        str_done = (axis2_char_t *) axutil_property_get_value(temp_prop, env); 
    }

    if(str_done && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, str_done))
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
            "[sandesha2]Application Processing Done. So return here.");
        return AXIS2_SUCCESS; 
    }

    temp_prop = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
    axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, temp_prop);
    conf = axis2_conf_ctx_get_conf(conf_ctx, env);
    if(!sandesha2_permanent_storage_mgr_create_db(env, conf_ctx))
    {
        return AXIS2_FAILURE;
    }

    /* Getting rm message */ 
    rm_msg_ctx = sandesha2_msg_init_init_msg(env, msg_ctx);
    temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_CLIENT_DUMMY_MESSAGE);
    if(NULL != temp_prop)
    {
        dummy_msg_str = (axis2_char_t *) axutil_property_get_value(temp_prop, env); 
    }

    if(dummy_msg_str && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, dummy_msg_str))
    {
        dummy_msg = AXIS2_TRUE;
    }

    temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_SVC_CLIENT_CLOSED);
    if(temp_prop)
    {
        axis2_char_t *spec_version = NULL;

        axis2_endpoint_ref_t *reply_to = axis2_msg_ctx_get_reply_to(msg_ctx, env);
        if(reply_to)
        {
            axis2_char_t *address = axis2_endpoint_ref_get_address(reply_to, env);
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "dam_reply_to_address:%s", address);
        }
        spec_version = sandesha2_utils_get_rm_version(env, msg_ctx);

        if(!axutil_strcmp(SANDESHA2_SPEC_VERSION_1_1, spec_version))
        {
            axis2_char_t *action = NULL;
            axutil_string_t *str_action = NULL;

            action = sandesha2_spec_specific_consts_get_terminate_seq_action(env, spec_version);
            str_action = axutil_string_create(env, action);
            axis2_msg_ctx_set_soap_action(msg_ctx, env, str_action);
            axutil_string_free(str_action, env);
            /*axis2_msg_ctx_set_reply_to(msg_ctx, env, NULL);*/
            msg_type = sandesha2_msg_ctx_set_msg_type(rm_msg_ctx, env, 
                SANDESHA2_MSG_TYPE_CLOSE_SEQ);
        }
        else if(!axutil_strcmp(SANDESHA2_SPEC_VERSION_1_0, spec_version))
        {
            axutil_property_t *property = NULL;
            axutil_string_t *str_action = NULL;
            
            /*axis2_msg_info_headers_set_action(axis2_msg_ctx_get_msg_info_headers(msg_ctx, env), 
             * env, SANDESHA2_SPEC_2005_02_SOAP_ACTION_LAST_MESSAGE); */
            str_action = axutil_string_create(env, SANDESHA2_SPEC_2005_02_SOAP_ACTION_LAST_MESSAGE);
            axis2_msg_ctx_set_soap_action(msg_ctx, env, str_action);
            axutil_string_free(str_action, env);
            property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
            axis2_msg_ctx_set_property(msg_ctx, env, "Sandesha2LastMessage", property);
            /*axis2_msg_ctx_set_reply_to(msg_ctx, env, NULL);*/
        }
    }

    msg_type = sandesha2_msg_ctx_get_msg_type(rm_msg_ctx, env);
    if(msg_type == SANDESHA2_MSG_TYPE_UNKNOWN)
    {
        axis2_msg_ctx_t *req_msg_ctx = NULL;
        axis2_op_ctx_t *op_ctx = NULL;

        op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
        req_msg_ctx =  axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN);
        if(req_msg_ctx) /* For the server side */
        {
            sandesha2_msg_ctx_t *req_rm_msg_ctx = NULL;
            sandesha2_seq_t *seq_part = NULL;

            req_rm_msg_ctx = sandesha2_msg_init_init_msg(env, req_msg_ctx);
            seq_part = sandesha2_msg_ctx_get_sequence(req_rm_msg_ctx, env);
            if(seq_part)
            {
                msg_processor = (sandesha2_msg_processor_t *) 
                sandesha2_app_msg_processor_create(env); /* rm intended msg */
            }
            if(req_rm_msg_ctx)
                sandesha2_msg_ctx_free(req_rm_msg_ctx, env);
        }
        else if(!axis2_msg_ctx_get_server_side(msg_ctx, env))
        {
            msg_processor = (sandesha2_msg_processor_t *) sandesha2_app_msg_processor_create(env);
        }
    }
    else
    {
        msg_processor = sandesha2_msg_processor_create_msg_processor(env, rm_msg_ctx);
    }
    if(msg_processor)
    {
        sandesha2_msg_processor_process_out_msg(msg_processor, env, rm_msg_ctx);
        sandesha2_msg_processor_free(msg_processor, env);
    }
    if(AXIS2_SUCCESS != AXIS2_ERROR_GET_STATUS_CODE(env->error))
    {
        /* Message should not be sent in an exception situation */

        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Pausing message context");
        axis2_msg_ctx_set_paused(msg_ctx, env, AXIS2_TRUE);
        if(rm_msg_ctx)
        {
            sandesha2_msg_ctx_free(rm_msg_ctx, env);
        }
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Error in processing the message");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_PROCESS_MSG, AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }
    
    temp_prop = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE);
    if(temp_prop)
    {
        axutil_property_set_value(temp_prop, env, AXIS2_VALUE_FALSE);
    }

    if(rm_msg_ctx)
    {
        sandesha2_msg_ctx_free(rm_msg_ctx, env);
    }

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2]Exit:sandesha2_out_handler_invoke");

    return AXIS2_SUCCESS;
}
Пример #4
0
static axis2_status_t
sandesha2_msg_creator_finalize_creation(
    const axutil_env_t *env,
    axis2_msg_ctx_t *related_msg,
    axis2_msg_ctx_t *new_msg)
{
    /*axis2_op_t *old_op = NULL;*/
    /*axis2_op_ctx_t *old_op_ctx = NULL;*/
    axis2_bool_t temp_bool = AXIS2_FALSE;
    /*axutil_hash_t *related_msg_props = NULL;
    axutil_hash_t *new_msg_props = NULL;
    axis2_ctx_t *related_ctx = NULL;
    axis2_ctx_t *new_ctx = NULL;*/

    temp_bool = axis2_msg_ctx_get_server_side(related_msg, env);
    axis2_msg_ctx_set_server_side(new_msg, env, temp_bool);
    /* Adding all parameters from old message to the new one */
    /*old_op = axis2_msg_ctx_get_op(related_msg, env);
    if(old_op)
    {
        axutil_array_list_t *op_params = NULL;

        op_params = axis2_op_get_all_params(old_op, env);
        if(op_params)
        {
            axis2_op_t *new_op = NULL;
            int i = 0, size = 0;

            new_op = axis2_msg_ctx_get_op(new_msg, env);
            size = axutil_array_list_size(op_params, env);
            for(i = 0; i < size; i++)
            {
                axutil_param_t *next_param = NULL;
                axutil_param_t *new_param = NULL;
                axis2_char_t *temp_name = NULL;
                void *temp_value = NULL;

                next_param = (axutil_param_t *) axutil_array_list_get(op_params, 
                        env, i);
                temp_name = axutil_param_get_name(next_param, env);
                temp_value = axutil_param_get_value(next_param, env);
                new_param = axutil_param_create(env, temp_name, temp_value);
                axutil_param_set_value_free(new_param, env, 
                    axutil_param_dummy_free_fn);
                axis2_op_add_param(new_op, env, new_param); 
            }
        }
    }*/
    /* Operation context properties */
    /*old_op_ctx = axis2_msg_ctx_get_op_ctx(related_msg, env);
    if(old_op_ctx)
    {
        axutil_hash_t *old_op_ctx_props = NULL;
        axis2_ctx_t *ctx = NULL;

        ctx = axis2_op_ctx_get_base(old_op_ctx, env);
        old_op_ctx_props = axis2_ctx_get_all_properties(ctx, env);
        if(old_op_ctx_props)
        {
            axis2_op_ctx_t *new_op_ctx = NULL;
            axutil_hash_index_t *hi = NULL;

            new_op_ctx = axis2_msg_ctx_get_op_ctx(new_msg, env);
            for (hi = axutil_hash_first (old_op_ctx_props, env); hi; hi = 
                    axutil_hash_next (env, hi))
            {
                void *v = NULL;
                void *k = NULL;
                axis2_char_t *key = NULL;
                axutil_property_t *prop = NULL;
                axutil_property_t *new_prop = NULL;
                axis2_ctx_t *ctx = NULL;

                axutil_hash_this (hi, (const void **)&k, NULL, &v);
                key = (axis2_char_t *) k;
                prop = (axutil_property_t *) v;
                ctx = axis2_op_ctx_get_base(new_op_ctx, env);
                if(prop)
                    new_prop = axutil_property_clone(prop, env);
                if(new_prop)
                {
                    if(0 == axutil_strcmp(AXIS2_TRANSPORT_IN, key))
                    {
                        axutil_property_set_own_value(new_prop, env, AXIS2_FALSE);
                    }
                    axis2_ctx_set_property(ctx, env, key, new_prop);
                }
            }
        }
    }*/
    /* Setting options with properties copied from the old one */
    /*if(related_msg && new_msg)
    {
        related_ctx = axis2_msg_ctx_get_base(related_msg, env);
        related_msg_props = axis2_ctx_get_all_properties(related_ctx, env);
        new_ctx = axis2_msg_ctx_get_base(new_msg, env);
        new_msg_props = axis2_ctx_get_all_properties(new_ctx, env);
        if(related_msg_props)
        {
            axutil_hash_index_t *i = NULL;

            for (i = axutil_hash_first (related_msg_props, env); i; i = 
                    axutil_hash_next (env, i))
            {
                void *v = NULL;
                void *k = NULL;
                axis2_char_t *key = NULL;
                axutil_property_t *prop = NULL;
                axutil_property_t *new_prop = NULL;

                axutil_hash_this (i, (const void **)&k, NULL, &v);
                key = (axis2_char_t *) k;
                prop = (axutil_property_t *) v;
                if(prop)
                    new_prop = axutil_property_clone(prop, env);
                if(new_prop)
                {
                    if(0 == axutil_strcmp(AXIS2_TRANSPORT_IN, key))
                    {
                        axutil_property_set_own_value(new_prop, env, AXIS2_FALSE);
                    }
                    if(0 == axutil_strcmp(AXIS2_HTTP_CLIENT, key))
                    {
                        axutil_property_set_own_value(new_prop, env, AXIS2_FALSE);
                    }
                    axutil_hash_set(new_msg_props, key, AXIS2_HASH_KEY_STRING, new_prop);
                }
            }
        }
    }*/
    return AXIS2_SUCCESS;
}
Пример #5
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_engine_receive(
    axis2_engine_t * engine,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_conf_t *conf = NULL;
    axis2_op_ctx_t *op_ctx = NULL;
    axis2_op_t *op = NULL;
    axutil_array_list_t *pre_calculated_phases = NULL;
    axutil_array_list_t *op_specific_phases = NULL;
    axis2_status_t status = AXIS2_FAILURE;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Start:axis2_engine_receive");
    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);

    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);

    conf = axis2_conf_ctx_get_conf(conf_ctx, env);

    pre_calculated_phases = axis2_conf_get_in_phases_upto_and_including_post_dispatch(conf, env);

    if(axis2_msg_ctx_is_paused(msg_ctx, env))
    {
        /* The message has paused, so re-run them from the position they stopped. */
        axis2_engine_resume_invocation_phases(engine, env, pre_calculated_phases, msg_ctx);
        if(axis2_msg_ctx_is_paused(msg_ctx, env))
        {
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Message context is paused. So return here.");
            return AXIS2_SUCCESS;
        }

        /* Resume op specific phases */
        op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
        if(op_ctx)
        {
            op = axis2_op_ctx_get_op(op_ctx, env);
            op_specific_phases = axis2_op_get_in_flow(op, env);
            axis2_engine_resume_invocation_phases(engine, env, op_specific_phases, msg_ctx);
            if(axis2_msg_ctx_is_paused(msg_ctx, env))
            {
                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                    "Message context is paused. So return here.");
                return AXIS2_SUCCESS;
            }
        }
    }
    else
    {
        status = axis2_engine_invoke_phases(engine, env, pre_calculated_phases, msg_ctx);
        if(status != AXIS2_SUCCESS)
        {
            if(axis2_msg_ctx_get_server_side(msg_ctx, env))
            {
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invoking pre-calculated phases failed");
                return status;
            }
        }

        if(axis2_msg_ctx_is_paused(msg_ctx, env))
        {
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Message context is paused. So return here.");
            return AXIS2_SUCCESS;
        }

        op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
        if(op_ctx)
        {
            op = axis2_op_ctx_get_op(op_ctx, env);
            op_specific_phases = axis2_op_get_in_flow(op, env);
            status = axis2_engine_invoke_phases(engine, env, op_specific_phases, msg_ctx);
            if(status != AXIS2_SUCCESS)
            {
                axis2_char_t *op_name = NULL;
                op_name = axutil_qname_get_localpart(axis2_op_get_qname(op, env), env);
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                    "Invoking operation specific phases failed for operation %s", op_name);
                return status;
            }

            if(axis2_msg_ctx_is_paused(msg_ctx, env))
            {
                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                    "Message context is paused. So return here.");
                return AXIS2_SUCCESS;
            }
        }
    }

    if((axis2_msg_ctx_get_server_side(msg_ctx, env)) && !(axis2_msg_ctx_is_paused(msg_ctx, env)))
    {
        axis2_msg_recv_t *receiver = NULL;

        status = axis2_engine_check_must_understand_headers(env, msg_ctx);
        if(status != AXIS2_SUCCESS)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Check for must understand headers failed");
            return status;
        }

        /* Invoke the message receivers */
        if(!op)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Operation not found");
            return AXIS2_FAILURE;
        }
        receiver = axis2_op_get_msg_recv(op, env);
        if(!receiver)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                "Message receiver not set in operation description");
            return AXIS2_FAILURE;
        }
        status = axis2_msg_recv_receive(receiver, env, msg_ctx, axis2_msg_recv_get_derived(
            receiver, env));
    }

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_engine_receive");

    return status;
}
static axis2_status_t AXIS2_CALL
sandesha2_terminate_seq_msg_processor_process_in_msg (
    sandesha2_msg_processor_t *msg_processor,
    const axutil_env_t *env,
    sandesha2_msg_ctx_t *rm_msg_ctx)
{
    axis2_msg_ctx_t *terminate_msg_ctx = NULL;
    sandesha2_terminate_seq_t *term_seq = NULL;
    axis2_char_t *rmd_sequence_id = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    sandesha2_storage_mgr_t *storage_mgr = NULL;
    sandesha2_seq_property_mgr_t *seq_prop_mgr = NULL;
    sandesha2_create_seq_mgr_t *create_seq_mgr = NULL;
    sandesha2_sender_mgr_t *sender_mgr = NULL;
    sandesha2_next_msg_mgr_t *next_msg_mgr = NULL;
    sandesha2_msg_ctx_t *fault_ctx = NULL;
    axis2_char_t *spec_version = NULL;
    axis2_char_t *dbname = NULL;
    sandesha2_seq_ack_t *seq_ack = NULL;
    axis2_op_ctx_t *op_ctx = NULL;
    /*sandesha2_seq_property_bean_t *term_rcvd_bean = NULL;*/

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
                    "[sandesha2]Entry:sandesha2_terminate_seq_msg_processor_process_in_msg");

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

    terminate_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env);

    if(axis2_msg_ctx_get_server_side(terminate_msg_ctx, env))
    {
        axis2_msg_ctx_t **msg_ctx_map = NULL;

        op_ctx = axis2_msg_ctx_get_op_ctx(terminate_msg_ctx, env);
        msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
        msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN] = terminate_msg_ctx;
    }

    term_seq = sandesha2_msg_ctx_get_terminate_seq(rm_msg_ctx, env);
    if(!term_seq)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "[sandesha2] Terminate Sequence part is not available");

        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING, AXIS2_FAILURE);

        return AXIS2_FAILURE;
    }

    rmd_sequence_id = sandesha2_identifier_get_identifier(sandesha2_terminate_seq_get_identifier(
                          term_seq, env), env);
    if(!rmd_sequence_id || 0 == axutil_strlen(rmd_sequence_id))
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Invalid sequence id");

        return AXIS2_FAILURE;
    }

    conf_ctx = axis2_msg_ctx_get_conf_ctx(terminate_msg_ctx, env);
    dbname = sandesha2_util_get_dbname(env, conf_ctx);
    storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname);
    if(!storage_mgr)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Could not create storage manager.");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_COULD_NOT_CREATE_STORAGE_MANAGER,
                        AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }
    seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
    create_seq_mgr = sandesha2_permanent_create_seq_mgr_create(env, dbname);
    sender_mgr = sandesha2_permanent_sender_mgr_create(env, dbname);
    next_msg_mgr = sandesha2_permanent_next_msg_mgr_create(env, dbname);
    fault_ctx = sandesha2_fault_mgr_check_for_unknown_seq(env, rm_msg_ctx, rmd_sequence_id, seq_prop_mgr,
                create_seq_mgr, next_msg_mgr);

    if(fault_ctx)
    {
        axis2_engine_t *engine = NULL;

        engine = axis2_engine_create(env, conf_ctx);

        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Send fault occurred");

        axis2_engine_send_fault(engine, env, sandesha2_msg_ctx_get_msg_ctx(fault_ctx, env));
        sandesha2_msg_ctx_free(fault_ctx, env);
        if(engine)
        {
            axis2_engine_free(engine, env);
        }

        axis2_msg_ctx_set_paused(terminate_msg_ctx, env, AXIS2_TRUE);

        if(seq_prop_mgr)
        {
            sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
        }
        if(create_seq_mgr)
        {
            sandesha2_create_seq_mgr_free(create_seq_mgr, env);
        }
        if(sender_mgr)
        {
            sandesha2_sender_mgr_free(sender_mgr, env);
        }
        if(next_msg_mgr)
        {
            sandesha2_next_msg_mgr_free(next_msg_mgr, env);
        }
        if(storage_mgr)
        {
            sandesha2_storage_mgr_free(storage_mgr, env);
        }

        return AXIS2_SUCCESS;
    }

    /*term_rcvd_bean = sandesha2_seq_property_bean_create(env);
    sandesha2_seq_property_bean_set_seq_id(term_rcvd_bean, env, rmd_sequence_id);
    sandesha2_seq_property_bean_set_name(term_rcvd_bean, env, SANDESHA2_SEQ_PROP_TERMINATE_RECEIVED);
    sandesha2_seq_property_bean_set_value(term_rcvd_bean, env, AXIS2_VALUE_TRUE);
    sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, term_rcvd_bean);*/

    spec_version = sandesha2_msg_ctx_get_rm_spec_ver(rm_msg_ctx, env);
    if(sandesha2_spec_specific_consts_is_term_seq_res_reqd(env, spec_version))
    {
        sandesha2_terminate_seq_msg_processor_add_terminate_seq_res(env, rm_msg_ctx, rmd_sequence_id,
                seq_prop_mgr);
    }

    seq_ack = sandesha2_msg_ctx_get_seq_ack(rm_msg_ctx, env);
    /* If we have received a sequence acknowldegment with the incoming terminate message then we may
     * decide to send the terminate sequence message.
     */
    if(seq_ack)
    {
        axis2_char_t *internal_sequence_id = NULL;
        axis2_char_t *rms_sequence_id = NULL;
        axis2_char_t *last_out_msg_no_str = NULL;
        long highest_out_msg_no = 0;
        sandesha2_seq_property_bean_t *terminated_bean = NULL;

        /* If there is a sequence acknowledgement element present in the sequence we will check
         * whether the sequence is completed. If so send a terminate sequence message.
         */
        rms_sequence_id = sandesha2_identifier_get_identifier(sandesha2_seq_ack_get_identifier(
                              seq_ack, env), env);

        internal_sequence_id = sandesha2_utils_get_seq_property(env, rms_sequence_id,
                               SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_INTERNAL_SEQUENCE_ID, seq_prop_mgr);

        terminated_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_sequence_id,
                          SANDESHA2_SEQ_PROP_TERMINATE_ADDED);
        if(terminated_bean)
        {
            axis2_char_t *value = sandesha2_seq_property_bean_get_value(terminated_bean, env);

            if(value && !axutil_strcmp(AXIS2_VALUE_TRUE, value))
            {
                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                                "[sandesha2] Terminate sequence message was added previously");
            }

            sandesha2_seq_property_bean_free(terminated_bean, env);
        }
        else
        {
            /* Retrieve the message number of the RM 1.0 last message */
            last_out_msg_no_str = sandesha2_utils_get_seq_property(env, internal_sequence_id,
                                  SANDESHA2_SEQ_PROP_LAST_OUT_MESSAGE_NO, seq_prop_mgr);

            if(last_out_msg_no_str)
            {
                highest_out_msg_no = atol(last_out_msg_no_str);
                if(last_out_msg_no_str)
                {
                    AXIS2_FREE(env->allocator, last_out_msg_no_str);
                }
            }
            else
            {
                highest_out_msg_no = sandesha2_app_msg_processor_get_prev_msg_no(env,
                                     internal_sequence_id, seq_prop_mgr);
            }

            if(highest_out_msg_no > 0)
            {
                axis2_bool_t completed = AXIS2_FALSE;
                axutil_array_list_t *ack_range_list = NULL;

                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] highest_out_msg_no:%ld",
                                highest_out_msg_no);

                ack_range_list = sandesha2_seq_ack_get_ack_range_list(seq_ack, env);
                completed = sandesha2_ack_mgr_verify_seq_completion(env, ack_range_list,
                            highest_out_msg_no);

                if(completed)
                {
                    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                                    "[sandesha2] Sequence %s is completed. So adding terminate msg",
                                    rms_sequence_id);

                    sandesha2_terminate_mgr_send_terminate_seq_msg(env, rm_msg_ctx, rms_sequence_id,
                            internal_sequence_id, storage_mgr, seq_prop_mgr, create_seq_mgr, sender_mgr);
                }
            }

            if(internal_sequence_id)
            {
                AXIS2_FREE(env->allocator, internal_sequence_id);
            }
        }
    }
    else
    {
        sandesha2_terminate_seq_msg_processor_setup_highest_msg_nums(env, conf_ctx, storage_mgr,
                rmd_sequence_id, rm_msg_ctx, seq_prop_mgr, create_seq_mgr, sender_mgr);
    }

    /*sandesha2_terminate_mgr_clean_recv_side_after_terminate_msg(env, conf_ctx, rmd_sequence_id, storage_mgr,
            seq_prop_mgr, next_msg_mgr);*/

    /*transmit_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id,
        SANDESHA2_SEQ_PROP_SEQ_TERMINATED, AXIS2_VALUE_TRUE);
    sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, transmit_bean);
    sandesha2_seq_mgr_update_last_activated_time(env, rmd_sequence_id, storage_mgr);
    */

    /* We have no intention to pass this message beyond Sandesha2/C handler. So pause the message
     * context */
    sandesha2_msg_ctx_set_paused(rm_msg_ctx, env, AXIS2_TRUE);

    if(seq_prop_mgr)
    {
        sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
    }

    if(create_seq_mgr)
    {
        sandesha2_create_seq_mgr_free(create_seq_mgr, env);
    }

    if(sender_mgr)
    {
        sandesha2_sender_mgr_free(sender_mgr, env);
    }

    if(next_msg_mgr)
    {
        sandesha2_next_msg_mgr_free(next_msg_mgr, env);
    }

    if(storage_mgr)
    {
        sandesha2_storage_mgr_free(storage_mgr, env);
    }

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
                    "[sandesha2]Exit:sandesha2_terminate_seq_msg_processor_process_in_msg");

    return AXIS2_SUCCESS;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
rampart_shb_build_message(
    const axutil_env_t *env,
    axis2_msg_ctx_t *msg_ctx,
    rampart_context_t *rampart_context,
    axiom_soap_envelope_t *soap_envelope)
{
    axis2_status_t status = AXIS2_SUCCESS;
    axiom_soap_header_t *soap_header = NULL;
    axiom_node_t *soap_header_node = NULL;
    axiom_element_t *soap_header_ele = NULL;
    axiom_soap_header_block_t *sec_header_block = NULL;
    axiom_namespace_t *sec_ns_obj = NULL;
    axiom_node_t *sec_node =  NULL;
    axiom_element_t *sec_ele = NULL;
    axis2_bool_t server_side = AXIS2_FALSE;
	/* 
	 * sign parts list. Moved this up the building process. This was originally 
	 * in the rampart_sig_sign_message 
	 */ 
    axutil_array_list_t *sign_parts_list = NULL;
    AXIS2_ENV_CHECK(env,AXIS2_FAILURE);
    soap_header  = axiom_soap_envelope_get_header(soap_envelope, env);
    soap_header_node = axiom_soap_header_get_base_node(soap_header, env);
    soap_header_ele = (axiom_element_t *)axiom_node_get_data_element(
                          soap_header_node, env);


    sec_ns_obj =  axiom_namespace_create(env, RAMPART_WSSE_XMLNS,
                                         RAMPART_WSSE);
    sec_header_block = axiom_soap_header_add_header_block(soap_header,
                       env, RAMPART_SECURITY, sec_ns_obj); /* sec_ns_obj is cloned there */
    server_side = axis2_msg_ctx_get_server_side(msg_ctx, env);
    if(!sec_header_block)
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart][shb] Security header block is NULL");
		axiom_namespace_free(sec_ns_obj, env);
        return AXIS2_SUCCESS;
    }

    axiom_soap_header_block_set_must_understand_with_bool(sec_header_block,
            env, AXIS2_TRUE);

    sec_node = axiom_soap_header_block_get_base_node(sec_header_block, env);
    sec_ele = (axiom_element_t *)
              axiom_node_get_data_element(sec_node, env);

    sign_parts_list = axutil_array_list_create(env, 4);
    /*Timestamp Inclusion*/
    if(rampart_context_is_include_timestamp(rampart_context,env))
    {
        int ttl = -1;
        axis2_bool_t need_millisecond = AXIS2_TRUE;

        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart][shb] Building Timestamp Token");
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart][shb] Using default timeToLive value %d",
                       RAMPART_TIMESTAMP_TOKEN_DEFAULT_TIME_TO_LIVE);
        ttl = rampart_context_get_ttl(rampart_context,env);
        need_millisecond = rampart_context_get_need_millisecond_precision(rampart_context, env);

        status = rampart_timestamp_token_build(env, sec_node, ttl, need_millisecond);
        if (status == AXIS2_FAILURE)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                            "[rampart][shb] Timestamp Token build failed. ERROR");
			axiom_namespace_free(sec_ns_obj, env);
            return AXIS2_FAILURE;
        }
    }

    /*Check whether we need username token*/
    /*User name tokens includes in messages sent from client to server*/
    if(!axis2_msg_ctx_get_server_side(msg_ctx,env))
    {
        if(rampart_context_is_include_username_token(rampart_context,env))
        {

            /*Now we are passing rampart_context here so inside this method
            relevant parameters are extracted. */

            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart][shb] Building UsernameToken");
            status = rampart_username_token_build(
                        env,
                        rampart_context,
                        sec_node,
                        sec_ns_obj);
            if (status == AXIS2_FAILURE)
            {
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                                "[rampart][shb] UsernameToken build failed. ERROR");
				axiom_namespace_free(sec_ns_obj, env);
                return AXIS2_FAILURE;
            }
        }
    }

    /*Custom tokens are included if its available in the rampart context*/
    if(!axis2_msg_ctx_get_server_side(msg_ctx,env))
    {
        axutil_array_list_t *token_list = NULL;

        token_list = rampart_context_get_custom_tokens(rampart_context, env);
        if(token_list){
            int size = 0, i = 0;
            size = axutil_array_list_size(token_list, env);
            for (i = 0; i < size; i++){
                axiom_node_t *token_node = NULL;
                token_node = (axiom_node_t*)axutil_array_list_get(token_list, env, i);
                if(token_node){
                    axis2_status_t status = AXIS2_FAILURE;
                    status = axiom_node_add_child(sec_node, env, token_node); 
                    if(status != AXIS2_SUCCESS){
                        return AXIS2_FAILURE;
                    }
                }
            }
        }
    }

    if (rampart_context_is_include_supporting_token(rampart_context, env, server_side, AXIS2_FALSE, RP_PROPERTY_SAML_TOKEN))
    {        
        status = rampart_saml_supporting_token_build(env, rampart_context, sec_node, sign_parts_list);    
        if (status == AXIS2_FAILURE)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                            "[rampart][shb] SAML Supporting token build failed. ERROR");
            axutil_array_list_free(sign_parts_list, env);
			axiom_namespace_free(sec_ns_obj, env);
            return AXIS2_FAILURE;
        }
    }

	if (rampart_context_is_include_supporting_token(rampart_context, env, server_side, AXIS2_FALSE, RP_PROPERTY_ISSUED_TOKEN))
	{
		status = rampart_issued_supporting_token_build(rampart_context, env, sec_node, sign_parts_list);					
        if (status == AXIS2_FAILURE)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                            "[rampart][shb] Issued supporting token build failed. ERROR");
            axutil_array_list_free(sign_parts_list, env);
			axiom_namespace_free(sec_ns_obj, env);
            return AXIS2_FAILURE;
        }
	}

    /*Signature Confirmation support. Only in the server side*/
    if(axis2_msg_ctx_get_server_side(msg_ctx,env)){
        axis2_bool_t sign_conf_reqd = AXIS2_FALSE;
        /*Sign_conf_reqd <- Get from context <- policy*/
        sign_conf_reqd = rampart_context_is_sig_confirmation_reqd(rampart_context, env);
        if(sign_conf_reqd){
            status = rampart_sig_confirm_signature(env, msg_ctx, rampart_context, sec_node);
        }
    }


    /*check the binding*/
    if((rampart_context_get_binding_type(rampart_context,env)) == RP_PROPERTY_ASYMMETRIC_BINDING)
    {
        axis2_status_t status = AXIS2_FAILURE;

        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart][shb] Asymmetric Binding. ");
        status = rampart_shb_do_asymmetric_binding(env, msg_ctx, rampart_context, soap_envelope, sec_node, sec_ns_obj, sign_parts_list);
		axiom_namespace_free(sec_ns_obj, env);
        if(AXIS2_FAILURE == status){
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart][shb] Asymmetric Binding failed");
            if(axis2_msg_ctx_get_server_side(msg_ctx,env)){
                AXIS2_ERROR_SET(env->error, RAMPART_ERROR_INVALID_SECURITY , AXIS2_FAILURE);
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,  "[rampart][shb] %s", AXIS2_ERROR_GET_MESSAGE(env->error));
                rampart_create_fault_envelope(env, RAMPART_FAULT_INVALID_SECURITY,
                                  " Asymmetric Binding failed. Check configurations ", RAMPART_FAULT_IN_POLICY, msg_ctx);
            }
            axutil_array_list_free(sign_parts_list, env);
            return AXIS2_FAILURE;
        }else{
            axutil_array_list_free(sign_parts_list, env);
            return AXIS2_SUCCESS;
        }

    }
    else if((rampart_context_get_binding_type(rampart_context,env)) == RP_PROPERTY_SYMMETRIC_BINDING)
    {
        axis2_status_t status = AXIS2_FAILURE;

        /*Do Symmetric_binding specific things*/
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart][shb] Symmetric Binding. ");
        status = rampart_shb_do_symmetric_binding(env, msg_ctx, rampart_context, soap_envelope, sec_node, sec_ns_obj, sign_parts_list);
		axiom_namespace_free(sec_ns_obj, env);
        if(AXIS2_FAILURE == status){
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[rampart][shb] Symmetric Binding failed");
            if(axis2_msg_ctx_get_server_side(msg_ctx,env)){
                AXIS2_ERROR_SET(env->error, RAMPART_ERROR_INVALID_SECURITY, AXIS2_FAILURE);
                rampart_create_fault_envelope(env, RAMPART_FAULT_INVALID_SECURITY,
                                  " Symmetric Binding failed. Check configurations ", RAMPART_FAULT_IN_POLICY, msg_ctx);
            }
            axutil_array_list_free(sign_parts_list, env);
            return AXIS2_FAILURE;
        }else{
            axutil_array_list_free(sign_parts_list, env);
            return AXIS2_SUCCESS;
        }
    }
    else if((rampart_context_get_binding_type(rampart_context,env)) == RP_PROPERTY_TRANSPORT_BINDING)
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[rampart][shb] Using transport binding");
		axiom_namespace_free(sec_ns_obj, env);
        axutil_array_list_free(sign_parts_list, env);
        return AXIS2_SUCCESS;
    }else{
        axutil_array_list_free(sign_parts_list, env);
		axiom_namespace_free(sec_ns_obj, env);
        return AXIS2_FAILURE;
    }
}
Пример #8
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
sandesha2_seq_mgr_setup_new_outgoing_sequence(
    const axutil_env_t *env,
    axis2_msg_ctx_t *first_app_msg,
    axis2_char_t *internal_sequence_id,
    axis2_char_t *spec_version,
    sandesha2_seq_property_mgr_t *seq_prop_mgr)
{
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_char_t *addr_ns_val = NULL;
    axutil_property_t *property = NULL;
    sandesha2_seq_property_bean_t *addr_ns_bean = NULL;
    axis2_char_t *anon_uri = NULL;
    axis2_endpoint_ref_t *to_epr = NULL;
    axis2_char_t *acks_to_str = NULL;
    sandesha2_seq_property_bean_t *to_bean = NULL;
    sandesha2_seq_property_bean_t *reply_to_bean = NULL;
    sandesha2_seq_property_bean_t *acks_to_bean = NULL;
    sandesha2_seq_property_bean_t *msgs_bean = NULL;
    axis2_char_t *transport_to = NULL;
    axis2_endpoint_ref_t *reply_to_epr = NULL;
    axis2_bool_t is_svr_side = AXIS2_FALSE;
   
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:sandesha2_seq_mgr_setup_new_outgoing_sequence");

    AXIS2_PARAM_CHECK(env->error, first_app_msg, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, internal_sequence_id, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, spec_version, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, seq_prop_mgr, AXIS2_FAILURE);
    
    conf_ctx = axis2_msg_ctx_get_conf_ctx(first_app_msg, env);
    
    property = axis2_msg_ctx_get_property(first_app_msg, env, AXIS2_WSA_VERSION);
    if(property)
    {
        addr_ns_val = axutil_property_get_value(property, env);
    }

    if(!addr_ns_val)
    {
        axis2_op_ctx_t *op_ctx = NULL;
        axis2_msg_ctx_t *req_msg_ctx = NULL;

        op_ctx = axis2_msg_ctx_get_op_ctx(first_app_msg, env);
        req_msg_ctx =  axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN);

        if(req_msg_ctx)
        {
            property = axis2_msg_ctx_get_property(req_msg_ctx, env, AXIS2_WSA_VERSION);
            if(property)
            {
                addr_ns_val = axutil_property_get_value(property, env);
            }
        }
    }

    if(!addr_ns_val)
    {
        addr_ns_val = AXIS2_WSA_NAMESPACE;
    }
        
    addr_ns_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, 
            SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, addr_ns_val);

    sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, addr_ns_bean);
    if(addr_ns_bean)
    {
        sandesha2_seq_property_bean_free(addr_ns_bean, env);
    }

    anon_uri = sandesha2_spec_specific_consts_get_anon_uri(env, addr_ns_val);
    
    to_epr = axis2_msg_ctx_get_to(first_app_msg, env);
    property = axis2_msg_ctx_get_property(first_app_msg, env, SANDESHA2_CLIENT_ACKS_TO);
    if(property)
    {
        acks_to_str = axutil_property_get_value(property, env);
    }

    if (to_epr)
    {
        to_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, 
                SANDESHA2_SEQ_PROP_TO_EPR, (axis2_char_t*)axis2_endpoint_ref_get_address(to_epr, 
                       env));
        sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, to_bean);
        sandesha2_seq_property_bean_free(to_bean, env);
    }
    
    is_svr_side = axis2_msg_ctx_get_server_side(first_app_msg, env);

    if(is_svr_side)
    {
        axis2_op_ctx_t *op_ctx = NULL;
        axis2_msg_ctx_t *req_msg_ctx = NULL;
        
        op_ctx = axis2_msg_ctx_get_op_ctx(first_app_msg, env);

        req_msg_ctx =  axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN);
        if(!req_msg_ctx)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                    "[sandesha2] Cannot find the request message from the operation context");
            return AXIS2_FAILURE;
        }

        reply_to_epr = axis2_msg_ctx_get_to(req_msg_ctx, env);

        if(reply_to_epr)
        {
            const axis2_char_t *temp_epr_addr = axis2_endpoint_ref_get_address(reply_to_epr, env);
            
            if(temp_epr_addr)
            {
                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "temp_epr_address:%s", temp_epr_addr);
                acks_to_str = (axis2_char_t *) temp_epr_addr;
                reply_to_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, 
                    SANDESHA2_SEQ_PROP_REPLY_TO_EPR, (axis2_char_t*) temp_epr_addr);
                sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, reply_to_bean);
                sandesha2_seq_property_bean_free(reply_to_bean, env);
            }
        }
        else
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                    "[sandesha2] Cannot get request message from the operation context");

            return AXIS2_FAILURE;
        }        
    }
    else /* Not server side */
    {
        reply_to_epr = axis2_msg_ctx_get_reply_to(first_app_msg, env);

        if(reply_to_epr)
        {
            const axis2_char_t *temp_epr_addr = axis2_endpoint_ref_get_address(reply_to_epr, env);
            if(temp_epr_addr)
            {
                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "temp_epr_address:%s", temp_epr_addr);
                reply_to_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, 
                    SANDESHA2_SEQ_PROP_REPLY_TO_EPR, (axis2_char_t*) temp_epr_addr);
                sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, reply_to_bean);
                sandesha2_seq_property_bean_free(reply_to_bean, env);
            }
        } 
    }

    if(!acks_to_str)
    {
        acks_to_str = anon_uri;
    }
    
    acks_to_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, 
            SANDESHA2_SEQ_PROP_ACKS_TO_EPR, acks_to_str);

    msgs_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, 
                        SANDESHA2_SEQ_PROP_CLIENT_COMPLETED_MESSAGES, "");
    if(msgs_bean)
    {
        sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, msgs_bean);
        sandesha2_seq_property_bean_free(msgs_bean, env);
    }
    
    if(acks_to_bean)
    {
        sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, acks_to_bean);
        sandesha2_seq_property_bean_free(acks_to_bean, env);
    }

    transport_to = axis2_msg_ctx_get_transport_url(first_app_msg, env);
    
    if(transport_to)
    {
        sandesha2_seq_property_bean_t *transport_to_bean = NULL;
        transport_to_bean = sandesha2_seq_property_bean_create_with_data(env, internal_sequence_id, 
                SANDESHA2_SEQ_PROP_TRANSPORT_TO, transport_to);

        sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, transport_to_bean);
    }

    sandesha2_seq_mgr_update_last_activated_time(env, internal_sequence_id, seq_prop_mgr);

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:sandesha2_seq_mgr_setup_new_outgoing_sequence");

    return AXIS2_SUCCESS;
}