axis2_bool_t AXIS2_CALL
sandesha2_permanent_invoker_mgr_update(
    sandesha2_invoker_mgr_t *invoker_mgr,
    const axutil_env_t *env,
    sandesha2_invoker_bean_t *bean)
{
    /*axis2_char_t *ref_key = NULL;*/
    axis2_char_t *sql_update = NULL;
    axis2_bool_t ret = AXIS2_FALSE;
    sandesha2_permanent_invoker_mgr_t *invoker_mgr_impl = NULL;
	axis2_char_t *msg_ctx_ref_key = NULL;
	long msg_no;
	axis2_char_t *seq_id = NULL;
	axis2_bool_t is_invoked = AXIS2_FALSE;
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
        "[sandesha2]Entry:sandesha2_permanent_invoker_mgr_update");
    AXIS2_PARAM_CHECK(env->error, bean, AXIS2_FALSE);
    msg_ctx_ref_key = sandesha2_invoker_bean_get_msg_ctx_ref_key(
        bean, env);
    msg_no = sandesha2_invoker_bean_get_msg_no(bean, env);
	seq_id = sandesha2_invoker_bean_get_seq_id(bean, env);
    is_invoked = sandesha2_invoker_bean_is_invoked(bean, env);

    invoker_mgr_impl = SANDESHA2_INTF_TO_IMPL(invoker_mgr);

    sprintf(sql_update, "update invoker set msg_no=%ld, seq_id='%s',"\
        "is_invoked=%d where msg_ctx_ref_key='%s';", msg_no, seq_id, is_invoked, 
        msg_ctx_ref_key);
    ret = sandesha2_permanent_bean_mgr_update(invoker_mgr_impl->bean_mgr, env, 
        sql_update);

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
        "[sandesha2]Exit:sandesha2_permanent_invoker_mgr_update");
    return ret;
}
axis2_bool_t AXIS2_CALL
sandesha2_permanent_invoker_mgr_insert(
    sandesha2_invoker_mgr_t *invoker_mgr,
    const axutil_env_t *env,
    sandesha2_invoker_bean_t *bean)
{
    axis2_char_t sql_insert[1024];
    axis2_bool_t ret = AXIS2_FALSE;
    sandesha2_permanent_invoker_mgr_t *invoker_mgr_impl = NULL;
	axis2_char_t *msg_ctx_ref_key  = NULL;
	long msg_no;
	axis2_char_t *seq_id = NULL;
	axis2_bool_t is_invoked = AXIS2_FALSE;
	
	AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
        "[sandesha2]Entry:sandesha2_permanent_invoker_mgr_insert");
    AXIS2_PARAM_CHECK(env->error, bean, AXIS2_FALSE);
    msg_ctx_ref_key = sandesha2_invoker_bean_get_msg_ctx_ref_key(
        bean, env);
	msg_no= sandesha2_invoker_bean_get_msg_no(bean, env);
    seq_id = sandesha2_invoker_bean_get_seq_id(bean, env);
    is_invoked = sandesha2_invoker_bean_is_invoked(bean, env);

    invoker_mgr_impl = SANDESHA2_INTF_TO_IMPL(invoker_mgr);

    sprintf(sql_insert, "insert into invoker(msg_ctx_ref_key, msg_no, seq_id,"\
        "is_invoked) values('%s', %ld, '%s', %d);", msg_ctx_ref_key, msg_no, 
        seq_id, is_invoked);
    ret = sandesha2_permanent_bean_mgr_insert(invoker_mgr_impl->bean_mgr, env,
        sql_insert);
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
        "[sandesha2]Exit:sandesha2_permanent_invoker_mgr_insert");
    return ret;
}
示例#3
0
文件: svc.c 项目: Denisss025/wsfcpp
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_svc_is_module_engaged(
    axis2_svc_t * svc,
    const axutil_env_t * env,
    axutil_qname_t * module_qname)
{
    int i = 0, size = 0;
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_svc_is_module_engaged");
    size = axutil_array_list_size(svc->engaged_module_list, env);
    for(i = 0; i < size; i++)
    {
        const axutil_qname_t *module_qname_l = NULL;
        axis2_module_desc_t *module_desc_l = NULL;

        module_desc_l = (axis2_module_desc_t *)axutil_array_list_get(svc->engaged_module_list, env,
                        i);
        module_qname_l = axis2_module_desc_get_qname(module_desc_l, env);

        if(axutil_qname_equals(module_qname, env, module_qname_l))
        {
            return AXIS2_TRUE;
        }
    }
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_svc_is_module_engaged");
    return AXIS2_FALSE;
}
示例#4
0
AXIS2_EXTERN void AXIS2_CALL
savan_xpath_filter_mod_free(
    savan_filter_mod_t *filtermod,
    const axutil_env_t *env)
{
    savan_xpath_filter_mod_t *filtermodimpl = NULL;
    filtermodimpl = SAVAN_INTF_TO_IMPL(filtermod);

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Entry:savan_xpath_filter_mod_free");

    if(filtermodimpl->dialect)
    {
        AXIS2_FREE(env->allocator, filtermodimpl->dialect);
        filtermodimpl->dialect = NULL;
    }

    filtermodimpl->conf = NULL;

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

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Exit:savan_xpath_filter_mod_free");
}
示例#5
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_engine_invoke_phases(
    axis2_engine_t * engine,
    const axutil_env_t * env,
    axutil_array_list_t * phases,
    axis2_msg_ctx_t * msg_ctx)
{
    int i = 0;
    int count = 0;
    axis2_status_t status = AXIS2_SUCCESS;

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

    if(phases)
        count = axutil_array_list_size(phases, env);
    for(i = 0; (i < count && !(axis2_msg_ctx_is_paused(msg_ctx, env))); i++)
    {
        axis2_phase_t *phase = (axis2_phase_t *)axutil_array_list_get(phases, env, i);

        status = axis2_phase_invoke(phase, env, msg_ctx);

        if(status != AXIS2_SUCCESS)
        {
            const axis2_char_t *phase_name = axis2_phase_get_name(phase, env);
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invoking phase %s failed", phase_name);
            return status;
        }
    }
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "End:axis2_engine_invoke_phases");
    return AXIS2_SUCCESS;
}
axis2_status_t AXIS2_CALL
axis2_statistics_admin_global_request_count_handler_invoke(struct axis2_handler *handler, 
                        const axutil_env_t *env,
                        struct axis2_msg_ctx *msg_ctx)
{
    axis2_status_t status = AXIS2_SUCCESS;
    axis2_svc_t *svc = NULL;
    
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[adminservices] Start:axis2_statistics_admin_global_request_count_handler_invoke");
    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);

    svc = axis2_msg_ctx_get_svc(msg_ctx, env);
    if(svc)
    {
        long *time_now = NULL;
        axutil_property_t *property = NULL;
       
        time_now = AXIS2_MALLOC(env->allocator, sizeof(long));
        *time_now = service_admin_util_get_current_time_in_millis(env);
        property = axutil_property_create_with_args(env, 0, 0, 0, time_now);
        axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_REQUEST_RECEIVED_TIME, property);
    }
    
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[adminservices] End:axis2_statistics_admin_global_request_count_handler_invoke");
    
    return status;
}
示例#7
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_engine_receive_fault(
    axis2_engine_t * engine,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axis2_op_ctx_t *op_ctx = NULL;

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

    op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);

    if(!op_ctx)
    {
        /* If we do not have an op context that means this may be an incoming
         dual channel response. So try to dispatch the service */
        axis2_conf_ctx_t *conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
        if(conf_ctx)
        {
            axis2_conf_t *conf = axis2_conf_ctx_get_conf(conf_ctx, env);
            if(conf)
            {
                axutil_array_list_t *phases =
                    axis2_conf_get_in_phases_upto_and_including_post_dispatch(conf, env);
                if(phases)
                {
                    if(axis2_msg_ctx_is_paused(msg_ctx, env))
                    {
                        axis2_engine_resume_invocation_phases(engine, env, phases, msg_ctx);
                    }
                    else
                    {
                        axis2_engine_invoke_phases(engine, env, phases, msg_ctx);
                    }
                }
            }
        }
    }

    op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
    /* Find and execute the fault in flow handlers */
    if(op_ctx)
    {
        axis2_op_t *op = axis2_op_ctx_get_op(op_ctx, env);
        axutil_array_list_t *phases = axis2_op_get_fault_in_flow(op, env);
        if(axis2_msg_ctx_is_paused(msg_ctx, env))
        {
            axis2_engine_resume_invocation_phases(engine, env, phases, msg_ctx);
        }
        else
        {
            axis2_engine_invoke_phases(engine, env, phases, msg_ctx);
        }
    }
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_engine_receive_fault");
    return AXIS2_SUCCESS;
}
示例#8
0
axis2_status_t AXIS2_CALL
axis2_statistics_admin_out_op_count_handler_invoke(struct axis2_handler *handler, 
                        const axutil_env_t *env,
                        struct axis2_msg_ctx *msg_ctx)
{
    axis2_status_t status = AXIS2_SUCCESS;
    service_admin_counter_t *counter = NULL;
    axutil_param_t *param = NULL;
    axis2_op_t *op = NULL;
    axis2_svc_t *svc = NULL;
    const axis2_char_t *svc_name = NULL;
    
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[adminservices] Start:axis2_statistics_admin_out_op_count_handler_invoke");
    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);

    svc = axis2_msg_ctx_get_svc(msg_ctx, env);
    if(svc)
    {
        svc_name = axis2_svc_get_name(svc, env);
    }
    op = axis2_msg_ctx_get_op(msg_ctx, env);
    if(op)
    {
        param = axis2_op_get_param(op, env, AXIS2_OUT_OPERATION_COUNTER);
        if(param)
        {
            counter = axutil_param_get_value(param, env);
            if(counter)
            {
                service_admin_counter_increment(counter, env, msg_ctx);
            }
        }
        else
        {
            axis2_char_t *op_name = NULL;

            op_name = axutil_qname_get_localpart(axis2_op_get_qname(op, env), env);
            axutil_allocator_switch_to_global_pool(env->allocator);
            counter = service_admin_counter_create(env, svc_name, op_name);
            if(counter)
            {
                service_admin_counter_increment(counter, env, msg_ctx);
                param = axutil_param_create(env, AXIS2_OUT_OPERATION_COUNTER, counter);
                if(param)
                {
                    axis2_op_add_param(op, env, param);
                }
            }
            axutil_allocator_switch_to_local_pool(env->allocator);
        }
    }
    
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[adminservices] End:axis2_statistics_admin_out_op_count_handler_invoke");
    
    return status;
}
示例#9
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;
}
static axis2_bool_t AXIS2_CALL
sandesha2_permanent_invoker_mgr_match(
    sandesha2_invoker_mgr_t *invoker_mgr,
    const axutil_env_t *env,
    sandesha2_invoker_bean_t *bean,
    sandesha2_invoker_bean_t *candidate)
{
    axis2_bool_t select = AXIS2_TRUE;
    axis2_char_t *ref_key = NULL;
    axis2_char_t *temp_ref_key = NULL;
    axis2_char_t *seq_id = NULL;
    axis2_char_t *temp_seq_id = NULL;
    long msg_no = 0;
    long temp_msg_no = 0;
    axis2_bool_t is_invoked = AXIS2_FALSE;
    axis2_bool_t temp_is_invoked = AXIS2_FALSE;
    
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
        "[sandesha2]Entry:sandesha2_permanent_create_invoker_mgr_match");
    ref_key = sandesha2_invoker_bean_get_msg_ctx_ref_key(bean, env);
    temp_ref_key = sandesha2_invoker_bean_get_msg_ctx_ref_key(candidate, env);
    if(ref_key && temp_ref_key && 0 != axutil_strcmp(ref_key, temp_ref_key))
    {
        select = AXIS2_FALSE;
    }
    seq_id = sandesha2_invoker_bean_get_seq_id(
        (sandesha2_invoker_bean_t *) bean, env);
    temp_seq_id = sandesha2_invoker_bean_get_seq_id(
        (sandesha2_invoker_bean_t *) candidate, env);
    if(seq_id && temp_seq_id && 0 != axutil_strcmp(seq_id, temp_seq_id))
    {
        select = AXIS2_FALSE;
    }
    msg_no = sandesha2_invoker_bean_get_msg_no(
        (sandesha2_invoker_bean_t *) bean, env);
    temp_msg_no = sandesha2_invoker_bean_get_msg_no(
        (sandesha2_invoker_bean_t *) candidate, env);
    if(msg_no != 0 && (msg_no != temp_msg_no))
    {
        select = AXIS2_FALSE;
    }
    is_invoked = sandesha2_invoker_bean_is_invoked(
        (sandesha2_invoker_bean_t *) bean, env);
    temp_is_invoked = sandesha2_invoker_bean_is_invoked(
        (sandesha2_invoker_bean_t *) candidate, env);
    if(is_invoked != temp_is_invoked)
    {
        select = AXIS2_FALSE;
    }
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
        "[sandesha2]Exit:sandesha2_permanent_create_invoker_mgr_match");
    return select;
}
示例#11
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_engine_resume_invocation_phases(
    axis2_engine_t * engine,
    const axutil_env_t * env,
    axutil_array_list_t * phases,
    axis2_msg_ctx_t * msg_ctx)
{
    int i = 0;
    int count = 0;
    axis2_bool_t found_match = AXIS2_FALSE;

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

    axis2_msg_ctx_set_paused(msg_ctx, env, AXIS2_FALSE);

    count = axutil_array_list_size(phases, env);

    for(i = 0; i < count && !(axis2_msg_ctx_is_paused(msg_ctx, env)); i++)
    {
        axis2_phase_t *phase = (axis2_phase_t *)axutil_array_list_get(phases, env, i);
        const axis2_char_t *phase_name = axis2_phase_get_name(phase, env);
        const axis2_char_t *paused_phase_name = axis2_msg_ctx_get_paused_phase_name(msg_ctx, env);
        /* Skip invoking handlers until we find the paused phase */
        if(phase_name && paused_phase_name && 0 == axutil_strcmp(phase_name, paused_phase_name))
        {
            int paused_handler_i = -1;
            found_match = AXIS2_TRUE;

            paused_handler_i = axis2_msg_ctx_get_current_handler_index(msg_ctx, env);
            /* Invoke the paused handler and rest of the handlers of the paused
             * phase */
            axis2_phase_invoke_start_from_handler(phase, env, paused_handler_i, msg_ctx);
        }
        else
        {
            /* Now we have found the paused phase and invoked the rest of the
             * handlers of that phase, invoke all the phases after that */
            if(found_match)
            {
                axis2_phase_invoke(phase, env, msg_ctx);
            }
        }
    }

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "End:axis2_engine_resume_invocation_phases");
    return AXIS2_SUCCESS;
}
axutil_array_list_t *AXIS2_CALL
sandesha2_permanent_invoker_mgr_find(
    sandesha2_invoker_mgr_t *invoker_mgr,
    const axutil_env_t *env,
    sandesha2_invoker_bean_t *bean)
{
    int i = 0;
    int size = 0;
    int match_list_size = 0;
    axutil_array_list_t *match_list = NULL;
    axutil_array_list_t *find_list = NULL;
    axis2_char_t *sql_find = NULL;
    axutil_array_list_t *ret = NULL;
    sandesha2_permanent_invoker_mgr_t *invoker_mgr_impl = NULL;
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
        "[sandesha2]Entry:sandesha2_permanent_invoker_mgr_find");
    invoker_mgr_impl = SANDESHA2_INTF_TO_IMPL(invoker_mgr);
    sql_find = "select msg_ctx_ref_key,msg_no, seq_id,is_invoked from invoker;";
    find_list = sandesha2_permanent_bean_mgr_find(invoker_mgr_impl->bean_mgr, env, 
        sandesha2_invoker_find_callback, sql_find);
    if(find_list)
        size = axutil_array_list_size(find_list, env);
    if(!bean)
        return find_list;
    match_list = axutil_array_list_create(env, 0);
    for(i = 0; i < size; i++)
    {
        sandesha2_invoker_bean_t *candidate = NULL;
        candidate = (sandesha2_invoker_bean_t *) 
            axutil_array_list_get(find_list, env, i);
        if(sandesha2_permanent_invoker_mgr_match(invoker_mgr, env, bean, 
            candidate))
        {
            match_list_size++;
            axutil_array_list_add(match_list, env, candidate);
        }
        else
        {
            sandesha2_invoker_bean_free(candidate, env);
        }
    }
    if(find_list)
        axutil_array_list_free(find_list, env);

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
        "[sandesha2]Exit:sandesha2_permanent_invoker_mgr_find");
    return ret;
}
示例#13
0
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
savan_xpath_filter_mod_apply(
    savan_filter_mod_t *filtermod,
    const axutil_env_t *env,
    savan_subscriber_t *subscriber,
    axiom_node_t *payload)
{
    axis2_char_t *payload_string = NULL;
    xmlDocPtr payload_doc = NULL;
    xsltStylesheetPtr xslt_template_filter = NULL;
    xmlChar *xfilter = NULL;
    xmlDocPtr result_doc;
    savan_xpath_filter_mod_t *filtermodimpl = NULL;

    filtermodimpl = SAVAN_INTF_TO_IMPL(filtermod);

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
            "[savan] Entry:savan_xpath_filter_mod_apply");

	xfilter = (xmlChar *) savan_subscriber_get_filter(subscriber, env);
	if(!xfilter)
	{
		return AXIS2_FALSE;
	}

    payload_string = axiom_node_to_string(payload, env);
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
        "[savan] payload_string before applying filter %s:%s", xfilter, payload_string);

    payload_doc = (xmlDocPtr)xmlParseDoc((xmlChar*)payload_string);

    xslt_template_filter = (xsltStylesheetPtr) savan_xpath_filter_mod_get_filter_template(env, 
            filtermodimpl->filter_template_path, xfilter);

    result_doc = (xmlDocPtr)xsltApplyStylesheet(xslt_template_filter, payload_doc, NULL);

    if(result_doc)
    {
        /*free(payload_string);*/ /* In apache freeing this give seg fault:damitha */
	    xmlFreeDoc(result_doc);
        return AXIS2_TRUE;
    }

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Exit:savan_xpath_filter_mod_apply");
    return AXIS2_FALSE;
}
示例#14
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_svc_engage_module(
    axis2_svc_t * svc,
    const axutil_env_t * env,
    axis2_module_desc_t * module_desc,
    axis2_conf_t * conf)
{
    axis2_phase_resolver_t *phase_resolver = NULL;
    axis2_status_t status = AXIS2_FAILURE;
    const axis2_char_t *svcname = NULL;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_svc_engage_module");

    AXIS2_PARAM_CHECK(env->error, module_desc, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, conf, AXIS2_FAILURE);

    svcname = axis2_svc_get_name(svc, env);
    phase_resolver = axis2_phase_resolver_create_with_config(env, conf);
    if (!phase_resolver)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
            "Creating phase resolver failed for service %s", svcname);

        return AXIS2_FAILURE;
    }

    status = axis2_phase_resolver_engage_module_to_svc(phase_resolver, env, svc, module_desc);
    if (status)
    {
        const axutil_qname_t *qname = NULL;
        status = axutil_array_list_add(svc->engaged_module_list, env, module_desc);
        qname = axis2_module_desc_get_qname(module_desc, env);
        axis2_svc_add_module_qname(svc, env, qname);
    }

    if (phase_resolver)
    {
        axis2_phase_resolver_free(phase_resolver, env);
    }

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

    return status;
}
示例#15
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_engine_resume_send(
    axis2_engine_t * engine,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axis2_op_ctx_t *op_ctx = NULL;
    axutil_array_list_t *phases = NULL;
    axis2_status_t status = AXIS2_FAILURE;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Start:axis2_engine_resume_send");
    /* Invoke the phases */
    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)
        {
            phases = axis2_op_get_out_flow(op, env);
        }
    }
    axis2_engine_resume_invocation_phases(engine, env, phases, msg_ctx);

    /* Invoking transport sender */
    if(!axis2_msg_ctx_is_paused(msg_ctx, env))
    {
        /* Write the message to the wire */
        axis2_transport_out_desc_t *transport_out = NULL;
        axis2_transport_sender_t *sender = NULL;
        transport_out = axis2_msg_ctx_get_transport_out_desc(msg_ctx, env);
        if(transport_out)
        {
            sender = axis2_transport_out_desc_get_sender(transport_out, env);
            if(sender)
            {
                status = AXIS2_TRANSPORT_SENDER_INVOKE(sender, env, msg_ctx);
            }
        }
    }
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_engine_resume_send");
    return status;
}
示例#16
0
AXIS2_EXTERN void AXIS2_CALL
savan_default_publisher_free(
    savan_publisher_t *publishermod,
    const axutil_env_t *env)
{
    savan_default_publisher_t *publishermodimpl = NULL;
    publishermodimpl = SAVAN_INTF_TO_IMPL(publishermod);

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Entry:savan_default_publisher_free");

    publishermodimpl->conf = NULL;

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

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Exit:savan_default_publisher_free");
}
示例#17
0
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
sandesha2_seq_mgr_has_seq_timedout(
    const axutil_env_t *env,
    axis2_char_t *property_key,
    sandesha2_seq_property_mgr_t *seq_prop_mgr,
    axis2_svc_t *svc)
{
    sandesha2_property_bean_t *property_bean = NULL;
    axis2_bool_t seq_timedout = AXIS2_FALSE;
    long last_activated_time = -1;
    long current_time = -1;
    long timeout_interval = -1;
    
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:sandesha2_seq_mgr_has_seq_timedout");

    AXIS2_PARAM_CHECK(env->error, property_key, AXIS2_FALSE);
    AXIS2_PARAM_CHECK(env->error, seq_prop_mgr, AXIS2_FALSE);
    
    property_bean = sandesha2_utils_get_property_bean(env, svc);
    timeout_interval = sandesha2_property_bean_get_inactive_timeout_interval(property_bean, env);
    if(timeout_interval <= 0)
    {
        return AXIS2_FALSE;
    }

    last_activated_time = sandesha2_seq_mgr_get_last_activated_time(env, property_key, seq_prop_mgr);
    current_time = sandesha2_utils_get_current_time_in_millis(env);

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

    if(last_activated_time > 0 && ((last_activated_time + timeout_interval) < current_time))
    {
        seq_timedout = AXIS2_TRUE;
    }

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

    return seq_timedout;
}
sandesha2_invoker_bean_t *AXIS2_CALL
sandesha2_permanent_invoker_mgr_retrieve(
    sandesha2_invoker_mgr_t *invoker_mgr,
    const axutil_env_t *env,
    axis2_char_t *key)
{
    axis2_char_t sql_retrieve[256];
    sandesha2_invoker_bean_t *bean = NULL;
    sandesha2_permanent_invoker_mgr_t *invoker_mgr_impl = NULL;
    AXIS2_PARAM_CHECK(env->error, key, AXIS2_FALSE);
    invoker_mgr_impl = SANDESHA2_INTF_TO_IMPL(invoker_mgr);
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
        "[sandesha2]Entry:sandesha2_permanent_invoker_mgr_retrieve");
    sprintf(sql_retrieve, "select msg_ctx_ref_key, msg_no, seq_id, is_invoked"\
        " from invoker where msg_ctx_ref_key='%s'", key);
    sandesha2_permanent_bean_mgr_retrieve(invoker_mgr_impl->bean_mgr, env, 
        sandesha2_invoker_retrieve_callback, sql_retrieve);
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
        "[sandesha2]Exit:sandesha2_permanent_invoker_mgr_retrieve");
    return bean;
}
示例#19
0
axis2_status_t AXIS2_CALL
mod_sandesha2_init(
    axis2_module_t *module,
    const axutil_env_t *env,
    axis2_conf_ctx_t *conf_ctx,
    axis2_module_desc_t *module_desc)
{
    /*sandesha2_property_bean_t *property_bean = NULL;
    axutil_param_t *param = NULL;
    axis2_conf_t *conf = NULL;*/
    axis2_ctx_t *ctx = NULL;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[sandesha2] Entry:mod_sandesha2_init");
    AXIS2_PARAM_CHECK(env->error, conf_ctx, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, module_desc, AXIS2_FAILURE);

    sandesha2_error_init();
    /*property_bean = sandesha2_property_mgr_load_properties_from_module_desc(env, module_desc);
    if(!property_bean)
    {
        property_bean = sandesha2_property_mgr_load_properties_from_def_values(env);
    }

    param = axutil_param_create(env, SANDESHA2_SANDESHA_PROPERTY_BEAN, property_bean);
    axutil_param_set_value_free(param, env, sandesha2_property_bean_free_void_arg);

    conf = axis2_conf_ctx_get_conf(conf_ctx, env);
    axis2_conf_add_param(conf, env, param);*/

    ctx = axis2_conf_ctx_get_base(conf_ctx, env);
    axis2_ctx_set_property(ctx, env, SANDESHA2_INMEMORY_STORAGE_MGR, NULL);
    axis2_ctx_set_property(ctx, env, SANDESHA2_PERMANENT_STORAGE_MGR, NULL);

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

    return AXIS2_SUCCESS;
}
示例#20
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;
}
示例#21
0
static axis2_status_t AXIS2_CALL
axis2_msg_recv_receive_impl(
    axis2_msg_recv_t * msg_recv,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx,
    void *callback_recv_param)
{
    axis2_msg_ctx_t *out_msg_ctx = NULL;
    axis2_engine_t *engine = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_op_ctx_t *op_ctx = NULL;
    axis2_svc_ctx_t *svc_ctx = NULL;
    axis2_status_t status = AXIS2_FAILURE;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[axis2]Entry:axis2_msg_recv_receive_impl");
    out_msg_ctx = axis2_core_utils_create_out_msg_ctx(env, msg_ctx);
    if(!out_msg_ctx)
    {
        return AXIS2_FAILURE;
    }
    op_ctx = axis2_msg_ctx_get_op_ctx(out_msg_ctx, env);
    if(!op_ctx)
    {
        axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
        axis2_msg_ctx_free(out_msg_ctx, env);
        return AXIS2_FAILURE;
    }

    status = axis2_op_ctx_add_msg_ctx(op_ctx, env, out_msg_ctx);
    if(!status)
    {
        axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
        axis2_msg_ctx_free(out_msg_ctx, env);
        return status;
    }
    status = axis2_op_ctx_add_msg_ctx(op_ctx, env, msg_ctx);

    if(!status)
    {
        return status;
    }

    status = axis2_msg_recv_invoke_business_logic(msg_recv, env, msg_ctx, out_msg_ctx);
    if(AXIS2_SUCCESS != status)
    {
        axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
        axis2_msg_ctx_free(out_msg_ctx, env);
        return status;
    }
    svc_ctx = axis2_op_ctx_get_parent(op_ctx, env);
    conf_ctx = axis2_svc_ctx_get_conf_ctx(svc_ctx, env);
    engine = axis2_engine_create(env, conf_ctx);
    if(!engine)
    {
        axis2_msg_ctx_free(out_msg_ctx, env);
        return AXIS2_FAILURE;
    }
    if(axis2_msg_ctx_get_soap_envelope(out_msg_ctx, env))
    {
        axiom_soap_envelope_t *soap_envelope = axis2_msg_ctx_get_soap_envelope(out_msg_ctx, env);
        if(soap_envelope)
        {
            axiom_soap_body_t *body = axiom_soap_envelope_get_body(soap_envelope, env);
            if(body)
            {
                /* in case of a SOAP fault, we got to return failure so that
                 transport gets to know that it should send 500 */
                if(axiom_soap_body_has_fault(body, env))
                {
                    status = AXIS2_FAILURE;
                    axis2_msg_ctx_set_fault_soap_envelope(msg_ctx, env, soap_envelope);
                    axis2_msg_ctx_set_soap_envelope(out_msg_ctx, env, NULL);
                }
                else
                {
                    /* if it is two way and not a fault then send through engine.
                     if it is one way we do not need to do an engine send */
                    status = axis2_engine_send(engine, env, out_msg_ctx);
                }
            }
        }
    }
    axis2_engine_free(engine, env);

    /* Reset the out message context to avoid double freeing at http worker. For example if this is
     * not done here both in and out message context will try to free the transport out stream 
     * which will result in memory corruption.
     */
    if(!axis2_msg_ctx_is_paused(out_msg_ctx, env) && !axis2_msg_ctx_is_keep_alive(out_msg_ctx, env))
    {
        axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
    }
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[axis2]Exit:axis2_msg_recv_receive_impl");
    return status;
    (void)callback_recv_param;
}
示例#22
0
static axis2_status_t
savan_default_publisher_publish_to_subscriber(
    savan_publisher_t *publishermod,
    const axutil_env_t *env,
    axis2_svc_client_t *svc_client,
    savan_subscriber_t *subscriber,
    savan_filter_mod_t *filtermod,
    axiom_node_t *payload)
{
    axis2_options_t *options = NULL;
    axis2_status_t status = AXIS2_SUCCESS;
    axis2_endpoint_ref_t *to = NULL;
    const axis2_char_t *address = NULL;
    axis2_bool_t filter_apply = AXIS2_TRUE;
    axis2_endpoint_ref_t *notifyto = NULL;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Entry:savan_default_publisher_publish_to_subscriber");

    options = (axis2_options_t *) axis2_svc_client_get_options(svc_client, env);
    if(!options)
    {
        options = axis2_options_create(env);
        axis2_svc_client_set_options(svc_client, env, options);
    }
    axis2_options_set_action(options, env, "http://ws.apache.org/ws/2007/05/eventing-extended/Publish");
    axis2_svc_client_engage_module(svc_client, env, AXIS2_MODULE_ADDRESSING);

    notifyto = savan_subscriber_get_notify_to(subscriber, env);
    if(notifyto)
    {
        address = axis2_endpoint_ref_get_address(notifyto, env);
        if(address)
        {
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Publishing to:%s", address);
            to = axis2_endpoint_ref_create(env, address);
            axis2_options_set_to(options, env, to);
        }
    }
    axis2_options_set_xml_parser_reset(options, env, AXIS2_FALSE);

#ifdef SAVAN_FILTERING
    /* If this is a filtering request and filter module is defined then filter the request.
     */
    {
        axis2_char_t *filter_dialect = NULL;
        filter_dialect = savan_subscriber_get_filter_dialect(subscriber, env);
        if(!axutil_strcmp(filter_dialect, SYNAPSE_FILTER_DIALECT))
        {
            /* Do nothing */
        }
        else if(filtermod && savan_subscriber_get_filter(subscriber, env))
        {
            /* Apply the filter, and check whether it evaluates to success */
            filter_apply = savan_filter_mod_apply(filtermod ,env, subscriber, payload);
            if(!filter_apply)
            {
                status = axutil_error_get_status_code(env->error);
                if(AXIS2_SUCCESS != status)
                {
                    axiom_node_detach(payload, env);
                    return status;
                }
            }
        }
        else
        {
            AXIS2_HANDLE_ERROR(env, SAVAN_ERROR_FILTER_MODULE_COULD_NOT_BE_RETRIEVED, 
                    AXIS2_FAILURE);
            return AXIS2_FAILURE;
        }
    }
#endif

    if(filter_apply)
    {
        axis2_svc_client_fire_and_forget(svc_client, env, payload);
    }

    axiom_node_detach(payload, env); /*insert this to prevent payload corruption in subsequent 
                                       "publish" calls with some payload.*/

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Exit:savan_default_publisher_publish_to_subscriber");

    return status;
}
示例#23
0
AXIS2_EXTERN void AXIS2_CALL
savan_default_publisher_publish(
    savan_publisher_t *publishermod,
    const axutil_env_t *env,
    void *msg_ctx,
    savan_subs_mgr_t *subs_mgr)
{
    savan_default_publisher_t *publishermodimpl = NULL;
    axutil_array_list_t *subs_store = NULL;
    int i = 0, size = 0;
    savan_filter_mod_t *filtermod = NULL;
    const axis2_char_t *path = NULL;
    axiom_node_t *payload = NULL;
    axiom_soap_envelope_t *envelope = NULL;
    axiom_soap_body_t *body = NULL;
    axiom_node_t *body_node = NULL;
    const axis2_char_t *filter = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axutil_property_t *topic_property = NULL;

    publishermodimpl = SAVAN_INTF_TO_IMPL(publishermod);

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Entry:savan_default_publisher_publish");

    topic_property = axis2_msg_ctx_get_property(msg_ctx, env, ELEM_NAME_TOPIC);
    if(topic_property)
    {
        filter = axutil_property_get_value(topic_property, env);
    }
    axutil_allocator_switch_to_global_pool(env->allocator);
    if(subs_mgr)
    {
        subs_store = savan_subs_mgr_retrieve_all_subscribers(subs_mgr, env, filter);
    }

    if (!subs_store)
    {
        axutil_allocator_switch_to_local_pool(env->allocator);
        AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "[savan] Subscriber store is NULL"); 
    }

    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    path = axis2_conf_ctx_get_root_dir(conf_ctx, env);
    if(!path)
    {
        path = AXIS2_GETENV("AXIS2C_HOME");
    }

    envelope =  axis2_msg_ctx_get_soap_envelope((axis2_msg_ctx_t *) msg_ctx, env);
    if (!envelope)
    {
        axutil_allocator_switch_to_local_pool(env->allocator);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] Failed to extract the soap envelop");
    }
    
    body = axiom_soap_envelope_get_body(envelope, env);
    if (!body)
    {
        axutil_allocator_switch_to_local_pool(env->allocator);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[savan] Failed to extract the soap body"); 
    }
    
    body_node = axiom_soap_body_get_base_node(body, env);

    payload = axiom_node_get_first_child(body_node, env);
    size = axutil_array_list_size(subs_store, env);
    for(i = 0; i < size; i++)
    {
        axis2_svc_client_t *svc_client = NULL;
        savan_subscriber_t *sub = NULL;

        sub = (savan_subscriber_t *)axutil_array_list_get(subs_store, env, i);
        if (sub)
        {
            axis2_char_t *id = savan_subscriber_get_id(sub, env);
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[savan] Publishing to:%s", id);

            svc_client = axis2_svc_client_create(env, path);
            filtermod = savan_util_get_filter_module(env, publishermodimpl->conf);
            /* Ideally publishing to each subscriber should happen within a thread for each 
             * subscriber. However until Axis2/C provide a good thread pool to handle
             * such tasks I use this sequential publishing to subscribers.
             */
            if(!savan_default_publisher_publish_to_subscriber(publishermod, env, svc_client, sub, 
                        filtermod, payload))
            {
                axis2_endpoint_ref_t *notifyto = savan_subscriber_get_notify_to(sub, env);
                const axis2_char_t *address = NULL;

                if(notifyto)
                {
                    address = axis2_endpoint_ref_get_address(notifyto, env);
                }

                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                        "Publishing to the Data Sink:%s proviced by subscriber:%s Failed. Check "\
                        "whether the Data Sink url is correct", address, id);
            }
            if(svc_client)
            {
                axis2_svc_client_free(svc_client, env);
            }
        }
    }

    axutil_allocator_switch_to_local_pool(env->allocator);

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[savan] Exit:savan_default_publisher_publish");
}
static axis2_status_t AXIS2_CALL 
sandesha2_create_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 *create_seq_msg_ctx = NULL;
    sandesha2_create_seq_t *create_seq_part = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    sandesha2_msg_ctx_t *fault_rm_msg_ctx = NULL;
    axis2_msg_ctx_t *out_msg_ctx = NULL;
    sandesha2_seq_property_mgr_t *seq_prop_mgr = NULL;
    sandesha2_next_msg_mgr_t *next_msg_mgr = NULL;
    axutil_property_t *property = NULL;
    axis2_char_t *incoming_sequence_id = NULL;
    sandesha2_msg_ctx_t *rm_create_seq_res_msg_ctx = NULL;
    sandesha2_create_seq_res_t *create_seq_res_part = NULL;
    sandesha2_seq_offer_t *seq_offer = NULL;
    axis2_endpoint_ref_t *acks_to_epr = NULL;
    sandesha2_acks_to_t *acks_to = NULL;
    sandesha2_seq_property_bean_t *acks_to_bean = NULL;
    sandesha2_seq_property_bean_t *acks_to_ref_param_bean = NULL;
    axutil_array_list_t *ref_param_list = NULL;
    axis2_char_t *ref_param_list_str = NULL;
    sandesha2_seq_property_bean_t *to_bean = NULL;
    axis2_engine_t *engine = NULL;
    axis2_char_t *addr_ns_uri = NULL;
    axis2_char_t *anon_uri = NULL;
    axis2_char_t *to_addr = NULL;
    axis2_op_ctx_t *op_ctx = NULL;
    axis2_char_t *dbname = NULL;
    sandesha2_create_seq_mgr_t *create_seq_mgr = NULL;
    axis2_msg_ctx_t **msg_ctx_map = NULL;
     
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,  
        "[sandesha2] Start:sandesha2_create_seq_msg_processor_process_in_msg");
    
    AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE);
    
    create_seq_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env);
    
    op_ctx = axis2_msg_ctx_get_op_ctx(create_seq_msg_ctx, env);
    msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
    msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN] = create_seq_msg_ctx;

    create_seq_part = sandesha2_msg_ctx_get_create_seq(rm_msg_ctx, env);
    if(!create_seq_part)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] create_seq_part is NULL");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING, AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }

    conf_ctx = axis2_msg_ctx_get_conf_ctx(create_seq_msg_ctx, env);
    dbname = sandesha2_util_get_dbname(env, conf_ctx);
    seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
    create_seq_mgr = sandesha2_permanent_create_seq_mgr_create(env, dbname);
    next_msg_mgr = sandesha2_permanent_next_msg_mgr_create(env, dbname);
    
    /*fault_rm_msg_ctx = sandesha2_fault_mgr_check_for_create_seq_refused(env, rm_msg_ctx, seq_prop_mgr);*/
    fault_rm_msg_ctx = sandesha2_fault_mgr_check_for_create_seq_refused(env, rm_msg_ctx, seq_prop_mgr);
    if(fault_rm_msg_ctx)
    {
        axis2_engine_t *engine = NULL;

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

        engine = axis2_engine_create(env, conf_ctx);
        axis2_engine_send_fault(engine, env, sandesha2_msg_ctx_get_msg_ctx(fault_rm_msg_ctx, env));
        if(fault_rm_msg_ctx)
        {
            sandesha2_msg_ctx_free(fault_rm_msg_ctx, env);
        }

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

        axis2_msg_ctx_set_paused(create_seq_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(next_msg_mgr)
        {
            sandesha2_next_msg_mgr_free(next_msg_mgr, env);
        }

        return AXIS2_SUCCESS;
    }

    out_msg_ctx = sandesha2_utils_create_out_msg_ctx(env, create_seq_msg_ctx);

    incoming_sequence_id = sandesha2_seq_mgr_setup_new_incoming_sequence(env, rm_msg_ctx, 
            seq_prop_mgr, next_msg_mgr);

    rm_create_seq_res_msg_ctx = sandesha2_msg_creator_create_create_seq_res_msg(env, rm_msg_ctx, 
            out_msg_ctx, incoming_sequence_id, seq_prop_mgr);

    axis2_msg_ctx_set_flow(out_msg_ctx, env, AXIS2_OUT_FLOW);

    if(!rm_create_seq_res_msg_ctx)
    {
        if(incoming_sequence_id)
        {
            AXIS2_FREE(env->allocator, incoming_sequence_id);
        }

        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(next_msg_mgr)
        {
            sandesha2_next_msg_mgr_free(next_msg_mgr, env);
        }

        return AXIS2_FAILURE;
    }

    property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);

    /* For making sure that this won't be processed again */
    sandesha2_msg_ctx_set_property(rm_create_seq_res_msg_ctx, env, 
            SANDESHA2_APPLICATION_PROCESSING_DONE, property); 
    
    create_seq_res_part = sandesha2_msg_ctx_get_create_seq_res(rm_create_seq_res_msg_ctx, env);
    seq_offer = sandesha2_create_seq_get_seq_offer(create_seq_part, env);

    /* Offer processing */ 
    if(seq_offer)
    {
        sandesha2_accept_t *accept = NULL;
        axis2_char_t *outgoing_sequence_id = NULL;
        axis2_bool_t offer_accepted = AXIS2_FALSE;

        if(create_seq_res_part)
        {
            accept = sandesha2_create_seq_res_get_accept(create_seq_res_part, env);
        }
        if(!accept)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                    "[sandesha2] Accept part has not genereated for a message with offer");
            AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING, AXIS2_FAILURE);

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

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

            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(next_msg_mgr)
            {
                sandesha2_next_msg_mgr_free(next_msg_mgr, env);
            }

            return AXIS2_FAILURE;
        }

        outgoing_sequence_id = sandesha2_identifier_get_identifier(sandesha2_seq_offer_get_identifier(
                    seq_offer, env), env);

        /* Check whether offered sequence id is valid or create sequence bean already created */
        offer_accepted = sandesha2_create_seq_msg_processor_offer_accepted(env, outgoing_sequence_id, 
                rm_msg_ctx, create_seq_mgr);

        if(offer_accepted)
        {
            /*sandesha2_create_seq_bean_t *create_seq_bean = NULL;*/
            axis2_char_t *outgoing_internal_sequence_id = NULL;
            sandesha2_seq_property_bean_t *outgoing_sequence_bean = NULL;
            sandesha2_seq_property_bean_t *outgoing_internal_sequence_bean = NULL;
    
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Offer Accepted"); 

            /*
             * If previously a create sequence message has arrived with an offer then there is
             * a create sequence bean already created in the database. Free it. Also free
             * outgoing_internal_sequence_bean, and outgoing_sequence_bean.
             */
            sandesha2_create_seq_msg_processor_create_seq_msg_already_received(env, 
                    outgoing_sequence_id, rm_msg_ctx, create_seq_mgr, seq_prop_mgr);
            /* Note that outgoing_internal_sequence_id is derived from incoming_sequence_id. This
             * is server side. So it should be noted that in server side 
             * incoming_internal_sequence_id and outgoing_internal_sequence_id are same
             */
            outgoing_internal_sequence_id = sandesha2_utils_get_internal_sequence_id(env, 
                    incoming_sequence_id);

            /*create_seq_bean = sandesha2_create_seq_bean_create(env);
            sandesha2_create_seq_bean_set_outgoing_sequence_id(create_seq_bean, env, 
                outgoing_sequence_id);
            sandesha2_create_seq_bean_set_internal_sequence_id(create_seq_bean, env, 
                    outgoing_internal_sequence_id);

            sandesha2_create_seq_bean_set_create_seq_msg_id(create_seq_bean, env, 
                    axutil_uuid_gen(env));

            sandesha2_create_seq_mgr_insert(create_seq_mgr, env, create_seq_bean);*/
            
            outgoing_sequence_bean = sandesha2_seq_property_bean_create(env);
            if(outgoing_sequence_bean)
            {
                sandesha2_seq_property_bean_set_name(outgoing_sequence_bean, env, 
                        SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_SEQUENCE_ID);

                sandesha2_seq_property_bean_set_seq_id(outgoing_sequence_bean, env, 
                        outgoing_internal_sequence_id);
                sandesha2_seq_property_bean_set_value(outgoing_sequence_bean, env, 
                        outgoing_sequence_id);
                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] incoming_sequence_id:%s", 
                        incoming_sequence_id); 
                sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, outgoing_sequence_bean);
                sandesha2_seq_property_bean_free(outgoing_sequence_bean, env);
            }

            outgoing_internal_sequence_bean = sandesha2_seq_property_bean_create(env);
            if(outgoing_internal_sequence_bean)
            {
                sandesha2_seq_property_bean_set_name(outgoing_internal_sequence_bean, env, 
                    SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_INTERNAL_SEQUENCE_ID);

                sandesha2_seq_property_bean_set_seq_id(outgoing_internal_sequence_bean, env, 
                        outgoing_sequence_id);
                sandesha2_seq_property_bean_set_value(outgoing_internal_sequence_bean, env, 
                        outgoing_internal_sequence_id);
                sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, outgoing_internal_sequence_bean);
                sandesha2_seq_property_bean_free(outgoing_internal_sequence_bean, env);
            }

            if(outgoing_internal_sequence_id)
            {
                AXIS2_FREE(env->allocator, outgoing_internal_sequence_id);
            }
        }
        else
        {
            sandesha2_msg_ctx_add_soap_envelope(rm_create_seq_res_msg_ctx, env);
        }
    }

    acks_to = sandesha2_create_seq_get_acks_to(create_seq_part, env);
    acks_to_epr = sandesha2_address_get_epr(sandesha2_acks_to_get_address(acks_to, env), env);

    if(!acks_to_epr || !axis2_endpoint_ref_get_address(acks_to_epr, env))
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]Acks to is null");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_INVALID_EPR, AXIS2_FAILURE);

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

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

        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(next_msg_mgr)
        {
            sandesha2_next_msg_mgr_free(next_msg_mgr, env);
        }

        return AXIS2_FAILURE;
    }

    acks_to_bean = sandesha2_seq_property_bean_create_with_data(env, incoming_sequence_id, 
            SANDESHA2_SEQ_PROP_ACKS_TO_EPR, (axis2_char_t*)axis2_endpoint_ref_get_address(
                acks_to_epr, 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);
    }

    ref_param_list = sandesha2_acks_to_get_ref_param_list(acks_to, env);
    if(ref_param_list)
    {
        ref_param_list_str = sandesha2_util_get_string_from_node_list(env, ref_param_list);
        acks_to_ref_param_bean = sandesha2_seq_property_bean_create_with_data(env, 
                incoming_sequence_id, SANDESHA2_SEQ_PROP_ACKS_TO_REF_PARAM, ref_param_list_str);
        
        if(ref_param_list_str)
        {
            AXIS2_FREE(env->allocator, ref_param_list_str);
        }

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

    axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_TRUE);
    sandesha2_seq_mgr_update_last_activated_time(env, incoming_sequence_id, seq_prop_mgr);

    engine = axis2_engine_create(env, conf_ctx);

    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]axis2_engine_send");

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

    if(out_msg_ctx)
    {
        axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
        /*axis2_msg_ctx_reset_transport_out_stream(out_msg_ctx, env);*/
        axis2_msg_ctx_free(out_msg_ctx, env);
    }

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

    to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, incoming_sequence_id, 
            SANDESHA2_SEQ_PROP_TO_EPR);
    if(!to_bean)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] wsa:To is not set");

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

        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(next_msg_mgr)
        {
            sandesha2_next_msg_mgr_free(next_msg_mgr, env);
        }

        return AXIS2_FAILURE;
    }

    to_addr = sandesha2_seq_property_bean_get_value(to_bean, env);
    addr_ns_uri = sandesha2_utils_get_seq_property(env, incoming_sequence_id, 
            SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, seq_prop_mgr);

    anon_uri = sandesha2_spec_specific_consts_get_anon_uri(env, addr_ns_uri);
    if(addr_ns_uri)
    {
        AXIS2_FREE(env->allocator, addr_ns_uri);
    }
    
    if(sandesha2_utils_is_anon_uri(env, to_addr))
    {
        axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_TRUE);
    }
    else
    {
        axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_FALSE);
    }

    sandesha2_seq_property_bean_free(to_bean, env);
   
    /* Pausing the flow here so that it won't go to a message receiver which is not set for this flow */
    sandesha2_msg_ctx_set_paused(rm_msg_ctx, env, AXIS2_TRUE);

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

    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(next_msg_mgr)
    {
        sandesha2_next_msg_mgr_free(next_msg_mgr, env);
    }

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

    return AXIS2_SUCCESS;
    
}
示例#25
0
文件: phase.c 项目: Denisss025/wsfcpp
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_phase_invoke(
    axis2_phase_t * phase,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    int idx = 0, size = 0;
    axis2_status_t status = AXIS2_SUCCESS;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_phase_invoke");
    axis2_msg_ctx_set_paused_phase_name(msg_ctx, env, phase->name);
    if(phase->first_handler)
    {
        if(axis2_msg_ctx_is_paused(msg_ctx, env))
        {
            AXIS2_LOG_INFO(env->log, "Message context is paused in the phase %s", phase->name);
            return AXIS2_SUCCESS;
        }
        else
        {
            const axis2_char_t *handler_name = axutil_string_get_buffer(axis2_handler_get_name(
                phase->first_handler, env), env);
            AXIS2_LOG_INFO(env->log, "Invoke the first handler %s within the phase %s",
                handler_name, phase->name);

            status = axis2_handler_invoke(phase->first_handler, env, msg_ctx);
            if(!status)
            {
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Handler %s invoke failed within phase %s",
                    handler_name, phase->name);
                return status;
            }
        }
    }
    /* Invoking the rest of handlers except first_handler and last_handler */
    size = axutil_array_list_size(phase->handlers, env);
    while(idx < size)
    {
        if(axis2_msg_ctx_is_paused(msg_ctx, env))
        {
            break;
        }
        else
        {
            axis2_handler_t *handler = (axis2_handler_t *)axutil_array_list_get(phase->handlers,
                env, idx);
            if(handler)
            {
                const axis2_char_t *handler_name = axutil_string_get_buffer(axis2_handler_get_name(
                    handler, env), env);
                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                    "Invoke the handler %s within the phase %s", handler_name, phase->name);

                /* Test code. This is used when valgrind is used to find leaks in Axis2/C modules.*/
                /*if(!axutil_strcmp(handler_name, "SandeshaGlobalInHandler") || !axutil_strcmp(
                 handler_name, "SandeshaInHandler"))
                 {
                 AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                 "dam_handler_name %s. dam_phase_name %s", handler_name, phase->name);
                 if(!axutil_strcmp(handler_name, "SandeshaGlobalInHandler"))
                 {
                 status = sandesha2_global_in_handler_invoke(phase->first_handler, env, msg_ctx);
                 }
                 if(!axutil_strcmp(handler_name, "SandeshaInHandler"))
                 {
                 status = sandesha2_in_handler_invoke(phase->first_handler, env, msg_ctx);
                 }
                 }
                 else*/
                status = axis2_handler_invoke(handler, env, msg_ctx);
                if(!status)
                {
                    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "Handler %s invoke failed within phase %s", handler_name, phase->name);
                    return status;
                }
                /* idx increment should be done after the invoke function. If the invocation
                 failed this handler is taken care of and no need to revoke again */
                idx++;
                axis2_msg_ctx_set_current_handler_index(msg_ctx, env, idx);
            }
        }
    }

    /* If phase last handler is there invoke it here */
    if(phase->last_handler)
    {
        if(axis2_msg_ctx_is_paused(msg_ctx, env))
        {
            AXIS2_LOG_INFO(env->log, "Message context is paused in the phase %s", phase->name);
            return AXIS2_SUCCESS;
        }
        else
        {
            const axis2_char_t *handler_name = axutil_string_get_buffer(axis2_handler_get_name(
                phase->last_handler, env), env);
            AXIS2_LOG_INFO(env->log, "Invoke the last handler %s within the phase %s",
                handler_name, phase->name);

            status = axis2_handler_invoke(phase->last_handler, env, msg_ctx);
            if(!status)
            {
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                    "Handler %s invoke failed within  phase %s", handler_name, phase->name);
                return status;
            }
        }
    }
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_phase_invoke");
    return AXIS2_SUCCESS;
}
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;
}
示例#27
0
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_tcp_worker_process_request(
    axis2_tcp_worker_t * tcp_worker,
    const axutil_env_t * env,
    axis2_simple_tcp_svr_conn_t * svr_conn,
    axis2_char_t * simple_request)
{
    axis2_conf_ctx_t *conf_ctx = 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_xml_reader_t *reader = NULL;
    axiom_stax_builder_t *builder = NULL;
    axiom_soap_builder_t *soap_builder = NULL;
    axiom_soap_envelope_t *soap_envelope = NULL;
    axis2_engine_t *engine = NULL;
    axis2_status_t status = AXIS2_FALSE;
    axutil_stream_t *svr_stream = NULL;
    axis2_char_t *buffer = NULL;
    int len = 0;
    int write = -1;
    axutil_stream_t *out_stream = NULL;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "start:axis2_tcp_worker_process_request");

    reader = axiom_xml_reader_create_for_memory(env, simple_request, axutil_strlen(simple_request),
        NULL, AXIS2_XML_PARSER_TYPE_BUFFER);
    if(!reader)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create XML reader");
        return AXIS2_FAILURE;
    }

    builder = axiom_stax_builder_create(env, reader);
    if(!builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create Stax builder");
        return AXIS2_FAILURE;
    }

    soap_builder= axiom_soap_builder_create(env, builder, NULL);
    if(!soap_builder)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to create SOAP builder");
        return AXIS2_FAILURE;
    }

    conf_ctx = tcp_worker->conf_ctx;

    if(!conf_ctx)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "conf ctx not available");
        return AXIS2_FAILURE;
    }

    out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf(conf_ctx, env), env,
        AXIS2_TRANSPORT_ENUM_TCP);
    if(!out_desc)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport out not set");
        return AXIS2_FAILURE;
    }

    in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(conf_ctx, env), env,
        AXIS2_TRANSPORT_ENUM_TCP);

    msg_ctx = axis2_msg_ctx_create(env, conf_ctx, in_desc, out_desc);
    axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);

    out_stream = axutil_stream_create_basic(env);
    axis2_msg_ctx_set_transport_out_stream(msg_ctx, env, out_stream);

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

    engine = axis2_engine_create(env, conf_ctx);
    status = axis2_engine_receive(engine, env, msg_ctx);

    svr_stream = axis2_simple_tcp_svr_conn_get_stream(svr_conn, env);
    buffer = out_stream->buffer;
    len = out_stream->len;
    buffer[len] = 0;
    if(svr_stream && buffer)
    {
        write = axutil_stream_write(svr_stream, env, buffer, len + 1);
        if(write < 0)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "stream write failed");
            return AXIS2_FAILURE;
        }
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "stream wrote:%s", buffer);
    }
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "end:axis2_tcp_worker_process_request");
    return AXIS2_SUCCESS;
}
示例#28
0
文件: svc.c 项目: Denisss025/wsfcpp
/**
 * Here we extract all operations defined in module.xml and built execution
 * chains for them by calling axis2_phase_resolver_build_execution_chains_for_module_op()
 * function. Within that function handlers of the modules defined for that
 * operation are added to module operation chains appropriately.
 */
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_svc_add_module_ops(
    axis2_svc_t * svc,
    const axutil_env_t * env,
    axis2_module_desc_t * module_desc,
    axis2_conf_t * conf)
{
    axutil_hash_t *map = NULL;
    axutil_hash_index_t *hash_idx = NULL;
    axis2_phase_resolver_t *phase_resolver = NULL;
    axis2_op_t *op_desc = NULL;
    axis2_status_t status = AXIS2_FAILURE;
    const axis2_char_t *svcname = NULL;
    axis2_char_t *modname = NULL;
    axis2_char_t *opname = NULL;

    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:axis2_svc_add_module_ops");
    AXIS2_PARAM_CHECK(env->error, module_desc, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, conf, AXIS2_FAILURE);
    svcname = axis2_svc_get_name(svc, env);
    modname = axutil_qname_get_localpart(axis2_module_desc_get_qname(module_desc, env), env);
    map = axis2_module_desc_get_all_ops(module_desc, env);
    phase_resolver = axis2_phase_resolver_create_with_config_and_svc(env, conf, svc);
    if(!phase_resolver)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating phase resolver failed for service %s",
                        svcname);
        return AXIS2_FAILURE;
    }
    for(hash_idx = axutil_hash_first(map, env); hash_idx; hash_idx = axutil_hash_next(env, hash_idx))
    {
        void *v = NULL;
        axutil_hash_this(hash_idx, NULL, NULL, &v);
        op_desc = (axis2_op_t *)v;
        opname = axutil_qname_get_localpart(axis2_op_get_qname(op_desc, env), env);
        status = axis2_phase_resolver_build_execution_chains_for_module_op(phase_resolver, env,
                 op_desc);

        if(AXIS2_SUCCESS != status)
        {
            axis2_phase_resolver_free(phase_resolver, env);
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                            "Builidng module operation %s failed for module %s", opname, modname);
            return status;
        }

        status = axis2_svc_add_op(svc, env, op_desc);
        if(AXIS2_SUCCESS != status)
        {
            axis2_phase_resolver_free(phase_resolver, env);
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Adding operation %s to service %s failed",
                            opname, svcname);
            return status;
        }

    }

    axis2_phase_resolver_free(phase_resolver, env);
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Exit:axis2_svc_add_module_ops");
    return AXIS2_SUCCESS;
}
示例#29
0
/**
 * Adds an ack message to the given application message.
 * 
 * @param app_msg
 * @param sequence_id
 */
axis2_status_t AXIS2_CALL
sandesha2_msg_creator_add_ack_msg(
    const axutil_env_t *env,
    sandesha2_msg_ctx_t *target_rm_msg_ctx,
    axis2_char_t *seq_id,
    sandesha2_seq_property_mgr_t *seq_prop_mgr)
{
    axiom_soap_envelope_t *envelope = NULL;
    axiom_soap_header_t *soap_header = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_char_t *rm_version = NULL;
    axis2_char_t *rm_ns_value = NULL;
    axis2_char_t *msg_no_list = NULL;
    axis2_char_t *ack_req_action = NULL;
    axis2_char_t *temp_action = NULL;
    axutil_string_t *ack_req_soap_action = NULL;
    axis2_char_t *str_value = NULL;
    axis2_char_t *uuid = NULL;
    sandesha2_identifier_t *id = NULL;
    sandesha2_seq_ack_t *seq_ack = NULL;
    sandesha2_seq_property_bean_t *seq_bean = NULL;
    sandesha2_seq_property_bean_t *seq_closed_bean = NULL;
    axis2_msg_ctx_t *msg_ctx = NULL;
    axutil_array_list_t *ack_range_list = NULL;
    int i = 0, size = 0;
    
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, 
        "[sandesha2] Entry:sandesha2_msg_creator_add_ack_msg");

    envelope = sandesha2_msg_ctx_get_soap_envelope(target_rm_msg_ctx, env);
    if(!envelope)
    {
        AXIS2_ERROR_SET(env->error, 
                AXIS2_ERROR_NULL_SOAP_ENVELOPE_IN_MSG_CTX, AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }

    msg_ctx = sandesha2_msg_ctx_get_msg_ctx(target_rm_msg_ctx, env);
    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    rm_version = sandesha2_utils_get_rm_version(env, msg_ctx);
    if(!rm_version)
    {
        AXIS2_ERROR_SET(env->error, 
                SANDESHA2_ERROR_CANNOT_FIND_RM_VERSION_OF_GIVEN_MSG, AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }

    rm_ns_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, rm_version);
    seq_ack = sandesha2_seq_ack_create(env, rm_ns_value);
    id = sandesha2_identifier_create(env, rm_ns_value);
    sandesha2_identifier_set_identifier(id, env, seq_id);
    sandesha2_seq_ack_set_identifier(seq_ack, env, id);
    seq_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, seq_id, 
            SANDESHA2_SEQ_PROP_SERVER_COMPLETED_MESSAGES);

    if(seq_bean)
    {
        msg_no_list = (axis2_char_t *) sandesha2_seq_property_bean_get_value(seq_bean, env); 
    }

    ack_range_list = sandesha2_utils_get_ack_range_list(env, msg_no_list, rm_ns_value);
    if(seq_bean)
    {
        sandesha2_seq_property_bean_free(seq_bean, env);
    }

    if(ack_range_list)
    {
        size = axutil_array_list_size(ack_range_list, env);
    }

    for(i = 0; i < size; i++)
    {
        sandesha2_ack_range_t *ack_range = NULL;

        ack_range = axutil_array_list_get(ack_range_list, env, i);
        sandesha2_seq_ack_add_ack_range(seq_ack, env, ack_range);
    }

    if(ack_range_list)
    {
        axutil_array_list_free(ack_range_list, env);
    }

    seq_closed_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, seq_id, 
            SANDESHA2_SEQ_PROP_SEQ_CLOSED);

    if(seq_closed_bean)
    {
        str_value = sandesha2_seq_property_bean_get_value(seq_closed_bean, env);
    }

    if(seq_closed_bean && 0 == axutil_strcmp(AXIS2_VALUE_TRUE, str_value))
    {
        axis2_bool_t is_allowed = AXIS2_FALSE;
        
        /* sequence is closed. so add the 'Final' part. */
        is_allowed = sandesha2_spec_specific_consts_is_ack_final_allowed(env, rm_version);
        if(is_allowed)
        {
            sandesha2_ack_final_t *ack_final = NULL;

            ack_final = sandesha2_ack_final_create(env,rm_ns_value);
            sandesha2_seq_ack_set_ack_final(seq_ack, env, ack_final);
        }
    }

    if(seq_closed_bean)
    {
        sandesha2_seq_property_bean_free(seq_closed_bean, env);
    }

    sandesha2_msg_ctx_set_seq_ack(target_rm_msg_ctx, env, seq_ack);
    soap_header = axiom_soap_envelope_get_header(envelope, env);
    sandesha2_seq_ack_to_om_node(seq_ack, env, soap_header);

    ack_req_action = sandesha2_msg_ctx_get_wsa_action(target_rm_msg_ctx, env);
    if((!ack_req_action) || (!axutil_strcmp(ack_req_action, "")))
    {
        ack_req_action = sandesha2_spec_specific_consts_get_seq_ack_action(env, rm_version);
        sandesha2_msg_ctx_set_wsa_action(target_rm_msg_ctx, env, ack_req_action); 
    }

    temp_action = sandesha2_spec_specific_consts_get_seq_ack_soap_action(env, rm_version);

    ack_req_soap_action = axutil_string_create(env, temp_action);
    if(ack_req_soap_action)
    {
        sandesha2_msg_ctx_set_soap_action(target_rm_msg_ctx, env, ack_req_soap_action); 
        axutil_string_free(ack_req_soap_action, env);
    }

    uuid = axutil_uuid_gen(env);
    sandesha2_msg_ctx_set_msg_id(target_rm_msg_ctx, env, uuid);

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

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

    return AXIS2_SUCCESS;
}
示例#30
0
/**
 * Create a new create_seq_response message.
 * @param env axis2 environment struct
 * @param create_seq_msg
 * @param out_msg
 * @param new_seq_id
 * @param seq_prop_mgr
 * @return sandesha2_msg_ctx_t
 */
sandesha2_msg_ctx_t *
sandesha2_msg_creator_create_create_seq_res_msg(
    const axutil_env_t *env,
    sandesha2_msg_ctx_t *create_seq_msg,
    axis2_msg_ctx_t *out_msg,
    axis2_char_t *new_seq_id,
    sandesha2_seq_property_mgr_t *seq_prop_mgr)
{
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_msg_ctx_t *temp_msg_ctx = NULL;
    axis2_char_t *rm_version = NULL;
    axis2_char_t *rm_ns_value = NULL;
    axis2_char_t *addressing_ns_value = NULL;
    axis2_char_t *new_msg_id = NULL;
    axis2_char_t *temp_action = NULL;
    axutil_string_t *soap_action = NULL;
    axiom_soap_envelope_t *envelope = NULL;
    axiom_soap_envelope_t *temp_envelope = NULL;
    axiom_soap_body_t *temp_soap_body = NULL;
    axiom_node_t *temp_om_node = NULL;
    sandesha2_create_seq_res_t *create_seq_res = NULL;
    sandesha2_identifier_t *identifier = NULL;
    sandesha2_seq_offer_t *offer = NULL;
    sandesha2_msg_ctx_t *create_seq_res_rm_msg_ctx = NULL;
    sandesha2_create_seq_t *cs = NULL;
    int soap_version = -1;

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

    temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env);
    conf_ctx = axis2_msg_ctx_get_conf_ctx(temp_msg_ctx, env);
    cs = sandesha2_msg_ctx_get_create_seq(create_seq_msg, env);
    rm_version = sandesha2_utils_get_rm_version(env, temp_msg_ctx);

    if(!rm_version)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find rm version of given message");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_RM_VERSION_OF_GIVEN_MSG, 
                AXIS2_FAILURE);
        return NULL;
    }

    rm_ns_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, rm_version);
    addressing_ns_value = sandesha2_utils_get_seq_property(env, new_seq_id, 
        SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, seq_prop_mgr);
    if(!addressing_ns_value)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Cannot find addressing namespace value");
        return NULL;
    }

    create_seq_res = sandesha2_create_seq_res_create(env, rm_ns_value, addressing_ns_value);
    identifier = sandesha2_identifier_create(env, rm_ns_value);
    sandesha2_identifier_set_identifier(identifier, env, new_seq_id);
    sandesha2_create_seq_res_set_identifier(create_seq_res, env, identifier);
    offer = sandesha2_create_seq_get_seq_offer(cs, env);

    if(offer)
    {
        axis2_char_t *out_seq_id = NULL;
        sandesha2_identifier_t *temp_identifier = NULL;
        
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] Offer present");

        temp_identifier = sandesha2_seq_offer_get_identifier(offer, env);
        out_seq_id = sandesha2_identifier_get_identifier(temp_identifier, env);
        if(out_seq_id && axutil_strcmp("", out_seq_id))
        {
            sandesha2_accept_t *accept = NULL;
            axis2_endpoint_ref_t *acks_to_epr = NULL;
            sandesha2_acks_to_t *acks_to = NULL;
            sandesha2_address_t *address = NULL;

            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2] out_seq_id present");

            accept = sandesha2_accept_create(env, rm_ns_value, addressing_ns_value);
            if(accept)
            {
                axis2_endpoint_ref_t *temp_to_epr = NULL;

                acks_to_epr = sandesha2_msg_ctx_get_to(create_seq_msg, env);
                if(acks_to_epr)
                {
                    temp_to_epr = sandesha2_util_endpoint_ref_clone(env, acks_to_epr);
                }

                address = sandesha2_address_create(env, addressing_ns_value, temp_to_epr);
                acks_to = sandesha2_acks_to_create(env, address, rm_ns_value, addressing_ns_value);
                sandesha2_accept_set_acks_to(accept, env, acks_to);
                sandesha2_create_seq_res_set_accept(create_seq_res, env, accept);
            }
            else
            {
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Could not create accept element");
                return NULL;
            }
        }
    }

    temp_envelope = sandesha2_msg_ctx_get_soap_envelope(create_seq_msg, env); 
    soap_version = sandesha2_utils_get_soap_version(env, temp_envelope);
    envelope = axiom_soap_envelope_create_default_soap_envelope(env, soap_version);
    temp_soap_body = axiom_soap_envelope_get_body(envelope, env);
    temp_om_node = axiom_soap_body_get_base_node(temp_soap_body, env);
    sandesha2_create_seq_res_to_om_node(create_seq_res, env, temp_om_node);
    temp_action = sandesha2_spec_specific_consts_get_create_seq_res_action(env, rm_version);

    axis2_msg_ctx_set_wsa_action(out_msg, env, temp_action);

    soap_action = axutil_string_create(env, temp_action);
    /*if(soap_action)
    {
        axis2_msg_ctx_set_soap_action(out_msg, env, soap_action);
        axutil_string_free(soap_action, env);
    }*/

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

    new_msg_id = axutil_uuid_gen(env);
    if(new_msg_id)
    {
        axis2_msg_ctx_set_message_id(out_msg, env, new_msg_id);
        AXIS2_FREE(env->allocator, new_msg_id);
    }

    axis2_msg_ctx_set_soap_envelope(out_msg, env, envelope);
    temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env);
    sandesha2_msg_creator_init_creation(env, temp_msg_ctx, out_msg);
    create_seq_res_rm_msg_ctx = sandesha2_msg_init_init_msg(env, out_msg);
    sandesha2_msg_ctx_set_create_seq_res(create_seq_res_rm_msg_ctx, env, create_seq_res);
    temp_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env);
    sandesha2_msg_creator_finalize_creation(env, temp_msg_ctx, out_msg);
    axis2_msg_ctx_set_server_side(temp_msg_ctx, env, AXIS2_TRUE);

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

    return create_seq_res_rm_msg_ctx;
}