Ejemplo n.º 1
0
AXIS2_EXTERN axis2_char_t* AXIS2_CALL
service_admin_util_get_epr_address(const axutil_env_t *env,
						   axis2_msg_ctx_t *msg_ctx,
						   axis2_char_t *service_name)
{
	axis2_endpoint_ref_t *epr = NULL;
	axis2_char_t *address = NULL;
	axis2_conf_ctx_t *conf_ctx = NULL;
	axis2_conf_t *conf = NULL;
	axis2_transport_in_desc_t *transport_in = NULL;

	conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
	conf = axis2_conf_ctx_get_conf(conf_ctx, env);
	
	transport_in = axis2_conf_get_transport_in(conf, env, AXIS2_TRANSPORT_ENUM_HTTP);

	if(transport_in)
	{
		axis2_transport_receiver_t *receiver = NULL;
		receiver = axis2_transport_in_desc_get_recv(transport_in, env);
		if(!receiver)
		{
			AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Transport Receiver Not found ");
			return NULL;
		}
		epr = axis2_transport_receiver_get_epr_for_service(receiver, env, service_name);
		if(!epr)
		{
			AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Endpoint reference null");
			return NULL;
		}
		address = (axis2_char_t*)axis2_endpoint_ref_get_address(epr,env);
	}
	return address;
}
Ejemplo n.º 2
0
axis2_op_t *AXIS2_CALL
axis2_req_uri_disp_find_op(
    axis2_msg_ctx_t * msg_ctx,
    const axutil_env_t * env,
    axis2_svc_t * svc)
{
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_op_t *op = NULL;

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

    if(axis2_msg_ctx_get_doing_rest(msg_ctx, env))
        return NULL;

    endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env);

    if(endpoint_ref)
    {
        const axis2_char_t *address = NULL;

        address = axis2_endpoint_ref_get_address(endpoint_ref, env);
        if(address)
        {
            axis2_char_t **url_tokens = NULL;

            url_tokens = axutil_parse_request_url_for_svc_and_op(env, address);

            if(url_tokens)
            {
                if(url_tokens[1])
                {
                    axutil_qname_t *op_qname = NULL;
                    AXIS2_LOG_DEBUG(
                        env->log,
                        AXIS2_LOG_SI,
                        "Checking for operation using \
                             target endpoint uri fragment : %s",
                        url_tokens[1]);
                    op_qname = axutil_qname_create(env, url_tokens[1], NULL, NULL);
                    op = axis2_svc_get_op_with_name(svc, env, axutil_qname_get_localpart(op_qname,
                        env));
                    axutil_qname_free(op_qname, env);
                    if(op)
                        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                            "Operation found using target endpoint uri fragment");
                }
                if(url_tokens[0])
                    AXIS2_FREE(env->allocator, url_tokens[0]);
                if(url_tokens[1])
                    AXIS2_FREE(env->allocator, url_tokens[1]);
                AXIS2_FREE(env->allocator, url_tokens);
            }
        }
    }

    return op;
}
Ejemplo n.º 3
0
/*
 * This method invokes the right service method 
 */
axiom_node_t* AXIS2_CALL
rm_sample_svc_invoke(
    axis2_svc_skeleton_t *svc_skeleton,
    const axutil_env_t *env,
    axiom_node_t *node,
    axis2_msg_ctx_t *msg_ctx)
{
    axis2_op_t *op = NULL;
    axutil_qname_t *op_qname = NULL;
    axis2_char_t *op_name = NULL;
    
    op = axis2_msg_ctx_get_op(msg_ctx, env);
    if(op)
    {
        op_qname = (axutil_qname_t *)axis2_op_get_qname(op, env);
        if(op_qname)
        {
            op_name = axutil_qname_get_localpart(op_qname, env);
        }

        if(op_name)
        {
			axis2_endpoint_ref_t* to_epr = NULL;
            to_epr = axis2_msg_ctx_get_to(msg_ctx, env);

            if (to_epr)
            {
                const axis2_char_t* to_address = NULL;
                to_address = axis2_endpoint_ref_get_address(to_epr, env);

                if (to_address && strstr(to_address, AXIS2_ANON_SERVICE))
                {
                    axis2_msg_ctx_set_wsa_action(msg_ctx, env, AXIS2_ANON_OUT_IN_OP);
                }
            }

			if (!axutil_strcmp(op_name, "echoString"))
            {
                return rm_sample_svc_echo(env, node);
            }
            if (!axutil_strcmp(op_name, "ping"))
            {
                rm_sample_svc_ping(env, node);
                return NULL;
            }
            if (!axutil_strcmp(op_name, "mtomSample"))
            {
                return rm_sample_svc_mtom(env, node, msg_ctx);
            }
        }
    }

    return NULL;
}
Ejemplo n.º 4
0
axiom_node_t* AXIS2_CALL 
sandesha2_address_to_om_node(
    sandesha2_address_t *address,
   	const axutil_env_t *env, 
    void *om_node)
{
    axiom_namespace_t *rm_ns = NULL;
    axiom_element_t *addr_element = NULL;
    axiom_node_t *addr_node = NULL;
    
    AXIS2_PARAM_CHECK(env->error, om_node, NULL);
    if(!address->epr || !axis2_endpoint_ref_get_address(
            address->epr, env) || 0 == axutil_strlen(
            axis2_endpoint_ref_get_address(address->epr, env)))
    {
        AXIS2_ERROR_SET(env->error, (axutil_error_codes_t)SANDESHA2_ERROR_TO_OM_NULL_ELEMENT, 
            AXIS2_FAILURE);
        return NULL;
    }
    rm_ns = axiom_namespace_create(env, address->ns_val,
        AXIS2_WSA_DEFAULT_PREFIX);
    if(!rm_ns)
    {
        return NULL;
    }
    addr_element = axiom_element_create(env, NULL, 
            SANDESHA2_WSA_ADDRESS, rm_ns, &addr_node);
    if(!addr_element)
    {
        return NULL;
    }
    axiom_element_set_text(addr_element, env, 
            axis2_endpoint_ref_get_address(address->epr, env), 
            addr_node);
    axiom_node_add_child((axiom_node_t*)om_node, env, addr_node);
    return (axiom_node_t*)om_node;
}
Ejemplo n.º 5
0
AXIS2_EXTERN axis2_char_t* AXIS2_CALL 
service_admin_util_get_wsdl_for_service(axutil_env_t *env, 
									   axis2_char_t *service_name, 
									   axis2_conf_t *conf)
{
	axis2_transport_in_desc_t *transport_in = axis2_conf_get_transport_in(conf, env, AXIS2_TRANSPORT_ENUM_HTTP);
	
	if(transport_in)
	{
		axis2_endpoint_ref_t *epr = NULL;
		axis2_char_t *address = NULL;
		axis2_transport_receiver_t *receiver = axis2_transport_in_desc_get_recv(transport_in, env);
		if(!receiver)
		{
			AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Transport Receiver Not found ");
			return NULL;
		}
		epr = axis2_transport_receiver_get_epr_for_service(receiver, env, service_name);
		if(!epr)
		{
			AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Endpoint reference null");
			return NULL;
		}
		address = (axis2_char_t*)axis2_endpoint_ref_get_address(epr,env);
		if(address)
		{
			int length = axutil_strlen(address);
			if(address[length -1 ] == '\\')
			{
				address = axutil_stracat(env, address,"?wsdl");
			}else{
					address = axutil_stracat(env, address,"\?wsdl");
			}

		}
		return address;
	}
	return NULL;
}
Ejemplo n.º 6
0
/**
 * Create a new create_seq_msg
 * @param env
 * @param application_rm_msg
 * @param internal_seq_id
 * @param acks_to
 * @param seq_prop_mgr
 * @return sandesha2_msg_ctx_t
 */
sandesha2_msg_ctx_t *AXIS2_CALL
sandesha2_msg_creator_create_create_seq_msg(
    const axutil_env_t *env,
    sandesha2_msg_ctx_t *application_rm_msg, 
    axis2_char_t *internal_seq_id,
    axis2_char_t *acks_to,
    sandesha2_seq_property_mgr_t *seq_prop_mgr)
{
    axis2_msg_ctx_t *application_msg_ctx = NULL;
    axis2_msg_ctx_t *create_seq_msg_ctx = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_op_t *app_msg_op_desc = NULL;
    axis2_op_ctx_t *op_ctx = NULL;
    axis2_char_t *create_seq_msg_id = NULL;
    axis2_char_t *rm_version = NULL;
    axis2_char_t *rm_ns_value = NULL;
    axis2_char_t *addressing_ns_value = NULL;
    axis2_char_t *anonymous_uri = NULL;
    axis2_char_t *temp_value = NULL;
    axis2_char_t *temp_action = NULL;
    axutil_string_t *temp_soap_action = NULL;
    axis2_endpoint_ref_t *to_epr = NULL;
    axis2_endpoint_ref_t *temp_to = NULL;
    axis2_endpoint_ref_t *acks_to_epr = NULL;
    axis2_endpoint_ref_t *temp_reply_to = NULL;
    sandesha2_create_seq_t *create_seq_part = NULL;
    sandesha2_seq_property_bean_t *reply_to_bean = NULL;
    sandesha2_seq_property_bean_t *to_bean = NULL;
    sandesha2_msg_ctx_t *create_seq_rm_msg = NULL;
    sandesha2_address_t *temp_address = NULL;
    sandesha2_acks_to_t *temp_acks_to = NULL;
    axutil_property_t *property = NULL;
    const axis2_char_t *reply_to_address = NULL;

    application_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(application_rm_msg, env);
    if(!application_msg_ctx)
    {
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_APPLICATION_MSG_NULL, AXIS2_FAILURE);
        return NULL;
    }

    conf_ctx = axis2_msg_ctx_get_conf_ctx(application_msg_ctx, env);
    if(!conf_ctx)
    {
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CONF_CTX_NULL, AXIS2_FAILURE);
        return NULL;
    }

    /* Creating by copying common contents.
     */
    create_seq_msg_ctx = sandesha2_utils_create_new_related_msg_ctx(env, application_rm_msg);

    sandesha2_msg_creator_init_creation(env, application_msg_ctx, create_seq_msg_ctx);

    create_seq_msg_id = axutil_uuid_gen(env);
    axis2_msg_ctx_set_message_id(create_seq_msg_ctx, env, create_seq_msg_id);
    AXIS2_FREE(env->allocator, create_seq_msg_id);

    app_msg_op_desc = axis2_msg_ctx_get_op(application_msg_ctx, env);

    property = axis2_msg_ctx_get_property(application_msg_ctx, env, AXIS2_TARGET_EPR);
    if(property)
    {
        temp_to = axutil_property_get_value(property, env);
        to_epr = axis2_endpoint_ref_create(env, axis2_endpoint_ref_get_address(temp_to, env));
    }

    if (!to_epr)
    {
        temp_to = sandesha2_msg_ctx_get_to(application_rm_msg, env); 
        if (temp_to)
        {
            to_epr = axis2_endpoint_ref_create(env, axis2_endpoint_ref_get_address(temp_to, env));
        }
    }

    if (to_epr)
    {
        axis2_msg_ctx_set_to(create_seq_msg_ctx, env, to_epr);
        to_epr = NULL;
    }
    
    temp_reply_to = sandesha2_msg_ctx_get_reply_to(application_rm_msg, env); 
    if(temp_reply_to)
    {
        axis2_endpoint_ref_t *reply_to_epr = NULL;

        reply_to_address = axis2_endpoint_ref_get_address(temp_reply_to, env);
        reply_to_epr = axis2_endpoint_ref_create(env, reply_to_address);
        if(reply_to_epr)
        {
            axis2_msg_ctx_set_reply_to(create_seq_msg_ctx, env, reply_to_epr);
        }
    }

    create_seq_rm_msg = sandesha2_msg_ctx_create(env, create_seq_msg_ctx);

        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "create_seq_internal_seq_id:%s", internal_seq_id);
    rm_version = sandesha2_utils_get_rm_version(env, application_msg_ctx);

    if(!rm_version)
    {
        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, internal_seq_id, 
        SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, seq_prop_mgr);

    create_seq_part = sandesha2_create_seq_create(env, addressing_ns_value, rm_ns_value);
    if(!create_seq_part)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] creating create sequence message failed");
        return NULL;
    }

    /* Adding sequence offer if present */
    op_ctx = axis2_msg_ctx_get_op_ctx(application_msg_ctx, env);
    if(op_ctx)
    {
        axis2_op_t *operation = NULL;
        int mep = -1;
        axis2_char_t *offered_seq_id = NULL;
        /*axutil_property_t *property = NULL;
        axis2_ctx_t *ctx = NULL;

        ctx = axis2_msg_ctx_get_base(application_msg_ctx, env);
        property = axis2_ctx_get_property(ctx, env, SANDESHA2_CLIENT_OFFERED_SEQ_ID);
        if(property)
        {
            offered_seq_id = axutil_property_get_value(property, env);
        }*/
        operation = axis2_op_ctx_get_op(op_ctx, env);
        mep = axis2_op_get_axis_specific_mep_const(operation, env);
        if(mep == AXIS2_MEP_CONSTANT_OUT_IN)
        {
            offered_seq_id = axutil_uuid_gen(env);
        }

        /*if(offered_seq_id && 0 != axutil_strcmp("", offered_seq_id))*/
        if(offered_seq_id)
        {
            sandesha2_seq_offer_t *offer_part = NULL;
            sandesha2_identifier_t *identifier = NULL;
            sandesha2_endpoint_t *endpoint = NULL;

            offer_part = sandesha2_seq_offer_create(env, rm_ns_value, addressing_ns_value);
            identifier = sandesha2_identifier_create(env, rm_ns_value);
            sandesha2_identifier_set_identifier(identifier, env, offered_seq_id);
            sandesha2_seq_offer_set_identifier(offer_part, env, identifier);

            if(!axutil_strcmp(SANDESHA2_SPEC_VERSION_1_1, rm_version))
            {
                axis2_endpoint_ref_t *reply_to_epr = NULL;
                sandesha2_address_t *address = NULL;

                reply_to_epr = axis2_endpoint_ref_create(env, reply_to_address);
                address = sandesha2_address_create(env, addressing_ns_value, reply_to_epr);
                endpoint = sandesha2_endpoint_create(env, address, rm_ns_value, 
                        addressing_ns_value);

                sandesha2_seq_offer_set_endpoint(offer_part, env, endpoint);
            }

            sandesha2_create_seq_set_seq_offer(create_seq_part, env, offer_part);
        }
    }

    reply_to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_seq_id, 
            SANDESHA2_SEQ_PROP_REPLY_TO_EPR);

    to_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, internal_seq_id, 
            SANDESHA2_SEQ_PROP_TO_EPR);
    if (to_bean)
    {
        temp_value = sandesha2_seq_property_bean_get_value(to_bean, env);
    
        if (temp_value)
        {
            to_epr = axis2_endpoint_ref_create(env, temp_value);
        }

        sandesha2_seq_property_bean_free(to_bean, env);
    }

    anonymous_uri = sandesha2_spec_specific_consts_get_anon_uri(env, addressing_ns_value);
    if(reply_to_bean)
    {
        axis2_endpoint_ref_t *reply_to_epr = NULL;

        temp_value = sandesha2_seq_property_bean_get_value(reply_to_bean, env);
        if(temp_value)
        {
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "dam_reply_to:%s", temp_value);
            reply_to_epr = axis2_endpoint_ref_create(env, temp_value);
            acks_to = axutil_strdup(env, temp_value);
        }

        if(reply_to_epr)
        {
            sandesha2_msg_ctx_set_reply_to(create_seq_rm_msg, env, reply_to_epr);
        }
        
        sandesha2_seq_property_bean_free(reply_to_bean, env);
    }
    
    if(!acks_to || !axutil_strcmp("", acks_to))
    {
        acks_to = axutil_strdup(env, anonymous_uri);
    }

    acks_to_epr = axis2_endpoint_ref_create(env, acks_to);

    temp_to = sandesha2_msg_ctx_get_to(create_seq_rm_msg, env);
    if(!temp_to && to_epr)
    {
        sandesha2_msg_ctx_set_to(create_seq_rm_msg, env, to_epr);
    }
    else
    {
        axis2_endpoint_ref_free(to_epr, env);
    }


    temp_address = sandesha2_address_create(env, addressing_ns_value, acks_to_epr);
    temp_acks_to = sandesha2_acks_to_create(env, temp_address, rm_ns_value, addressing_ns_value);

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

    sandesha2_create_seq_set_acks_to(create_seq_part, env,  temp_acks_to);
    sandesha2_msg_ctx_set_create_seq(create_seq_rm_msg, env, create_seq_part);
    sandesha2_msg_ctx_add_soap_envelope(create_seq_rm_msg, env);
    temp_action = sandesha2_spec_specific_consts_get_create_seq_action(env, rm_version);

    sandesha2_msg_ctx_set_wsa_action(create_seq_rm_msg, env, temp_action);

    temp_soap_action = axutil_string_create(env, temp_action);
    if(temp_soap_action)
    {
        sandesha2_msg_ctx_set_soap_action(create_seq_rm_msg, env, temp_soap_action);
        axutil_string_free(temp_soap_action, env);
    }

    /*sandesha2_msg_creator_finalize_creation(env, application_msg_ctx, create_seq_msg_ctx);*/

    return create_seq_rm_msg;
}
Ejemplo n.º 7
0
sandesha2_msg_ctx_t *AXIS2_CALL
sandesha2_msg_creator_create_make_connection_msg(
    const axutil_env_t *env,
    sandesha2_msg_ctx_t *ref_rm_msg_ctx, 
    axis2_char_t *make_conn_seq_id,
    const axis2_char_t *internal_seq_id,
    axis2_char_t *make_conn_anon_uri,
    sandesha2_seq_property_mgr_t *seq_prop_mgr)
{
    axis2_msg_ctx_t *ref_msg_ctx = NULL;
    axis2_msg_ctx_t *make_conn_msg_ctx = NULL;
    axis2_char_t *rm_ns_value = NULL;
    axis2_char_t *mc_ns_value = NULL;
    axis2_char_t *wsa_action = NULL;
    sandesha2_make_connection_t *make_conn = NULL;
    sandesha2_msg_ctx_t *make_conn_rm_msg_ctx = NULL;
   
    rm_ns_value = sandesha2_spec_specific_consts_get_rm_ns_val(env, SANDESHA2_SPEC_VERSION_1_1);
    
    mc_ns_value = MAKE_CONNECTION_SPEC_2007_02_NS_URI;

    if(ref_rm_msg_ctx)
    {
        ref_msg_ctx = sandesha2_msg_ctx_get_msg_ctx(ref_rm_msg_ctx, env);
    }
    
    make_conn_msg_ctx = sandesha2_utils_create_new_related_msg_ctx(env, ref_rm_msg_ctx);
    if(make_conn_msg_ctx)
    {
        make_conn_rm_msg_ctx = sandesha2_msg_init_init_msg(env, make_conn_msg_ctx);
    }

    /* This if block is an hack to add the addressing handlers to the outflow.
     * Check whether this is not a hack
     */
    /*if(ref_msg_ctx)
    {
        axis2_op_t *op = axis2_msg_ctx_get_op(ref_msg_ctx, env);
        axis2_op_t *make_conn_op = axis2_msg_ctx_get_op(make_conn_msg_ctx, env);
        axutil_array_list_t *out_flow = axis2_op_get_out_flow(op, env);
        axutil_array_list_t *in_flow = axis2_op_get_in_flow(op, env);
        int size = axutil_array_list_size(out_flow, env);
        if(size > 0)
        {
            int i = 0;
            axutil_array_list_t *new_flow = axutil_array_list_create(env, 0);
            for(i = 0; i < size; i++)
            {
                const axis2_phase_t *phase = axutil_array_list_get(out_flow, env, i);
                const axis2_char_t *phase_name = axis2_phase_get_name(phase, env);
                if(0 == axutil_strcmp(phase_name, AXIS2_PHASE_MESSAGE_OUT))
                {
                    axutil_array_list_add(new_flow, env, phase);
                }
            }
            axis2_op_set_out_flow(make_conn_op, env, new_flow);
        }
        size = axutil_array_list_size(in_flow, env);
        if(size > 0)
        {
            int i = 0;
            axutil_array_list_t *new_flow = axutil_array_list_create(env, 0);
            for(i = 0; i < size; i++)
            {
                const axis2_phase_t *phase = axutil_array_list_get(in_flow, env, i);
                const axis2_char_t *phase_name = axis2_phase_get_name(phase, env);
                if(0 == axutil_strcmp(phase_name, "RMPhase"))
                {
                    axutil_array_list_add(new_flow, env, phase);
                }
            }
            axis2_op_set_in_flow(make_conn_op, env, new_flow);
        }
    }*/

    make_conn = sandesha2_make_connection_create(env, mc_ns_value);
    if(make_conn_seq_id)
    {
        sandesha2_identifier_t *identifier = sandesha2_identifier_create(env, 
            rm_ns_value);
        if(identifier)
            sandesha2_identifier_set_identifier(identifier, env, 
                make_conn_seq_id);
        if(make_conn)
            sandesha2_make_connection_set_identifier(make_conn, env, identifier);
    }

    if(make_conn_anon_uri)
    {
        sandesha2_mc_address_t *address = NULL;
        axis2_endpoint_ref_t *epr = NULL;

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

        address = sandesha2_mc_address_create(env, mc_ns_value, NULL);
        epr = axis2_endpoint_ref_create(env, make_conn_anon_uri);

        if(address)
        {
            sandesha2_mc_address_set_epr(address, env, epr);
        }

        if(make_conn)
        {
            sandesha2_make_connection_set_address(make_conn, env, address);
        }
    }

    if(make_conn_msg_ctx)
    {
        axis2_endpoint_ref_t *to = NULL;
        axis2_endpoint_ref_t *reply_to = NULL;
        axis2_char_t *address = NULL;
        axutil_string_t *soap_action = NULL;

        /* Setting the addressing properties */
        to = axis2_msg_ctx_get_to(ref_msg_ctx, env);
        address = (axis2_char_t *) axis2_endpoint_ref_get_address((const axis2_endpoint_ref_t *) to, env);
        to = axis2_endpoint_ref_create(env, address);
        axis2_msg_ctx_set_to(make_conn_msg_ctx, env, to);
        reply_to = axis2_endpoint_ref_create(env, AXIS2_WSA_ANONYMOUS_URL);
        axis2_msg_ctx_set_reply_to(make_conn_msg_ctx, env, reply_to);
        wsa_action = sandesha2_spec_specific_consts_get_make_connection_action(env, SANDESHA2_SPEC_VERSION_1_1);
        axis2_msg_ctx_set_wsa_action(make_conn_msg_ctx, env, wsa_action);
        soap_action = axutil_string_create(env, wsa_action);
        axis2_msg_ctx_set_soap_action(make_conn_msg_ctx, env, soap_action);
        axis2_msg_ctx_set_message_id(make_conn_msg_ctx, env, axutil_uuid_gen(env));
    
        sandesha2_msg_ctx_set_make_connection(make_conn_rm_msg_ctx, env, make_conn);

       /* Generating the soap envelope */
        sandesha2_msg_ctx_add_soap_envelope(make_conn_rm_msg_ctx, env);
        return make_conn_rm_msg_ctx;
    }

    return NULL;
}
Ejemplo n.º 8
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
sandesha2_seq_mgr_setup_new_outgoing_sequence(
    const axutil_env_t *env,
    axis2_msg_ctx_t *first_app_msg,
    axis2_char_t *internal_sequence_id,
    axis2_char_t *spec_version,
    sandesha2_seq_property_mgr_t *seq_prop_mgr)
{
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_char_t *addr_ns_val = NULL;
    axutil_property_t *property = NULL;
    sandesha2_seq_property_bean_t *addr_ns_bean = NULL;
    axis2_char_t *anon_uri = NULL;
    axis2_endpoint_ref_t *to_epr = NULL;
    axis2_char_t *acks_to_str = NULL;
    sandesha2_seq_property_bean_t *to_bean = NULL;
    sandesha2_seq_property_bean_t *reply_to_bean = NULL;
    sandesha2_seq_property_bean_t *acks_to_bean = NULL;
    sandesha2_seq_property_bean_t *msgs_bean = NULL;
    axis2_char_t *transport_to = NULL;
    axis2_endpoint_ref_t *reply_to_epr = NULL;
    axis2_bool_t is_svr_side = AXIS2_FALSE;
   
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "Entry:sandesha2_seq_mgr_setup_new_outgoing_sequence");

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

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

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

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

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

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

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

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

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

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

        reply_to_epr = axis2_msg_ctx_get_to(req_msg_ctx, env);

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

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

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

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

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

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

        sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, transport_to_bean);
    }

    sandesha2_seq_mgr_update_last_activated_time(env, internal_sequence_id, seq_prop_mgr);

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

    return AXIS2_SUCCESS;
}
Ejemplo n.º 9
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;
}
Ejemplo n.º 10
0
axis2_op_t *AXIS2_CALL
axis2_rest_disp_find_op(
    axis2_msg_ctx_t * msg_ctx,
    const axutil_env_t * env,
    axis2_svc_t * svc)
{
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_op_t *op = NULL;
    axiom_soap_envelope_t *soap_env = NULL;
    axiom_soap_body_t *soap_body = NULL;
    axiom_element_t *body_child = NULL;
    axiom_node_t *body_child_node = NULL;
    axiom_node_t *body_element_node = NULL;
    axis2_bool_t soap_env_exists = AXIS2_TRUE;
    int i = 0;

    axutil_array_list_t *param_keys = NULL;
    axutil_array_list_t *param_values = NULL;

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

    if(!axis2_msg_ctx_get_doing_rest(msg_ctx, env))
        return NULL;

    endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env);

    if(endpoint_ref)
    {
        const axis2_char_t *address = NULL;

        address = axis2_endpoint_ref_get_address(endpoint_ref, env);
        if(address)
        {
            axis2_char_t **url_tokens = NULL;

            url_tokens = axutil_parse_request_url_for_svc_and_op(env, address);

            if(url_tokens)
            {
                if(url_tokens[0])
                {
                    axis2_char_t *location = NULL;

                    location = strstr(address, url_tokens[0]);
                    if(location)
                    {
                        const axis2_char_t *method = NULL;

                        location += strlen(url_tokens[0]);
                        param_keys = axutil_array_list_create(env, 10);
                        if(!param_keys)
                        {
                            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                                "No memory. Cannot create the live rest parameter maps");
                            return NULL;
                        }
                        param_values = axutil_array_list_create(env, 10);

                        if(!param_values)
                        {
                            axutil_array_list_free(param_keys, env);
                            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                                "No memory. Cannot create the live rest parameter maps");
                            return NULL;
                        }
                        method = axis2_msg_ctx_get_rest_http_method(msg_ctx, env);
                        op = axis2_core_utils_get_rest_op_with_method_and_location(svc, env,
                            method, location, param_keys, param_values);
                    }
                }
                if(url_tokens[0])
                    AXIS2_FREE(env->allocator, url_tokens[0]);
                if(url_tokens[1])
                    AXIS2_FREE(env->allocator, url_tokens[1]);
                AXIS2_FREE(env->allocator, url_tokens);
            }
        }
    }

    if(!op)
    {
        if(param_keys)
        {
            for(i = 0; i < axutil_array_list_size(param_keys, env); i++)
            {
                void *value = axutil_array_list_get(param_keys, env, i);
                AXIS2_FREE(env->allocator, value);
            }
            axutil_array_list_free(param_keys, env);
        }
        if(param_values)
        {
            for(i = 0; i < axutil_array_list_size(param_values, env); i++)
            {
                void *value = axutil_array_list_get(param_values, env, i);
                AXIS2_FREE(env->allocator, value);
            }
            axutil_array_list_free(param_values, env);
        }
        return NULL;
    }

    soap_env = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);

    if(!soap_env)
    {
        soap_env_exists = AXIS2_FALSE;
        soap_env = axiom_soap_envelope_create_default_soap_envelope(env, AXIOM_SOAP11);
    }
    if(soap_env)
    {
        soap_body = axiom_soap_envelope_get_body(soap_env, env);
    }
    if(!soap_body)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL, AXIS2_FAILURE);

        if(param_keys)
        {
            for(i = 0; i < axutil_array_list_size(param_keys, env); i++)
            {
                void *value = axutil_array_list_get(param_keys, env, i);
                AXIS2_FREE(env->allocator, value);
            }
            axutil_array_list_free(param_keys, env);
        }
        if(param_values)
        {
            for(i = 0; i < axutil_array_list_size(param_values, env); i++)
            {
                void *value = axutil_array_list_get(param_values, env, i);
                AXIS2_FREE(env->allocator, value);
            }
            axutil_array_list_free(param_values, env);
        }
        return NULL;
    }

    body_element_node = axiom_soap_body_get_base_node(soap_body, env);

    if(body_element_node)
    {
        body_child_node = axiom_node_get_first_child(body_element_node, env);
    }

    if(!body_child_node)
    {
        body_child = axiom_element_create_with_qname(env, NULL, axis2_op_get_qname(op, env),
            &body_child_node);
        axiom_soap_body_add_child(soap_body, env, body_child_node);
    }

    if(param_keys && param_values)
    {
        for(i = 0; i < axutil_array_list_size(param_keys, env); i++)
        {
            axis2_char_t *param_key = NULL;
            axis2_char_t *param_value = NULL;

            axiom_node_t *node = NULL;
            axiom_element_t *element = NULL;

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

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

            AXIS2_FREE(env->allocator, param_key);
            AXIS2_FREE(env->allocator, param_value);
        }

        axutil_array_list_free(param_keys, env);
        axutil_array_list_free(param_values, env);
    }

    if(!soap_env_exists)
    {
        axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_env);
    }

    return op;
}
Ejemplo n.º 11
0
axis2_status_t AXIS2_CALL
axis2_addr_out_handler_invoke(
    struct axis2_handler * handler,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axis2_char_t *addr_ver_from_msg_ctx = NULL;
    const axis2_char_t *addr_ns = NULL;
    axis2_msg_info_headers_t *msg_info_headers = NULL;
    axis2_ctx_t *ctx = NULL;
    axiom_soap_envelope_t *soap_envelope = NULL;
    axiom_soap_header_t *soap_header = NULL;
    axiom_node_t *soap_header_node = NULL;
    axiom_element_t *soap_header_ele = NULL;
    axis2_endpoint_ref_t *epr_to = NULL;
    axis2_endpoint_ref_t *epr_reply_to = NULL;
    axis2_endpoint_ref_t *epr_from = NULL;
    axis2_endpoint_ref_t *epr_fault_to = NULL;
    axutil_property_t *property = NULL;
    const axis2_char_t *wsa_action = NULL;
	axis2_bool_t set_must_understand = AXIS2_FALSE;
	axutil_property_t *must_understand_prop;

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

    AXIS2_LOG_INFO(env->log, "Starting addressing out handler");

    soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
    if(!soap_envelope)
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No SOAP envelope. Stop processing addressing");
        return AXIS2_SUCCESS; /* Can happen in case of ONE-WAY services/clients */
    }

    msg_info_headers = axis2_msg_ctx_get_msg_info_headers(msg_ctx, env);

    if(msg_info_headers)
    {
        wsa_action = axis2_msg_info_headers_get_action(msg_info_headers, env);
    }
    else
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No addressing in use");
        return AXIS2_SUCCESS; /* No addressing in use */
    }

    if(!wsa_action || !*wsa_action)
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No action present. Stop processing addressing");
        return AXIS2_SUCCESS; /* If no action present, assume no addressing in use */
    }


    ctx = axis2_msg_ctx_get_base(msg_ctx, env);
    property = axis2_ctx_get_property(ctx, env, AXIS2_WSA_VERSION);

    if(property)
    {
        addr_ver_from_msg_ctx = axutil_property_get_value(property, env);
        property = NULL;
    }

	must_understand_prop = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_ADDR_ADD_MUST_UNDERSTAND_TO_ADDR_HEADERS);
	if(must_understand_prop)
	{
		axis2_char_t *value = axutil_property_get_value(must_understand_prop, env);
		if(axutil_strcmp(value, AXIS2_VALUE_TRUE) == 0)
			set_must_understand = AXIS2_TRUE;
	}

    /* Setting version 1.0 as the default addressing namespace */
    addr_ns = AXIS2_WSA_NAMESPACE;

    if(addr_ver_from_msg_ctx)
    {
        if(!axutil_strcmp(AXIS2_WSA_NAMESPACE_SUBMISSION, addr_ver_from_msg_ctx))
        {
            addr_ns = AXIS2_WSA_NAMESPACE_SUBMISSION;
        }
    }
    else if(axis2_msg_ctx_get_op_ctx(msg_ctx, env))
    {
        axis2_op_ctx_t *op_ctx = NULL;
        axis2_msg_ctx_t *in_msg_ctx = NULL;
        op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);

        if(op_ctx)
        {
            in_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN);
        }

        if(in_msg_ctx)
        {
            axis2_ctx_t *in_ctx = NULL;
            in_ctx = axis2_msg_ctx_get_base(in_msg_ctx, env);

            property = axis2_ctx_get_property(in_ctx, env, AXIS2_WSA_VERSION);
            if(property)
            {
                addr_ns = axutil_property_get_value(property, env);
                property = NULL;
            }

            if(!addr_ns || !*addr_ns)
            {
                addr_ns = AXIS2_WSA_NAMESPACE;
            }
        }
    }

    soap_header = axiom_soap_envelope_get_header(soap_envelope, env);
    if(!soap_header)
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "No SOAP header. Stop processing addressing");
        return AXIS2_SUCCESS; /* No SOAP header, so no point proceeding */
    }
    else
    {
        /* By this time, we definitely have some addressing information to be sent. This is because,
         * we have tested at the start of this whether msg_info_headers are null or not.
         * So rather than declaring addressing namespace in each and every addressing header, lets
         * define that in the Header itself.
         */
        const axis2_char_t *action = NULL;
        const axis2_char_t *address = NULL;
        const axis2_char_t *svc_group_context_id = NULL;
        const axis2_char_t *message_id = NULL;
        axis2_relates_to_t *relates_to = NULL;
        axiom_node_t *relates_to_header_node = NULL;
        axiom_element_t *relates_to_header_ele = NULL;
        axiom_namespace_t *addressing_namespace = NULL;

        soap_header_node = axiom_soap_header_get_base_node(soap_header, env);
        soap_header_ele = (axiom_element_t *)axiom_node_get_data_element(soap_header_node, env);

        addressing_namespace = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);

        axiom_element_declare_namespace(soap_header_ele, env, soap_header_node,
            addressing_namespace);

        epr_to = axis2_msg_info_headers_get_to(msg_info_headers, env);

        if(epr_to)
        {
            axiom_soap_body_t *body = axiom_soap_envelope_get_body(soap_envelope, env);

            if(body)
            {
                /* In case of a SOAP fault, we got to send the response to
                 the adress specified by FaultTo */
                if(axiom_soap_body_has_fault(body, env))
                {
                    axis2_endpoint_ref_t *epr_fault_to = axis2_msg_info_headers_get_fault_to(
                        msg_info_headers, env);
                    if(epr_fault_to)
                    {
                        const axis2_char_t *fault_to_address = axis2_endpoint_ref_get_address(
                            epr_fault_to, env);
                        if(fault_to_address)
                        {
                            if(axutil_strcmp(AXIS2_WSA_NONE_URL, fault_to_address)
                                && axutil_strcmp(AXIS2_WSA_NONE_URL_SUBMISSION, fault_to_address))
                            {
                                axis2_endpoint_ref_set_address(epr_to, env, fault_to_address);
                            }
                        }
                    }
                }
            }

            address = axis2_endpoint_ref_get_address(epr_to, env);
            if(address && *address)
            {
                axiom_node_t *to_header_block_node = NULL;
                axiom_soap_header_block_t *to_header_block = NULL;
                axutil_array_list_t *ref_param_list = NULL;
                int size = 0;

                to_header_block = axiom_soap_header_add_header_block(soap_header, env,
                    AXIS2_WSA_TO, addressing_namespace);
				if(set_must_understand == AXIS2_TRUE)
				{
					axiom_soap_header_block_set_must_understand_with_bool(to_header_block, env, AXIS2_TRUE);
				}
				to_header_block_node = axiom_soap_header_block_get_base_node(to_header_block, env);
                if(to_header_block_node)
                {
                    axiom_element_t *to_header_block_element = NULL;
                    to_header_block_element = (axiom_element_t *)axiom_node_get_data_element(
                        to_header_block_node, env);
                    if(to_header_block_element)
                    {
                        axiom_element_set_text(to_header_block_element, env, address,
                            to_header_block_node);
                    }
                }

                ref_param_list = axis2_endpoint_ref_get_ref_param_list(epr_to, env);

                size = axutil_array_list_size(ref_param_list, env);
                if(ref_param_list && size > 0)
                {
                    axiom_soap_header_block_t *reference_header_block = NULL;
                    axiom_node_t *reference_node = NULL;
                    int i = 0;

                    for(i = 0; i < size; i++)
                    {
                        axiom_node_t *temp_node = NULL;

                        temp_node = (axiom_node_t *)axutil_array_list_get(ref_param_list, env, i);
                        if(temp_node)
                        {
                            axiom_element_t *temp_ele = NULL;

                            temp_ele = axiom_node_get_data_element(temp_node, env);
                            if(temp_ele)
                            {
                                reference_header_block = axiom_soap_header_add_header_block(
                                    soap_header, env, axiom_element_get_localname(temp_ele, env),
                                    axiom_element_get_namespace(temp_ele, env, temp_node));
								if(set_must_understand)
								{
									axiom_soap_header_block_set_must_understand_with_bool(reference_header_block, env, AXIS2_TRUE);
								}

                                reference_node = axiom_soap_header_block_get_base_node(
                                    reference_header_block, env);
                                if(reference_node)
                                {
                                    axiom_element_t *reference_ele = NULL;
                                    reference_ele = (axiom_element_t *)axiom_node_get_data_element(
                                        reference_node, env);

                                    if(reference_ele)
                                    {
                                        axiom_namespace_t *addr_ns_obj = NULL;
                                        axiom_attribute_t *reference_attr = NULL;

                                        addr_ns_obj = axiom_namespace_create(env, addr_ns,
                                            AXIS2_WSA_DEFAULT_PREFIX);
                                        reference_attr = axiom_attribute_create(env,
                                        /*"isReferenceParameter"*/
                                        AXIS2_WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE, "true",
                                            addr_ns_obj);
                                        axiom_element_add_attribute(reference_ele, env,
                                            reference_attr, reference_node);
                                        axiom_element_set_text(reference_ele, env,
                                            axiom_element_get_text(temp_ele, env, temp_node),
                                            reference_node);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }/* if(epr_to) */

		axiom_namespace_free(addressing_namespace, env);

        action = axis2_msg_info_headers_get_action(msg_info_headers, env);
        if(action && *action)
        {
            axis2_addr_out_handler_process_string_info(env, action, AXIS2_WSA_ACTION, &soap_header,
				addr_ns, set_must_understand);
        }

        epr_reply_to = axis2_msg_info_headers_get_reply_to(msg_info_headers, env);
        if(!epr_reply_to)
        {
            const axis2_char_t *anonymous_uri = NULL;
            axis2_bool_t anonymous = axis2_msg_info_headers_get_reply_to_anonymous(
                msg_info_headers, env);
            axis2_bool_t none = axis2_msg_info_headers_get_reply_to_none(msg_info_headers, env);
            if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION))
            {
                if(none)
                {
                    anonymous_uri = AXIS2_WSA_NONE_URL_SUBMISSION;
                }
                else if(anonymous)
                {
                    anonymous_uri = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION;
                }
            }
            else
            {
                if(none)
                {
                    anonymous_uri = AXIS2_WSA_NONE_URL;
                }
                else if(anonymous)
                {
                    anonymous_uri = AXIS2_WSA_ANONYMOUS_URL;
                }
            }

            if(anonymous_uri)
            {
                epr_reply_to = axis2_endpoint_ref_create(env, anonymous_uri);
            }

            if(epr_reply_to)
            {
                axis2_msg_info_headers_set_reply_to(msg_info_headers, env, epr_reply_to);
            }
        }

        /* add the service group id as a reference parameter */
        svc_group_context_id = axutil_string_get_buffer(axis2_msg_ctx_get_svc_grp_ctx_id(msg_ctx,
            env), env);

        axis2_addr_out_handler_add_to_soap_header(env, epr_reply_to, AXIS2_WSA_REPLY_TO,
            soap_header, addr_ns);

        epr_from = axis2_msg_info_headers_get_from(msg_info_headers, env);

        if(epr_from)
        {
            axis2_addr_out_handler_add_to_soap_header(env, epr_from, AXIS2_WSA_FROM, soap_header,
                addr_ns);

        }

        epr_fault_to = axis2_msg_info_headers_get_fault_to(msg_info_headers, env);
        if(!epr_fault_to)
        {
            const axis2_char_t *anonymous_uri = NULL;
            axis2_bool_t anonymous = axis2_msg_info_headers_get_fault_to_anonymous(
                msg_info_headers, env);
            axis2_bool_t none = axis2_msg_info_headers_get_fault_to_none(msg_info_headers, env);
            if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION))
            {
                if(none)
                {
                    anonymous_uri = AXIS2_WSA_NONE_URL_SUBMISSION;
                }
                else if(anonymous)
                {
                    anonymous_uri = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION;
                }
            }
            else
            {
                if(none)
                    anonymous_uri = AXIS2_WSA_NONE_URL;
                else if(anonymous)
                    anonymous_uri = AXIS2_WSA_ANONYMOUS_URL;
            }

            if(anonymous_uri)
            {
                epr_fault_to = axis2_endpoint_ref_create(env, anonymous_uri);
            }
        }

        if(epr_fault_to)
        {
            /* optional */
            axis2_addr_out_handler_add_to_soap_header(env, epr_fault_to, AXIS2_WSA_FAULT_TO,
                soap_header, addr_ns);
        }

        message_id = axis2_msg_info_headers_get_message_id(msg_info_headers, env);

        if(message_id)
        {
            axis2_addr_out_handler_process_string_info(env, message_id, AXIS2_WSA_MESSAGE_ID,
				&soap_header, addr_ns, set_must_understand);
        }

        relates_to = axis2_msg_info_headers_get_relates_to(msg_info_headers, env);

        if(relates_to)
        {
            const axis2_char_t *value = NULL;
            value = axis2_relates_to_get_value(relates_to, env);
            relates_to_header_node = axis2_addr_out_handler_process_string_info(env, value,
				AXIS2_WSA_RELATES_TO, &soap_header, addr_ns, set_must_understand);
        }

        if(relates_to_header_node)
        {
            const axis2_char_t *relationship_type = NULL;
            relationship_type = axis2_relates_to_get_relationship_type(relates_to, env);
            if(relationship_type && *relationship_type)
            {
                axiom_attribute_t *om_attr = NULL;
                axiom_namespace_t *addr_ns_obj = NULL;
                axiom_namespace_t *dec_ns = NULL;
                relates_to_header_ele = (axiom_element_t *)axiom_node_get_data_element(
                    relates_to_header_node, env);
                if(relates_to_header_ele)
                {
                    dec_ns = axiom_element_find_declared_namespace(relates_to_header_ele, env,
                        addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
                    if(dec_ns)
                    {
                        addr_ns_obj = dec_ns;
                    }
                    else
                    {
                        addr_ns_obj
                            = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
                    }

                    if(!axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION))
                    {
                        om_attr = axiom_attribute_create(env,
                            AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE,
                            AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE_SUBMISSION,
                            addr_ns_obj);
                    }
                    else
                    {
                        om_attr = axiom_attribute_create(env,
                            AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE,
                            AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE, addr_ns_obj);
                    }

                    axiom_element_add_attribute(relates_to_header_ele, env, om_attr,
                        relates_to_header_node);

                    dec_ns = axiom_element_find_declared_namespace(relates_to_header_ele, env,
                        addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
                    if(!dec_ns)
                    {
                        dec_ns = axiom_element_find_namespace(relates_to_header_ele, env,
                            relates_to_header_node, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
                        if(dec_ns)
                        {
                            axiom_namespace_free(addr_ns_obj, env);
                            addr_ns_obj = NULL;
                            axiom_attribute_set_namespace(om_attr, env, dec_ns);
                        }
                    }
                }

            }
        }
    }
    return AXIS2_SUCCESS;
}
Ejemplo n.º 12
0
axis2_status_t
axis2_addr_out_handler_add_to_soap_header(
    const axutil_env_t * env,
    axis2_endpoint_ref_t * endpoint_ref,
    const axis2_char_t * type,
    axiom_soap_header_t * soap_header,
    const axis2_char_t * addr_ns)
{
    axiom_soap_header_block_t *header_block = NULL;
    const axis2_char_t *address = NULL;
    axutil_array_list_t *ref_param_list = NULL;
    axutil_array_list_t *meta_data_list = NULL;
    axutil_array_list_t *extension_list = NULL;
    axiom_node_t *header_block_node = NULL;
    axiom_node_t *header_node = NULL;
    axiom_namespace_t *addr_ns_obj = NULL;
    int size = 0;

    AXIS2_PARAM_CHECK(env->error, endpoint_ref, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, type, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, soap_header, AXIS2_FAILURE);

    header_node = axiom_soap_header_get_base_node(soap_header, env);

    addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
    header_block = axiom_soap_header_add_header_block(soap_header, env, type, addr_ns_obj);
    if(addr_ns_obj)
    {
        axiom_namespace_free(addr_ns_obj, env);
        addr_ns_obj = NULL;
    }

    address = axis2_endpoint_ref_get_address(endpoint_ref, env);
    if(address && *address)
    {
        axiom_node_t *hb_node = NULL;
        axiom_element_t *hb_ele = NULL;
        axiom_node_t *address_node = NULL;
        axiom_element_t *address_ele = NULL;
        hb_node = axiom_soap_header_block_get_base_node(header_block, env);
        hb_ele = (axiom_element_t *)axiom_node_get_data_element(hb_node, env);

        addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);

        address_ele = axiom_element_create(env, hb_node, EPR_ADDRESS, addr_ns_obj, &address_node);
		axiom_namespace_free(addr_ns_obj, env);
        if(address_ele)
        {
            axiom_namespace_t *dec_ns = NULL;
            axiom_element_set_text(address_ele, env, address, address_node);
            dec_ns = axiom_element_find_declared_namespace(address_ele, env, addr_ns,
                AXIS2_WSA_DEFAULT_PREFIX);
        }
    }

    header_block_node = axiom_soap_header_block_get_base_node(header_block, env);
    axis2_addr_out_handler_add_to_header(env, endpoint_ref, &header_block_node, addr_ns);

    ref_param_list = axis2_endpoint_ref_get_ref_param_list(endpoint_ref, env);
    if(ref_param_list && axutil_array_list_size(ref_param_list, env) > 0)
    {
        axiom_node_t *reference_node = NULL;
        axiom_element_t *reference_ele = NULL;
        axutil_array_list_t *ref_attribute_list = NULL;
        int i = 0;

        addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);

        reference_ele = axiom_element_create(env, header_block_node, EPR_REFERENCE_PARAMETERS,
            addr_ns_obj, &reference_node);
		axiom_namespace_free(addr_ns_obj, env);

        ref_attribute_list = axis2_endpoint_ref_get_ref_attribute_list(endpoint_ref, env);
        if(ref_attribute_list)
        {
            int j = 0;

            size = axutil_array_list_size(ref_attribute_list, env);
            for(j = 0; j < size; j++)
            {
                axiom_attribute_t *attr = (axiom_attribute_t *)axutil_array_list_get(
                    ref_attribute_list, env, j);
                if(attr)
                {
                    axiom_element_add_attribute(reference_ele, env, attr, reference_node);
                }
            }
        }

        size = axutil_array_list_size(ref_param_list, env);
        for(i = 0; i < size; i++)
        {
            axiom_node_t *ref_node = (axiom_node_t *)axutil_array_list_get(ref_param_list, env, i);
            if(ref_node)
            {
                axiom_node_add_child(reference_node, env, ref_node);
            }
        }

    }

    meta_data_list = axis2_endpoint_ref_get_metadata_list(endpoint_ref, env);
    if(meta_data_list && axutil_array_list_size(meta_data_list, env) > 0)
    {
        axiom_node_t *reference_node = NULL;
        axiom_element_t *reference_ele = NULL;
        axutil_array_list_t *meta_attribute_list = NULL;
        int i = 0;

        if(!reference_node) /* may be we alredy created this in ref params block */
        {
            addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);

            reference_ele = axiom_element_create(env, header_block_node, AXIS2_WSA_METADATA,
                addr_ns_obj, &reference_node);
			axiom_namespace_free(addr_ns_obj, env);
        }

        meta_attribute_list = axis2_endpoint_ref_get_metadata_attribute_list(endpoint_ref, env);
        if(meta_attribute_list)
        {
            int j = 0;
            size = axutil_array_list_size(meta_attribute_list, env);
            for(j = 0; j < size; j++)
            {
                axiom_attribute_t *attr = (axiom_attribute_t *)axutil_array_list_get(
                    meta_attribute_list, env, j);
                if(attr)
                {
                    axiom_element_add_attribute(reference_ele, env, attr, reference_node);
                }
            }
        }

        size = axutil_array_list_size(meta_data_list, env);
        for(i = 0; i < size; i++)
        {
            axiom_node_t *ref_node = (axiom_node_t *)axutil_array_list_get(meta_data_list, env, i);
            if(ref_node)
            {
                axiom_node_add_child(reference_node, env, ref_node);
            }
        }
    }

    extension_list = axis2_endpoint_ref_get_extension_list(endpoint_ref, env);
    if(extension_list && axutil_array_list_size(extension_list, env) > 0)
    {
        int i = 0;

        size = axutil_array_list_size(extension_list, env);
        for(i = 0; i < size; i++)
        {
            axiom_node_t *ref_node = (axiom_node_t *)axutil_array_list_get(extension_list, env, i);
            if(ref_node)
            {
                axiom_node_add_child(header_block_node, env, ref_node);
            }
        }
    }

    return AXIS2_SUCCESS;
}
Ejemplo n.º 13
0
static axis2_svc_t *AXIS2_CALL
axis2_addr_disp_find_svc(
    axis2_msg_ctx_t * msg_ctx,
    const axutil_env_t * env)
{
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_svc_t *svc = NULL;

    if(axis2_msg_ctx_get_doing_rest(msg_ctx, env))
        return NULL;

    endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env);

    if(endpoint_ref)
    {
        const axis2_char_t *address = NULL;

        address = axis2_endpoint_ref_get_address(endpoint_ref, env);
        if(address)
        {
            axis2_char_t **url_tokens = NULL;
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                "Checking for service using WSA enpoint address : %s", address);

            if((axutil_strcmp(AXIS2_WSA_ANONYMOUS_URL, address) == 0) || (axutil_strcmp(
                AXIS2_WSA_NAMESPACE_SUBMISSION, address) == 0))
            {
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                    "Endpoint address cannot be the same as WSA namespace : %s", address);
                return NULL;
            }

            url_tokens = axutil_parse_request_url_for_svc_and_op(env, address);

            if(url_tokens)
            {
                if(url_tokens[0])
                {
                    axis2_conf_ctx_t *conf_ctx = NULL;

                    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
                    if(conf_ctx)
                    {
                        axis2_conf_t *conf = NULL;
                        conf = axis2_conf_ctx_get_conf(conf_ctx, env);
                        if(conf)
                        {
                            svc = axis2_conf_get_svc(conf, env, url_tokens[0]);

                            if(svc)
                            {
                                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                                    "Service found using WSA enpoint address");
                            }
                        }
                    }
                    AXIS2_FREE(env->allocator, url_tokens[0]);
                }
                if(url_tokens[1])
                {
                    AXIS2_FREE(env->allocator, url_tokens[1]);
                }
                AXIS2_FREE(env->allocator, url_tokens);
                url_tokens = NULL;
            }
        }
    }

    return svc;
}
Ejemplo n.º 14
0
AXIS2_EXTERN axis2_char_t *AXIS2_CALL
sandesha2_seq_mgr_setup_new_incoming_sequence(
    const axutil_env_t *env,
    sandesha2_msg_ctx_t *create_seq_msg, 
    sandesha2_seq_property_mgr_t *seq_prop_mgr,
    sandesha2_next_msg_mgr_t *next_msg_mgr)
{
    axis2_char_t *rmd_sequence_id = NULL;
    axis2_endpoint_ref_t *to = NULL;
    axis2_endpoint_ref_t *reply_to = NULL;
    axis2_endpoint_ref_t *acks_to = NULL;
    sandesha2_acks_to_t *temp_acks_to = NULL;
    sandesha2_address_t *temp_address = NULL;
    sandesha2_create_seq_t *create_seq = NULL;
    axis2_msg_ctx_t *msg_ctx = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    sandesha2_seq_property_bean_t *received_msg_bean = NULL;
    sandesha2_seq_property_bean_t *addressing_ns_bean = NULL;
    sandesha2_seq_property_bean_t *reply_to_bean = NULL;
    sandesha2_seq_property_bean_t *acks_to_bean = NULL;
    sandesha2_seq_property_bean_t *to_bean = NULL;
    sandesha2_next_msg_bean_t *next_msg_bean = NULL;
    axis2_char_t *addressing_ns_value = NULL;
    axis2_char_t *anonymous_uri = NULL;
    axis2_char_t *create_seq_msg_action = NULL;
    axis2_char_t *msg_rm_ns = NULL;
    axis2_char_t *spec_version = NULL;
    axis2_char_t *address = NULL;
    axis2_char_t *reply_to_addr = NULL;

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

    rmd_sequence_id = axutil_uuid_gen(env);
    to = sandesha2_msg_ctx_get_to(create_seq_msg, env);
    if(!to)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "To is NULL");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_TO_IS_NULL, AXIS2_FAILURE);
        return NULL; 
    }

    reply_to = sandesha2_msg_ctx_get_reply_to(create_seq_msg, env);
    create_seq = sandesha2_msg_ctx_get_create_seq(create_seq_msg, env);
    if(!create_seq)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Create Sequence Part is NULL");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CREATE_SEQ_PART_IS_NULL, AXIS2_FAILURE);
        return NULL; 
    }

    temp_acks_to = sandesha2_create_seq_get_acks_to(create_seq, env);
    temp_address = sandesha2_acks_to_get_address(temp_acks_to, env);
    acks_to = sandesha2_address_get_epr(temp_address, env);
    if(!acks_to)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Acks To is NULL");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_ACKS_TO_IS_NULL, AXIS2_FAILURE);
        return NULL; 
    }

    msg_ctx = sandesha2_msg_ctx_get_msg_ctx(create_seq_msg, env);
    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);

    /* Setting the addressing version */
    addressing_ns_value = sandesha2_msg_ctx_get_addr_ns_val(create_seq_msg, env);
    addressing_ns_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id, 
            SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, addressing_ns_value);
    if(addressing_ns_bean)
    {
        sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, addressing_ns_bean);
        sandesha2_seq_property_bean_free(addressing_ns_bean, env);
    }
    anonymous_uri = sandesha2_spec_specific_consts_get_anon_uri(env, addressing_ns_value); 

    /* If no replyTo value. Send responses as sync. */
    if(reply_to)
    {
        reply_to_addr = (axis2_char_t*)axis2_endpoint_ref_get_address(reply_to, env);
        to_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id, 
                SANDESHA2_SEQ_PROP_TO_EPR, reply_to_addr);
    }
    else
    {
        to_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id, 
                SANDESHA2_SEQ_PROP_TO_EPR, anonymous_uri);
    }

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

    address = (axis2_char_t*)axis2_endpoint_ref_get_address(to, env);
    reply_to_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id, 
        SANDESHA2_SEQ_PROP_REPLY_TO_EPR, address);
    if(reply_to_bean)
    {
        sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, reply_to_bean);
        sandesha2_seq_property_bean_free(reply_to_bean, env);
    }

    address = (axis2_char_t*)axis2_endpoint_ref_get_address(acks_to, env);
    acks_to_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id, 
        SANDESHA2_SEQ_PROP_ACKS_TO_EPR, address);

    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);
    }

    received_msg_bean = sandesha2_seq_property_bean_create_with_data(env, rmd_sequence_id, 
            SANDESHA2_SEQ_PROP_SERVER_COMPLETED_MESSAGES, "");
    if(received_msg_bean)
    {
        sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, received_msg_bean);
        sandesha2_seq_property_bean_free(received_msg_bean, env);
    }


    next_msg_bean = sandesha2_next_msg_bean_create_with_data(env, rmd_sequence_id, 1); 
                                                    /* 1 will be the next */
    if(next_msg_bean)
    {
        axis2_char_t *internal_sequence_id = NULL;

        internal_sequence_id = sandesha2_utils_get_internal_sequence_id(env, rmd_sequence_id);
        if(internal_sequence_id)
        {
            sandesha2_next_msg_bean_set_internal_seq_id(next_msg_bean, env, internal_sequence_id);
            AXIS2_FREE(env->allocator, internal_sequence_id);
        }

        sandesha2_next_msg_mgr_insert(next_msg_mgr, env, next_msg_bean);
        sandesha2_next_msg_bean_free(next_msg_bean, env);
    }

    /* Message to invoke. This will apply for only in-order invocations */
    /*if(!axis2_msg_ctx_get_server_side(msg_ctx, env) || !sandesha2_utils_is_anon_uri(env, 
     * reply_to_addr))
     * {
     *   sandesha2_utils_start_sender_for_seq(env, conf_ctx, rmd_sequence_id);
     *}*/

    /* Setting the RM Spec version for this sequence */
    create_seq_msg_action = sandesha2_msg_ctx_get_wsa_action(create_seq_msg, env);
    if(!create_seq_msg_action)
    {
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CREATE_SEQ_MSG_DOES_NOT_HAVE_WSA_ACTION_VALUE, 
            AXIS2_FAILURE);

        return NULL;
    }

    msg_rm_ns = sandesha2_create_seq_get_namespace_value(create_seq, env);

    if(!axutil_strcmp(SANDESHA2_SPEC_2005_02_NS_URI, msg_rm_ns))
    {
        spec_version = axutil_strdup(env, SANDESHA2_SPEC_VERSION_1_0);
    }
    else if(!axutil_strcmp(SANDESHA2_SPEC_2007_02_NS_URI, msg_rm_ns))
    {
        spec_version = axutil_strdup(env, SANDESHA2_SPEC_VERSION_1_1);
    }
    else
    {
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CREATE_SEQ_MSG_DOES_NOT_HAVE_VALID_RM_NS_VALUE,
            AXIS2_FAILURE);

        return NULL;
    }

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

    /* TODO Get the SOAP version from the creaet sequence message */

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

    return rmd_sequence_id;
}
static axis2_status_t AXIS2_CALL
sandesha2_terminate_seq_msg_processor_add_terminate_seq_res(
    const axutil_env_t *env,
    sandesha2_msg_ctx_t *rm_msg_ctx,
    axis2_char_t *seq_id,
    sandesha2_seq_property_mgr_t *seq_prop_mgr)
{
    axis2_msg_ctx_t *msg_ctx = NULL;
    axis2_msg_ctx_t *out_msg_ctx = NULL;
    sandesha2_msg_ctx_t *out_rm_msg = NULL;
    sandesha2_msg_ctx_t *ack_rm_msg = NULL;
    sandesha2_seq_ack_t *seq_ack = NULL;
    axutil_property_t *property = NULL;
    axis2_engine_t *engine = NULL;
    axis2_op_ctx_t *op_ctx = NULL;
    axis2_endpoint_ref_t *to_epr = NULL;
    /*axis2_transport_out_desc_t *orig_trans_out = NULL;
    axis2_transport_out_desc_t *trans_out = NULL;
    sandesha2_sender_bean_t *term_res_bean = NULL;
    axis2_char_t *key = NULL;
    sandesha2_sender_mgr_t *retrans_mgr = NULL;*/

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

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

    msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env);
    out_msg_ctx = sandesha2_utils_create_out_msg_ctx(env, msg_ctx);
    out_rm_msg = sandesha2_msg_creator_create_terminate_seq_res_msg(env, rm_msg_ctx, out_msg_ctx,
                 seq_prop_mgr);
    if(!out_rm_msg)
    {
        return AXIS2_FAILURE;
    }

    ack_rm_msg = sandesha2_ack_mgr_generate_ack_msg(env, rm_msg_ctx, seq_id, seq_prop_mgr);
    if(ack_rm_msg)
    {
        seq_ack = sandesha2_msg_ctx_get_seq_ack(ack_rm_msg, env);
        sandesha2_msg_ctx_set_seq_ack(out_rm_msg, env, seq_ack);
    }

    sandesha2_msg_ctx_add_soap_envelope(out_rm_msg, env);
    sandesha2_msg_ctx_set_flow(out_rm_msg, env, AXIS2_OUT_FLOW);

    property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
    axis2_msg_ctx_set_property(out_msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, property);

    /* test code */
    /*
    to_epr = axis2_msg_ctx_get_to(out_msg_ctx, env);
    if(to_epr && !sandesha2_utils_is_anon_uri(env,
        axis2_endpoint_ref_get_address(to_epr, env)))
    {
        axis2_msg_ctx_t *tsr_msg_ctx = axis2_core_utils_create_out_msg_ctx(env, msg_ctx);
        orig_trans_out = axis2_msg_ctx_get_transport_out_desc(tsr_msg_ctx, env);
        property = axutil_property_create_with_args(env, 0, 0, 0, orig_trans_out);
        axis2_msg_ctx_set_property(tsr_msg_ctx, env, SANDESHA2_ORIGINAL_TRANSPORT_OUT_DESC, property);
        trans_out = sandesha2_utils_get_transport_out(env);
        axis2_msg_ctx_set_transport_out_desc(tsr_msg_ctx, env, trans_out);

        key = axutil_uuid_gen(env);
        term_res_bean = sandesha2_sender_bean_create(env);
        sandesha2_sender_bean_set_msg_ctx_ref_key(term_res_bean, env, key);
        property = axutil_property_create_with_args(env, 0, 0, 0, key);
        axis2_msg_ctx_set_property(tsr_msg_ctx, env, SANDESHA2_MESSAGE_STORE_KEY, property);
        sandesha2_storage_mgr_store_msg_ctx(storage_mgr, env, key, tsr_msg_ctx);
        */
    /* TODO: refine the terminate delay */
    /*
    sandesha2_sender_bean_set_time_to_send(term_res_bean, env,
        sandesha2_utils_get_current_time_in_millis(env) + SANDESHA2_TERMINATE_DELAY);
    sandesha2_sender_bean_set_msg_id(term_res_bean, env,
        (axis2_char_t *) axis2_msg_ctx_get_msg_id(tsr_msg_ctx, env));
    sandesha2_sender_bean_set_send(term_res_bean, env, AXIS2_TRUE);

    property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
    axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_QUALIFIED_FOR_SENDING, property);
    sandesha2_sender_bean_set_resend(term_res_bean, env, AXIS2_FALSE);
    retrans_mgr = sandesha2_storage_mgr_get_retrans_mgr(storage_mgr, env);
    sandesha2_sender_mgr_insert(retrans_mgr, env, term_res_bean);
    }*/
    /* end test code */

    engine = axis2_engine_create(env, axis2_msg_ctx_get_conf_ctx(msg_ctx, env));

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

    axis2_engine_send(engine, env, out_msg_ctx);
    op_ctx = axis2_msg_ctx_get_op_ctx(out_msg_ctx, env);
    if(to_epr)
    {
        if(sandesha2_utils_is_anon_uri(env, axis2_endpoint_ref_get_address(to_epr,
                                       env)))
        {
            axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_TRUE);
        }
        else
        {
            axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_FALSE);
        }
    }
    else
    {
        axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_TRUE);
    }

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

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

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

    return AXIS2_SUCCESS;
}
Ejemplo n.º 16
0
AXIS2_EXTERN axis2_amqp_destination_info_t* AXIS2_CALL
axis2_amqp_util_msg_ctx_get_destination_info(
    axis2_msg_ctx_t* msg_ctx,
    const axutil_env_t* env)
{
    /* The destination URI that is expected by this method
     * should be of one of the following formats
     * 1. amqp://IP:PORT/services/SERVICE_NAME
     * 2. jms:/SERVICE_NAME?java.naming.provider.url=tcp://IP:PORT...
     * 3. TempQueue... */

    axis2_endpoint_ref_t* endpoint_ref = NULL;
    axis2_amqp_destination_info_t* destination_info = NULL;

    destination_info = (axis2_amqp_destination_info_t*)AXIS2_MALLOC(env->allocator,
        sizeof(axis2_amqp_destination_info_t));

    destination_info->broker_ip = NULL;
    destination_info->broker_port = AXIS2_QPID_NULL_CONF_INT;
    destination_info->queue_name = NULL;

    endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env);

    if(endpoint_ref)
    {
        const axis2_char_t* endpoint_address_original = NULL;
        axis2_char_t* endpoint_address = NULL;
        char* substr = NULL;
        char* token = NULL;
        endpoint_address_original = axis2_endpoint_ref_get_address(endpoint_ref, env);

        if(!endpoint_address_original)
            return NULL;

        endpoint_address = (axis2_char_t*)AXIS2_MALLOC(env->allocator, (sizeof(axis2_char_t)
            * axutil_strlen(endpoint_address_original)) + 1);
        strcpy((char*)endpoint_address, (char*)endpoint_address_original);

        if((substr = strstr(endpoint_address, AXIS2_AMQP_EPR_PREFIX))) /* Start with amqp: */
        {
            if(strstr(endpoint_address, AXIS2_AMQP_EPR_ANON_SERVICE_NAME))
            {
                /* Server reply to dual-channel client */
                axutil_property_t* property = NULL;
                property = axis2_msg_ctx_get_property(msg_ctx, env,
                    AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO);

                if(property)
                {
                    axis2_char_t* queue_name = (axis2_char_t*)axutil_property_get_value(property,
                        env);

                    if(queue_name)
                    {
                        destination_info->queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
                            (sizeof(axis2_char_t) * strlen(queue_name)) + 1);
                        strcpy(destination_info->queue_name, queue_name);
                    }
                }
            }
            else
            {
                substr += strlen(AXIS2_AMQP_EPR_PREFIX) + 2; /* 2 -> "//" */
                if(substr) /* IP:PORT/services/SERVICE_NAME */
                {
                    token = strtok(substr, ":");
                    if(token) /* IP */
                    {
                        axis2_char_t* broker_ip = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
                            (sizeof(axis2_char_t) * strlen(token)) + 1);
                        strcpy(broker_ip, token);
                        destination_info->broker_ip = broker_ip;

                        token = strtok(NULL, "/"); /* PORT */
                        if(token)
                        {
                            destination_info->broker_port = atoi(token);

                            token = strtok(NULL, "#"); /* ... services/SERVICE_NAME */
                            if(token)
                            {
                                if((substr = strstr(token, AXIS2_AMQP_EPR_SERVICE_PREFIX)))
                                {
                                    substr += strlen(AXIS2_AMQP_EPR_SERVICE_PREFIX) + 1; /* 1 -> "/" */
                                    if(substr)
                                    {
                                        axis2_char_t* queue_name = (axis2_char_t*)AXIS2_MALLOC(
                                            env->allocator, (sizeof(axis2_char_t) * strlen(substr))
                                                + 1);
                                        strcpy(queue_name, substr);
                                        destination_info->queue_name = queue_name;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        else if(0 == strcmp(endpoint_address, AXIS2_WSA_ANONYMOUS_URL)) /* Required to work with Sandesha2 */
        {
            axutil_property_t* property = NULL;
            property = axis2_msg_ctx_get_property(msg_ctx, env,
                AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO);

            if(property)
            {
                axis2_char_t* queue_name = (axis2_char_t*)axutil_property_get_value(property, env);

                if(queue_name)
                {
                    destination_info->queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
                        (sizeof(axis2_char_t) * strlen(queue_name)) + 1);
                    strcpy(destination_info->queue_name, queue_name);
                }
            }
        }
        else if((substr = strstr(endpoint_address, "jms:/")) && (substr == endpoint_address))
        {

        }

        AXIS2_FREE(env->allocator, endpoint_address);
    }
    else
    {
        /* Single-channel blocking */
        axutil_property_t* property = NULL;
        property = axis2_msg_ctx_get_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO);

        if(property)
        {
            axis2_char_t* queue_name = (axis2_char_t*)axutil_property_get_value(property, env);

            if(queue_name)
            {
                destination_info->queue_name = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
                    (sizeof(axis2_char_t) * strlen(queue_name)) + 1);
                strcpy(destination_info->queue_name, queue_name);
            }
        }
    }

    /* Get broker IP/Port from conf_ctx if they are not
     * found in the destination URI */
    if(!destination_info->broker_ip)
    {
        axis2_conf_ctx_t* conf_ctx = NULL;

        conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
        if(conf_ctx)
        {
            axutil_property_t* property = NULL;
            property = axis2_conf_ctx_get_property(conf_ctx, env,
                AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP);

            if(property)
            {
                axis2_char_t* broker_ip = (axis2_char_t*)axutil_property_get_value(property, env);

                if(broker_ip)
                {
                    destination_info->broker_ip = (axis2_char_t*)AXIS2_MALLOC(env->allocator,
                        (sizeof(axis2_char_t) * strlen(broker_ip)) + 1);
                    strcpy(destination_info->broker_ip, broker_ip);
                }
            }

        }
    }

    if(AXIS2_QPID_NULL_CONF_INT == destination_info->broker_port)
    {
        axis2_conf_ctx_t* conf_ctx = NULL;

        conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
        if(conf_ctx)
        {
            axutil_property_t* property = NULL;
            property = axis2_conf_ctx_get_property(conf_ctx, env,
                AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT);

            if(property)
            {
                void* value = axutil_property_get_value(property, env);

                if(value)
                {
                    destination_info->broker_port = *(int*)value;
                }
            }
        }
    }

    return destination_info;
}
/**
 * This function is invoked in RM 1.1 where client explicitly send the
 * terminate sequence message
 */
static axis2_status_t AXIS2_CALL
sandesha2_terminate_seq_msg_processor_process_out_msg(
    sandesha2_msg_processor_t *msg_processor,
    const axutil_env_t *env,
    sandesha2_msg_ctx_t *rm_msg_ctx)
{
    axis2_msg_ctx_t *msg_ctx = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    sandesha2_storage_mgr_t *storage_mgr = NULL;
    sandesha2_seq_property_mgr_t *seq_prop_mgr = NULL;
    sandesha2_create_seq_mgr_t *create_seq_mgr = NULL;
    sandesha2_sender_mgr_t *sender_mgr = NULL;
    axis2_char_t *to_address = NULL;
    axis2_char_t *seq_key = NULL;
    axis2_char_t *int_seq_id = NULL;
    axis2_char_t *out_seq_id = NULL;
    axutil_property_t *property = NULL;
    axis2_char_t *terminated = NULL;
    axis2_op_t *old_op = NULL;
    axis2_op_t *out_in_op = NULL;
    axutil_qname_t *qname = NULL;
    sandesha2_terminate_seq_t *term_seq_part = NULL;
    axis2_char_t *rm_version = NULL;
    axis2_char_t *transport_to = NULL;
    sandesha2_seq_property_bean_t *term_added = NULL;
    axis2_char_t *temp_action = NULL;
    axutil_string_t *soap_action = NULL;
    axis2_char_t *dbname = NULL;

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

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

    msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env);
    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);

    dbname = sandesha2_util_get_dbname(env, conf_ctx);
    storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname);
    if(!storage_mgr)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Could not create storage manager.");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_COULD_NOT_CREATE_STORAGE_MANAGER,
                        AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }
    seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
    create_seq_mgr = sandesha2_permanent_create_seq_mgr_create(env, dbname);
    sender_mgr = sandesha2_permanent_sender_mgr_create(env, dbname);
    to_address = (axis2_char_t*)axis2_endpoint_ref_get_address(axis2_msg_ctx_get_to(msg_ctx, env),
                 env);

    property = axis2_msg_ctx_get_property(msg_ctx, env, SANDESHA2_CLIENT_SEQ_KEY);
    if(property)
    {
        seq_key = axutil_property_get_value(property, env);
    }

    int_seq_id = sandesha2_utils_get_client_internal_sequence_id(env, to_address, seq_key);
    out_seq_id = sandesha2_utils_get_seq_property(env, int_seq_id,
                 SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_SEQUENCE_ID, seq_prop_mgr);

    if(!out_seq_id)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "[sandesha2]seq_id was not found. Cannot send the terminate message");

        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_SEQ_ID, AXIS2_FAILURE);
        if(seq_prop_mgr)
        {
            sandesha2_seq_property_mgr_free(seq_prop_mgr, env);
        }

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

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

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

        return AXIS2_FAILURE;
    }

    terminated = sandesha2_utils_get_seq_property(env, int_seq_id,
                 SANDESHA2_SEQ_PROP_TERMINATE_ADDED, seq_prop_mgr);
    old_op = axis2_msg_ctx_get_op(msg_ctx, env);

    qname = axutil_qname_create(env, "temp", NULL, NULL);
    out_in_op = axis2_op_create_with_qname(env, qname);
    if(qname)
    {
        axutil_qname_free(qname, env);
    }

    axis2_op_set_msg_exchange_pattern(out_in_op, env, AXIS2_MEP_URI_OUT_IN);
    axis2_op_set_in_flow(out_in_op, env, axis2_op_get_in_flow(old_op, env));

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

        if(out_seq_id)
        {
            AXIS2_FREE(env->allocator, out_seq_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(sender_mgr)
        {
            sandesha2_sender_mgr_free(sender_mgr, env);
        }

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

        return AXIS2_SUCCESS;
    }

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

    term_seq_part = sandesha2_msg_ctx_get_terminate_seq(rm_msg_ctx, env);
    sandesha2_identifier_set_identifier(sandesha2_terminate_seq_get_identifier(term_seq_part, env),
                                        env, out_seq_id);

    sandesha2_msg_ctx_set_flow(rm_msg_ctx, env, AXIS2_OUT_FLOW);
    property = axutil_property_create_with_args(env, 0, 0, 0, AXIS2_VALUE_TRUE);
    axis2_msg_ctx_set_property(msg_ctx, env, SANDESHA2_APPLICATION_PROCESSING_DONE, property);
    axis2_msg_ctx_set_to(msg_ctx, env, axis2_endpoint_ref_create(env, to_address));
    rm_version = sandesha2_utils_get_rm_version(env, msg_ctx);
    if(!rm_version)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                        "[sandesha2] Cant find the rm_version of the given message");

        if(out_seq_id)
        {
            AXIS2_FREE(env->allocator, out_seq_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(sender_mgr)
        {
            sandesha2_sender_mgr_free(sender_mgr, env);
        }

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

        return AXIS2_FAILURE;
    }

    axis2_msg_ctx_set_wsa_action(msg_ctx, env,
                                 sandesha2_spec_specific_consts_get_terminate_seq_action(env, rm_version));

    temp_action = sandesha2_spec_specific_consts_get_terminate_seq_soap_action(env, rm_version);

    soap_action = axutil_string_create(env, temp_action);
    axis2_msg_ctx_set_soap_action(msg_ctx, env, soap_action);
    transport_to = sandesha2_utils_get_seq_property(env, int_seq_id,
                   SANDESHA2_SEQ_PROP_TRANSPORT_TO, seq_prop_mgr);

    if(transport_to)
    {
        axis2_msg_ctx_set_transport_url(msg_ctx, env, transport_to);
        AXIS2_FREE(env->allocator, transport_to);
    }

    if(!sandesha2_util_is_ack_already_piggybacked(env, rm_msg_ctx))
    {
        sandesha2_ack_mgr_piggyback_acks_if_present(env, out_seq_id, rm_msg_ctx, storage_mgr,
                seq_prop_mgr, sender_mgr);
    }

    term_added = sandesha2_seq_property_bean_create(env);
    sandesha2_seq_property_bean_set_name(term_added, env, SANDESHA2_SEQ_PROP_TERMINATE_ADDED);
    sandesha2_seq_property_bean_set_seq_id(term_added, env, int_seq_id);
    if(out_seq_id)
    {
        AXIS2_FREE(env->allocator, out_seq_id);
    }

    sandesha2_seq_property_bean_set_value(term_added, env, AXIS2_VALUE_TRUE);
    sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, term_added);

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

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

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

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

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

    return AXIS2_SUCCESS;
}
Ejemplo n.º 18
0
axis2_svc_t *AXIS2_CALL
axis2_rest_disp_find_svc(
    axis2_msg_ctx_t * msg_ctx,
    const axutil_env_t * env)
{
    axis2_endpoint_ref_t *endpoint_ref = NULL;
    axis2_svc_t *svc = NULL;

    if(!axis2_msg_ctx_get_doing_rest(msg_ctx, env))
        return NULL;

    endpoint_ref = axis2_msg_ctx_get_to(msg_ctx, env);

    if(endpoint_ref)
    {
        const axis2_char_t *address = NULL;

        address = axis2_endpoint_ref_get_address(endpoint_ref, env);
        if(address)
        {
            axis2_char_t **url_tokens = NULL;
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                "Checking for service using target endpoint address : %s", address);

            url_tokens = axutil_parse_request_url_for_svc_and_op(env, address);

            if(url_tokens)
            {
                if(url_tokens[0])
                {
                    axis2_conf_ctx_t *conf_ctx = NULL;

                    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
                    if(conf_ctx)
                    {
                        axis2_conf_t *conf = NULL;
                        conf = axis2_conf_ctx_get_conf(conf_ctx, env);
                        if(conf)
                        {
                            svc = axis2_conf_get_svc(conf, env, url_tokens[0]);
                            if(svc)
                                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI,
                                    "Service found using target endpoint address");
                        }
                    }
                    AXIS2_FREE(env->allocator, url_tokens[0]);

                    if(url_tokens[1])
                    {
                        AXIS2_FREE(env->allocator, url_tokens[1]);
                    }

                }
                AXIS2_FREE(env->allocator, url_tokens);
                url_tokens = NULL;
            }
        }
    }

    return svc;
}
Ejemplo n.º 19
0
AXIS2_EXTERN axis2_msg_ctx_t * AXIS2_CALL
axis2_engine_create_fault_msg_ctx(
    axis2_engine_t * engine,
    const axutil_env_t * env,
    axis2_msg_ctx_t * processing_context,
    const axis2_char_t * code_value,
    const axis2_char_t * reason_text)
{
    axis2_msg_ctx_t *fault_ctx = NULL;
    axis2_endpoint_ref_t *fault_to = NULL;
    axis2_endpoint_ref_t *reply_to = NULL;
    axutil_stream_t *stream = NULL;
    axiom_soap_envelope_t *envelope = NULL;
    const axis2_char_t *wsa_action = NULL;
    const axis2_char_t *msg_id = NULL;
    axis2_relates_to_t *relates_to = NULL;
    axis2_char_t *msg_uuid = NULL;
    axis2_msg_info_headers_t *msg_info_headers = NULL;
    axis2_bool_t doing_rest = AXIS2_FALSE;

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

    if(axis2_msg_ctx_get_process_fault(processing_context, env))
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_PROCESSING_FAULT_ALREADY,
            AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Creating fault message contex failed");
        return NULL;
    }

    fault_ctx = axis2_msg_ctx_create(env, engine->conf_ctx, axis2_msg_ctx_get_transport_in_desc(
        processing_context, env), axis2_msg_ctx_get_transport_out_desc(processing_context, env));

    axis2_msg_ctx_set_process_fault(fault_ctx, env, AXIS2_TRUE);

    fault_to = axis2_msg_ctx_get_fault_to(processing_context, env);
    if(fault_to)
    {
        const axis2_char_t *address = axis2_endpoint_ref_get_address(fault_to, env);
        if(!address)
        {
            fault_to = NULL;
        }
        else if(axutil_strcmp(AXIS2_WSA_NONE_URL, address) == 0 || axutil_strcmp(
            AXIS2_WSA_NONE_URL_SUBMISSION, address) == 0)
        {
            reply_to = axis2_msg_ctx_get_reply_to(processing_context, env);
            if(reply_to)
            {
                axis2_msg_ctx_set_fault_to(fault_ctx, env, reply_to);
            }
            else
            {
                axis2_msg_ctx_set_fault_to(fault_ctx, env, fault_to);
            }
        }
        else
        {
            axis2_msg_ctx_set_fault_to(fault_ctx, env, fault_to);
        }

    }

    stream = axis2_msg_ctx_get_transport_out_stream(processing_context, env);

    if(stream)
    {
        axis2_msg_ctx_set_transport_out_stream(fault_ctx, env, stream);
        axis2_msg_ctx_reset_transport_out_stream(processing_context, env);
    }

    if(!fault_to && !stream)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NOWHERE_TO_SEND_FAULT, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Soap fault target destination not found");
        return NULL;
    }

    /* Set WSA action */
    msg_info_headers = axis2_msg_ctx_get_msg_info_headers(processing_context, env);
    if(msg_info_headers)
    {
        wsa_action = axis2_msg_info_headers_get_action(msg_info_headers, env);
        if(wsa_action)
        {
            /*
             We have to use the action set by user,
             cannot use the default always.
             wsa_action = "http://www.w3.org/2005/08/addressing/fault"; */
            axis2_msg_ctx_set_wsa_action(fault_ctx, env, wsa_action);
        }
    }

    /* Set relates to */
    msg_id = axis2_msg_ctx_get_msg_id(processing_context, env);

    /* we can create with default Relates to namespace. 
     Actual namespace based on addressing version will be created in addressing out handler */
    relates_to = axis2_relates_to_create(env, msg_id,
        AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE);
    axis2_msg_ctx_set_relates_to(fault_ctx, env, relates_to);

    /* Set msg id */
    msg_uuid = axutil_uuid_gen(env);
    axis2_msg_ctx_set_message_id(fault_ctx, env, msg_uuid);
    if(msg_uuid)
    {
        AXIS2_FREE(env->allocator, msg_uuid);
        msg_uuid = NULL;
    }

	/** Copy the property map from the current message context to the newly created fault message
		context. */
	{
		axis2_ctx_t *ctx = axis2_msg_ctx_get_base(processing_context, env);
		axis2_ctx_t *fault_base_ctx = axis2_msg_ctx_get_base(fault_ctx, env);

		if(ctx && fault_ctx)
		{
			axis2_ctx_set_property_map(fault_base_ctx, env, axis2_ctx_get_property_map(ctx, env));
		}

	}


    axis2_msg_ctx_set_op_ctx(fault_ctx, env, axis2_msg_ctx_get_op_ctx(processing_context, env));
    axis2_msg_ctx_set_process_fault(fault_ctx, env, AXIS2_TRUE);
    axis2_msg_ctx_set_server_side(fault_ctx, env, AXIS2_TRUE);

    envelope = axis2_msg_ctx_get_fault_soap_envelope(processing_context, env);

    if(!envelope)
    {
        if(axis2_msg_ctx_get_is_soap_11(processing_context, env))
        {
            envelope = axiom_soap_envelope_create_default_soap_fault_envelope(env, code_value,
                reason_text, AXIOM_SOAP11, NULL, NULL);

        }
        else
        {
            envelope = axiom_soap_envelope_create_default_soap_fault_envelope(env, code_value,
                reason_text, AXIOM_SOAP12, NULL, NULL);
        }

        if(!envelope)
        {
            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Creating default soap envelope failed");
            return NULL;
        }
    }
    else
    {
        axis2_msg_ctx_set_fault_soap_envelope(processing_context, env, NULL);
    }

    doing_rest = axis2_msg_ctx_get_doing_rest(processing_context, env);
    axis2_msg_ctx_set_doing_rest(fault_ctx, env, doing_rest);

    axis2_msg_ctx_set_soap_envelope(fault_ctx, env, envelope);
    axis2_msg_ctx_set_out_transport_info(fault_ctx, env, axis2_msg_ctx_get_out_transport_info(
        processing_context, env));
    axis2_msg_ctx_reset_out_transport_info(processing_context, env);
    return fault_ctx;
}
Ejemplo n.º 20
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;
    
}
Ejemplo n.º 22
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;
}
static axis2_status_t AXIS2_CALL 
sandesha2_create_seq_res_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 *msg_ctx = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    sandesha2_storage_mgr_t *storage_mgr = NULL;
    sandesha2_create_seq_res_t *csr_part = NULL;
    axis2_char_t *outgoing_sequence_id = NULL;
    axis2_relates_to_t *relates_to = NULL;
    axis2_char_t *create_seq_msg_id = NULL;
    sandesha2_sender_mgr_t *sender_mgr = NULL;
    sandesha2_create_seq_mgr_t *create_seq_mgr = NULL;
    sandesha2_create_seq_bean_t *create_seq_bean = NULL;
    axis2_char_t *outgoing_internal_sequence_id = NULL;
    sandesha2_seq_property_mgr_t *seq_prop_mgr = NULL;
    sandesha2_seq_property_bean_t *outgoing_sequence_bean = NULL;
    sandesha2_seq_property_bean_t *outgoing_internal_sequence_bean = NULL;
    sandesha2_accept_t *accept = NULL;
    axis2_op_ctx_t *op_ctx = NULL;
    axis2_bool_t polling_mode = AXIS2_FALSE;
    axis2_char_t *dbname = NULL;
    
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,  
        "[sandesha2] Entry:sandesha2_create_seq_res_msg_processor_process_in_msg");
   
    AXIS2_PARAM_CHECK(env->error, rm_msg_ctx, AXIS2_FAILURE);

    msg_ctx = sandesha2_msg_ctx_get_msg_ctx(rm_msg_ctx, env);
    conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
    
    dbname = sandesha2_util_get_dbname(env, conf_ctx);
    storage_mgr = sandesha2_utils_get_storage_mgr(env, dbname);
    if(!storage_mgr)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Could not create storage manager.");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_COULD_NOT_CREATE_STORAGE_MANAGER, 
                AXIS2_FAILURE);
        return AXIS2_FAILURE;
    }
                        
    csr_part = sandesha2_msg_ctx_get_create_seq_res(rm_msg_ctx, env);
    if(!csr_part)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Create Sequence Response part is null");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_REQD_MSG_PART_MISSING, AXIS2_FAILURE);
        if(storage_mgr)
        {
            sandesha2_storage_mgr_free(storage_mgr, env);
        }
        return AXIS2_FAILURE;
    }

    outgoing_sequence_id = sandesha2_identifier_get_identifier(
            sandesha2_create_seq_res_get_identifier(csr_part, env), env);
    if(!outgoing_sequence_id)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Out going sequence id is null");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_SEQ_ID, AXIS2_FAILURE);
        if(storage_mgr)
        {
            sandesha2_storage_mgr_free(storage_mgr, env);
        }
        return AXIS2_FAILURE;
    }

    relates_to = axis2_msg_ctx_get_relates_to(msg_ctx, env);
    if(!relates_to)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                "[sandesha2] Invalid create sequence message. relates_to part is not available");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_INVALID_RELATES_TO, AXIS2_FAILURE);
        if(storage_mgr)
        {
            sandesha2_storage_mgr_free(storage_mgr, env);
        }
        return AXIS2_FAILURE;
    }

    create_seq_msg_id = (axis2_char_t *) axis2_relates_to_get_value(relates_to, env);
    seq_prop_mgr = sandesha2_permanent_seq_property_mgr_create(env, dbname);
    create_seq_mgr = sandesha2_permanent_create_seq_mgr_create(env, dbname);
    sender_mgr = sandesha2_permanent_sender_mgr_create(env, dbname);
    create_seq_bean = sandesha2_create_seq_mgr_retrieve(create_seq_mgr, env, create_seq_msg_id);
    if(!create_seq_bean)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Create Sequence entry not found");

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

        return AXIS2_FAILURE;
    }

    outgoing_internal_sequence_id = axutil_strdup(env, sandesha2_create_seq_bean_get_internal_sequence_id(
            create_seq_bean, env));

    if(!outgoing_internal_sequence_id)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] Internal sequence id is not set");
        AXIS2_ERROR_SET(env->error, SANDESHA2_ERROR_CANNOT_FIND_SEQ_ID, AXIS2_FAILURE);

        sandesha2_create_seq_bean_free(create_seq_bean, env);

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

        return AXIS2_FAILURE;
    }

    sandesha2_create_seq_bean_set_outgoing_sequence_id(create_seq_bean, env, outgoing_sequence_id);
    sandesha2_create_seq_mgr_update(create_seq_mgr, env, create_seq_bean);
    sandesha2_create_seq_bean_free(create_seq_bean, env);
    
    outgoing_sequence_bean = sandesha2_seq_property_bean_create_with_data(env, 
            outgoing_internal_sequence_id, SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_SEQUENCE_ID, 
            outgoing_sequence_id);
    if(outgoing_sequence_bean)
    {
        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
                "[sandesha2] Inserting outgoing_sequence_bean with outgoing_sequence_id :%s and "\
                "outgoing internal_sequence_id :%s", outgoing_sequence_id, 
                outgoing_internal_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_with_data(env, outgoing_sequence_id, 
            SANDESHA2_SEQUENCE_PROPERTY_OUTGOING_INTERNAL_SEQUENCE_ID, outgoing_internal_sequence_id);
    if(outgoing_internal_sequence_bean)
    {
        sandesha2_sender_bean_t *find_sender_bean = NULL;
        sandesha2_sender_bean_t *sender_bean = NULL;

        find_sender_bean = sandesha2_sender_bean_create(env);
        sandesha2_sender_bean_set_msg_type(find_sender_bean, env, SANDESHA2_MSG_TYPE_CREATE_SEQ);
        sandesha2_sender_bean_set_internal_seq_id(find_sender_bean, env, 
                outgoing_internal_sequence_id);
        sandesha2_sender_bean_set_send(find_sender_bean, env, AXIS2_TRUE);

        sender_bean = sandesha2_sender_mgr_find_unique(sender_mgr, env, find_sender_bean);
        if(sender_bean)
        {
            axis2_char_t *msg_id = NULL;

            msg_id = sandesha2_sender_bean_get_msg_id(sender_bean, env);
            sandesha2_sender_mgr_remove(sender_mgr, env, msg_id);
            sandesha2_sender_bean_free(sender_bean, env);
        }

        sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, outgoing_internal_sequence_bean);
        sandesha2_seq_property_bean_free(outgoing_internal_sequence_bean, env);
    }

    accept = sandesha2_create_seq_res_get_accept(csr_part, env);

    if(accept)
    {
        /*sandesha2_seq_property_bean_t *special_int_seq_bean = NULL;*/
        sandesha2_seq_property_bean_t *offerd_seq_bean = NULL;
        axis2_char_t *incoming_sequence_id = NULL;
        axis2_endpoint_ref_t *acks_to_epr = NULL;
        axis2_endpoint_ref_t *to_epr = NULL;
        sandesha2_seq_property_bean_t *acks_to_bean = NULL;
        sandesha2_next_msg_bean_t *next_bean = NULL;
        sandesha2_next_msg_mgr_t *next_msg_mgr = NULL;
        sandesha2_seq_property_bean_t *rcvd_msg_bean = NULL;
        sandesha2_seq_property_bean_t *msgs_bean = NULL;
        sandesha2_seq_property_bean_t *addr_ver_bean = NULL;
        axis2_char_t *rm_spec_ver = NULL;
        axis2_char_t *addr_ns_val = NULL;
        axis2_char_t *new_msg_store_key = NULL;
        sandesha2_seq_property_bean_t *to_seq_bean = NULL;
        sandesha2_msg_ctx_t *create_seq_rm_msg = NULL;
        axis2_msg_ctx_t *create_seq_msg = NULL;
        axis2_char_t *acks_to = NULL;
        /* axis2_char_t *reply_to_addr = NULL; */
        
        next_msg_mgr = sandesha2_permanent_next_msg_mgr_create(env, dbname);
        offerd_seq_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, 
                outgoing_internal_sequence_id, SANDESHA2_SEQ_PROP_OFFERED_SEQ);

        if(!offerd_seq_bean)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
                "[sandesha2] No offered sequence entry. But an accept was received");

            if(outgoing_internal_sequence_id)
            {
                AXIS2_FREE(env->allocator, outgoing_internal_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(sender_mgr)
            {
                sandesha2_sender_mgr_free(sender_mgr, env);
            }
            if(next_msg_mgr)
            {
                sandesha2_next_msg_mgr_free(next_msg_mgr, env);
            }
            if(storage_mgr)
            {
                sandesha2_storage_mgr_free(storage_mgr, env);
            }

            return AXIS2_FAILURE;
        }

        incoming_sequence_id = axutil_strdup(env, sandesha2_seq_property_bean_get_value(
                    offerd_seq_bean, env));

        sandesha2_seq_property_bean_free(offerd_seq_bean, env);

        /*special_int_seq_bean = sandesha2_seq_property_bean_create_with_data(env, 
                incoming_sequence_id, SANDESHA2_SEQ_PROP_SPECIAL_INTERNAL_SEQUENCE_ID, 
                outgoing_internal_sequence_id);

        if(special_int_seq_bean)
        {
            sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, special_int_seq_bean);
            sandesha2_seq_property_bean_free(special_int_seq_bean, env);
        }*/

        acks_to_epr = sandesha2_address_get_epr(sandesha2_acks_to_get_address(
                    sandesha2_accept_get_acks_to(accept, env), env), env);

        acks_to_bean = sandesha2_seq_property_bean_create(env);
        if(acks_to_bean)
        {
            sandesha2_seq_property_bean_set_name(acks_to_bean, env, SANDESHA2_SEQ_PROP_ACKS_TO_EPR);
            sandesha2_seq_property_bean_set_seq_id(acks_to_bean, env, incoming_sequence_id);

            if (acks_to_epr)
            {
                sandesha2_seq_property_bean_set_value(acks_to_bean, env, 
                    (axis2_char_t*)axis2_endpoint_ref_get_address(acks_to_epr, env));
            }

            sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, acks_to_bean);
            sandesha2_seq_property_bean_free(acks_to_bean, env);
        }
 
        rm_spec_ver = sandesha2_msg_ctx_get_rm_spec_ver(rm_msg_ctx, env);

        if(!axutil_strcmp(SANDESHA2_SPEC_VERSION_1_1, rm_spec_ver))
        {
            /*reply_to_addr = sandesha2_utils_get_seq_property(env, internal_sequence_id, 
                    SANDESHA2_SEQ_PROP_REPLY_TO_EPR, seq_prop_mgr); 
            if(reply_to_addr)
            {
                polling_mode = sandesha2_utils_is_anon_uri(env, reply_to_addr);
            }*/
        }
        
        acks_to = (axis2_char_t *) axis2_endpoint_ref_get_address(acks_to_epr, env);
        create_seq_rm_msg = sandesha2_msg_creator_create_create_seq_msg(env, rm_msg_ctx, 
                outgoing_internal_sequence_id, acks_to, seq_prop_mgr);

        if(!create_seq_rm_msg)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2]create_seq_rm_msg is NULL");

            /*if(reply_to_addr)
            {
                AXIS2_FREE(env->allocator, reply_to_addr);
            }*/

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

            if(outgoing_internal_sequence_id)
            {
                AXIS2_FREE(env->allocator, outgoing_internal_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(sender_mgr)
            {
                sandesha2_sender_mgr_free(sender_mgr, env);
            }
            if(next_msg_mgr)
            {
                sandesha2_next_msg_mgr_free(next_msg_mgr, env);
            }
            if(storage_mgr)
            {
                sandesha2_storage_mgr_free(storage_mgr, env);
            }

            return AXIS2_FAILURE;
        }

        sandesha2_msg_ctx_set_flow(create_seq_rm_msg, env, SANDESHA2_MSG_CTX_OUT_FLOW);
        create_seq_msg = sandesha2_msg_ctx_get_msg_ctx(create_seq_rm_msg, env);
        to_seq_bean = sandesha2_seq_property_mgr_retrieve(seq_prop_mgr, env, 
                outgoing_internal_sequence_id, SANDESHA2_SEQ_PROP_TO_EPR);

        if(to_seq_bean)
        {
            axis2_char_t *to_addr = sandesha2_seq_property_bean_get_value(to_seq_bean, env);
            to_epr = axis2_endpoint_ref_create(env, to_addr);

            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]to:%s", to_addr);
            sandesha2_seq_property_bean_free(to_seq_bean, env);
        }
        else
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[sandesha2] to_seq_bean is NULL");

            /*if(reply_to_addr)
            {
                AXIS2_FREE(env->allocator, reply_to_addr);
            }*/

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

            if(outgoing_internal_sequence_id)
            {
                AXIS2_FREE(env->allocator, outgoing_internal_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(sender_mgr)
            {
                sandesha2_sender_mgr_free(sender_mgr, env);
            }
            if(next_msg_mgr)
            {
                sandesha2_next_msg_mgr_free(next_msg_mgr, env);
            }
            if(storage_mgr)
            {
                sandesha2_storage_mgr_free(storage_mgr, env);
            }
        
            if(create_seq_msg)
            {
                axis2_msg_ctx_free(create_seq_msg, env);
            }

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

            return AXIS2_FAILURE;
        }

        axis2_msg_ctx_set_to(create_seq_msg, env, to_epr);
        axis2_msg_ctx_set_relates_to(create_seq_msg, env, NULL);
        new_msg_store_key = axutil_uuid_gen(env);

        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sandesha2]Storing msg_ctx with msg_id:%s", 
                axis2_msg_ctx_get_msg_id(create_seq_msg, env));

        sandesha2_storage_mgr_store_msg_ctx(storage_mgr, env, new_msg_store_key, create_seq_msg, 
                AXIS2_TRUE);

        next_bean = sandesha2_next_msg_bean_create(env);
        sandesha2_next_msg_bean_set_seq_id(next_bean, env, incoming_sequence_id);
        sandesha2_next_msg_bean_set_internal_seq_id(next_bean, env, outgoing_internal_sequence_id);
        sandesha2_next_msg_bean_set_next_msg_no_to_process(next_bean, env, 1);
        sandesha2_next_msg_bean_set_ref_msg_key(next_bean, env, new_msg_store_key);
        sandesha2_next_msg_bean_set_polling_mode(next_bean, env, polling_mode);
        if(new_msg_store_key)
        {
            AXIS2_FREE(env->allocator, new_msg_store_key);
        }

        /* If polling_mode is true, starting the polling manager */
        if(polling_mode)
        {
            /*sandesha2_polling_mgr_start(env, conf_ctx, storage_mgr, sender_mgr, create_seq_rm_msg, 
                    outgoing_internal_sequence_id, incoming_sequence_id, reply_to_addr);*/
        }

        sandesha2_next_msg_mgr_insert(next_msg_mgr, env, next_bean);
        sandesha2_next_msg_bean_free(next_bean, env);
        
        rcvd_msg_bean = sandesha2_seq_property_bean_create_with_data(env, incoming_sequence_id, 
                SANDESHA2_SEQ_PROP_SERVER_COMPLETED_MESSAGES, "");

        if(rcvd_msg_bean)
        {
            sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, rcvd_msg_bean);
            sandesha2_seq_property_bean_free(rcvd_msg_bean, env);
        }
        
        msgs_bean = sandesha2_seq_property_bean_create_with_data(env, incoming_sequence_id, 
                SANDESHA2_SEQ_PROP_CLIENT_COMPLETED_MESSAGES, "");
        if(msgs_bean)
        {
            sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, msgs_bean);
            sandesha2_seq_property_bean_free(msgs_bean, env);
        }
        
        addr_ns_val = sandesha2_msg_ctx_get_addr_ns_val(rm_msg_ctx, env);
        addr_ver_bean = sandesha2_seq_property_bean_create_with_data(env, incoming_sequence_id, 
                SANDESHA2_SEQ_PROP_ADDRESSING_NAMESPACE_VALUE, addr_ns_val);
        if(addr_ver_bean)
        {
            sandesha2_seq_property_mgr_insert(seq_prop_mgr, env, addr_ver_bean);
            sandesha2_seq_property_bean_free(addr_ver_bean, env);
        }

        if(create_seq_msg)
        {
            axis2_core_utils_reset_out_msg_ctx(env, create_seq_msg);
            axis2_msg_ctx_free(create_seq_msg, env);
        }

        /*if(reply_to_addr)
        {
            AXIS2_FREE(env->allocator, reply_to_addr);
        }*/

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

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

        if(incoming_sequence_id)
        {
            AXIS2_FREE(env->allocator, incoming_sequence_id);
        }
    } /* End of if accept block */

    sandesha2_seq_mgr_update_last_activated_time(env, outgoing_internal_sequence_id, seq_prop_mgr);
    op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
    axis2_op_ctx_set_response_written(op_ctx, env, AXIS2_TRUE);
    
    /* 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(outgoing_internal_sequence_id)
    {
        AXIS2_FREE(env->allocator, outgoing_internal_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(sender_mgr)
    {
        sandesha2_sender_mgr_free(sender_mgr, env);
    }

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

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

    return AXIS2_SUCCESS;
    
}