Beispiel #1
0
/* Process a request. If the request has a response the response structure will be populated */
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_udp_receiver_process_request(
	const axutil_env_t * env,
	axis2_conf_ctx_t *conf_ctx,    
    axis2_udp_request_t * request,
	axis2_udp_response_t * responce)
{   
    axis2_transport_out_desc_t *out_desc = NULL;
    axis2_transport_in_desc_t *in_desc = NULL;
    axis2_msg_ctx_t *msg_ctx = NULL;
    axiom_xml_reader_t *reader = NULL;
    axiom_stax_builder_t *builder = NULL;
    axiom_soap_builder_t *soap_builder = NULL;
    axiom_soap_envelope_t *soap_envelope = NULL;
    axis2_engine_t *engine = NULL;
    axis2_status_t status = AXIS2_FALSE;
    axutil_stream_t *out_stream = NULL;

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

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

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

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

    soap_builder = axiom_soap_builder_create(env, builder,
                                             AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI);

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

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

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

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

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

    soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env);
    axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope);
	if (request->svc)
	{
		axis2_msg_ctx_set_svc(msg_ctx, env, request->svc);
	}
	if (request->op)
	{
		axis2_msg_ctx_set_op(msg_ctx, env, request->op);	
	}
    engine = axis2_engine_create(env, conf_ctx);
    status = axis2_engine_receive(engine, env, msg_ctx);

    responce->buff = axutil_stream_get_buffer(out_stream, env);
	responce->buf_size = axutil_stream_get_len(out_stream, env);
    AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
                    "end:axis2_udp_worker_process_request");
    return AXIS2_SUCCESS;
}
Beispiel #2
0
static axis2_status_t AXIS2_CALL
axis2_addr_disp_invoke(
    axis2_handler_t * handler,
    const axutil_env_t * env,
    struct axis2_msg_ctx *msg_ctx)
{
    axis2_relates_to_t *relates_to = NULL;

    relates_to = axis2_msg_ctx_get_relates_to(msg_ctx, env);

    /** first check if we can dispatch using the relates_to */
    if(relates_to)
    {
        const axis2_char_t *relates_to_value = NULL;
        relates_to_value = axis2_relates_to_get_value(relates_to, env);
        if(relates_to_value && axutil_strcmp(relates_to_value, "") != 0)
        {
            axis2_conf_ctx_t *conf_ctx = NULL;

            conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
            if(conf_ctx)
            {
                axis2_op_ctx_t *op_ctx = NULL;
                const axis2_char_t *msg_id = axis2_msg_ctx_get_msg_id(msg_ctx, env);
                op_ctx = axis2_conf_ctx_get_op_ctx(conf_ctx, env, msg_id);
                if(op_ctx)
                {
                    axis2_op_t *op = NULL;
                    op = axis2_op_ctx_get_op(op_ctx, env);
                    if(op)
                    {
                        axis2_svc_ctx_t *svc_ctx = NULL;
                        axis2_msg_ctx_set_op_ctx(msg_ctx, env, op_ctx);
                        axis2_msg_ctx_set_op(msg_ctx, env, op);
                        axis2_op_register_op_ctx(op, env, msg_ctx, op_ctx);

                        svc_ctx = axis2_op_ctx_get_parent(op_ctx, env);
                        if(svc_ctx)
                        {
                            axis2_svc_t *svc = NULL;
                            axis2_svc_grp_ctx_t *svc_grp_ctx = NULL;
                            axis2_msg_ctx_set_svc_ctx(msg_ctx, env, svc_ctx);
                            svc = axis2_svc_ctx_get_svc(svc_ctx, env);
                            if(svc)
                            {
                                axis2_msg_ctx_set_svc(msg_ctx, env, svc);
                            }
                            svc_grp_ctx = axis2_svc_ctx_get_parent(svc_ctx, env);
                            if(svc_grp_ctx)
                            {
                                axutil_string_t *svc_grp_ctx_id_str = axutil_string_create(env,
                                    axis2_svc_grp_ctx_get_id(svc_grp_ctx, env));
                                axis2_msg_ctx_set_svc_grp_ctx_id(msg_ctx, env, svc_grp_ctx_id_str);
                                axutil_string_free(svc_grp_ctx_id_str, env);
                            }
                            return AXIS2_SUCCESS;
                        }
                    }
                }
            }
        }

    }

    axis2_msg_ctx_set_find_svc(msg_ctx, env, axis2_addr_disp_find_svc);
    axis2_msg_ctx_set_find_op(msg_ctx, env, axis2_addr_disp_find_op);

    return axis2_disp_find_svc_and_op(handler, env, msg_ctx);
}