Esempio n. 1
0
AXIS2_EXTERN void AXIS2_CALL
axis2_svc_client_fire_and_forget_with_op_qname(
    axis2_svc_client_t * svc_client,
    const axutil_env_t * env,
    const axutil_qname_t * op_qname,
    const axiom_node_t * payload)
{
    axis2_msg_ctx_t *msg_ctx = NULL;
    axis2_bool_t qname_free_flag = AXIS2_FALSE;

    AXIS2_PARAM_CHECK_VOID(env->error, svc_client);

    if(!op_qname)
    {
        op_qname = axutil_qname_create(env, AXIS2_ANON_OUT_ONLY_OP, NULL, NULL);
        if(!op_qname)
        {
            return;
        }
        qname_free_flag = AXIS2_TRUE;
    }

    svc_client->auth_failed = AXIS2_FALSE;
    svc_client->required_auth_is_http = AXIS2_FALSE;
    if(svc_client->auth_type)
    {
        AXIS2_FREE(env->allocator, svc_client->auth_type);
    }
    svc_client->auth_type = NULL;

    msg_ctx = axis2_msg_ctx_create(env, axis2_svc_ctx_get_conf_ctx(svc_client->svc_ctx, env), NULL,
        NULL);
    if(!axis2_svc_client_fill_soap_envelope(env, svc_client, msg_ctx, payload))
    {
        return;
    }

    if(!axis2_svc_client_create_op_client(svc_client, env, op_qname))
    {
        return;
    }

    axis2_op_client_add_out_msg_ctx(svc_client->op_client, env, msg_ctx);
    axis2_op_client_execute(svc_client->op_client, env, AXIS2_TRUE);
    axis2_svc_client_set_http_info(svc_client, env, msg_ctx);
    svc_client->auth_failed = axis2_msg_ctx_get_auth_failed(msg_ctx, env);
    svc_client->required_auth_is_http = axis2_msg_ctx_get_required_auth_is_http(msg_ctx, env);
    if(axis2_msg_ctx_get_auth_type(msg_ctx, env))
    {
        svc_client->auth_type = axutil_strdup(env, axis2_msg_ctx_get_auth_type(msg_ctx, env));
    }

    if(qname_free_flag)
    {
        axutil_qname_free((axutil_qname_t *)op_qname, env);
    }
}
Esempio n. 2
0
axiom_soap_envelope_t *
wsdl_util_send_receive_soap_envelope_with_op_client(
    const axutil_env_t* env,
    axis2_svc_client_t* svc_client,
    axis2_options_t* options,
    axis2_char_t* buffer)
{
    axiom_soap_envelope_t *res_envelope = NULL, *req_envelope = NULL;
    axis2_svc_ctx_t *svc_ctx = NULL;
    axis2_conf_ctx_t *conf_ctx = NULL;
    axis2_msg_ctx_t *req_msg_ctx = NULL, *res_msg_ctx = NULL;
    axutil_qname_t *op_qname = NULL;
    axis2_op_client_t *op_client = NULL;
    axis2_char_t *soap_version_uri = NULL;

    svc_ctx = axis2_svc_client_get_svc_ctx (svc_client, env);

    conf_ctx = axis2_svc_ctx_get_conf_ctx (svc_ctx, env);

    req_msg_ctx = axis2_msg_ctx_create (env, conf_ctx, NULL, NULL);

    op_qname = axutil_qname_create (env, AXIS2_ANON_OUT_IN_OP, NULL, NULL);

    op_client = axis2_svc_client_create_op_client (svc_client, env, op_qname);

    soap_version_uri = (axis2_char_t *) axis2_options_get_soap_version_uri (options, env);

    req_envelope = wsdl_util_create_soap_envelope_from_buffer (env, buffer, soap_version_uri);
    
    axis2_msg_ctx_set_soap_envelope (req_msg_ctx, env, req_envelope);
    
    axis2_op_client_add_msg_ctx (op_client, env, req_msg_ctx);
    
    axis2_op_client_execute (op_client, env, AXIS2_TRUE);
    
    res_msg_ctx =
       (axis2_msg_ctx_t *)axis2_op_client_get_msg_ctx (op_client, env, AXIS2_WSDL_MESSAGE_LABEL_IN);
    
    if (res_msg_ctx) 
    {        
        res_envelope = axis2_msg_ctx_get_soap_envelope (res_msg_ctx, env);
    } 
    else 
    {
        res_envelope = NULL;
    }
    
    return res_envelope;
}
Esempio n. 3
0
AXIS2_EXTERN void AXIS2_CALL
axis2_svc_client_send_receive_non_blocking_with_op_qname(
    axis2_svc_client_t * svc_client,
    const axutil_env_t * env,
    const axutil_qname_t * op_qname,
    const axiom_node_t * payload,
    axis2_callback_t * callback)
{
    axis2_msg_ctx_t *msg_ctx = NULL;
    AXIS2_TRANSPORT_ENUMS transport_in_protocol;
    axis2_bool_t qname_free_flag = AXIS2_FALSE;

    AXIS2_PARAM_CHECK_VOID(env->error, svc_client);

    if(!op_qname)
    {
        op_qname = axutil_qname_create(env, AXIS2_ANON_OUT_IN_OP, NULL, NULL);
        if(!op_qname)
            return;
        qname_free_flag = AXIS2_TRUE;
    }

    svc_client->auth_failed = AXIS2_FALSE;
    svc_client->required_auth_is_http = AXIS2_FALSE;
    if(svc_client->auth_type)
    {
        AXIS2_FREE(env->allocator, svc_client->auth_type);
    }
    svc_client->auth_type = NULL;

    msg_ctx = axis2_msg_ctx_create(env, axis2_svc_ctx_get_conf_ctx(svc_client-> svc_ctx, env),
        NULL, NULL);
    if(!msg_ctx)
        return;

    if(!axis2_svc_client_fill_soap_envelope(env, svc_client, msg_ctx, payload))
    {
        return;
    }

    if(!axis2_svc_client_create_op_client(svc_client, env, op_qname))
    {
        return;
    }

    axis2_op_client_set_callback(svc_client->op_client, env, callback);
    axis2_op_client_add_out_msg_ctx(svc_client->op_client, env, msg_ctx);

    /* If dual channel */
    if(axis2_options_get_use_separate_listener(svc_client->options, env))
    {
        axis2_op_t *op = NULL;

        transport_in_protocol = axis2_options_get_transport_in_protocol(svc_client->options, env);
        if(transport_in_protocol == AXIS2_TRANSPORT_ENUM_MAX)
        {
            axis2_options_set_transport_in_protocol(svc_client->options, env,
                AXIS2_TRANSPORT_ENUM_HTTP);
            transport_in_protocol = AXIS2_TRANSPORT_ENUM_HTTP;
        }
        axis2_listener_manager_make_sure_started(svc_client->listener_manager, env,
            transport_in_protocol, svc_client->conf_ctx);
        /* Following sleep is required to ensure the listener is ready to receive response.
         If it is missing, the response gets lost. - Samisa */
        AXIS2_USLEEP(1);

        op = axis2_svc_get_op_with_qname(svc_client->svc, env, op_qname);
        /* At the end of the incoming flow this message receiver will be hit */
        axis2_op_set_msg_recv(op, env,
            AXIS2_CALLBACK_RECV_GET_BASE(svc_client-> callback_recv, env));
        axis2_op_client_set_callback_recv(svc_client->op_client, env, svc_client->callback_recv);
    }

    axis2_op_client_execute(svc_client->op_client, env, AXIS2_FALSE);
    axis2_svc_client_set_http_info(svc_client, env, msg_ctx);
    svc_client->auth_failed = axis2_msg_ctx_get_auth_failed(msg_ctx, env);
    svc_client->required_auth_is_http = axis2_msg_ctx_get_required_auth_is_http(msg_ctx, env);
    if(axis2_msg_ctx_get_auth_type(msg_ctx, env))
    {
        svc_client->auth_type = axutil_strdup(env, axis2_msg_ctx_get_auth_type(msg_ctx, env));
    }

    if(qname_free_flag)
    {
        axutil_qname_free((axutil_qname_t *)op_qname, env);
        op_qname = NULL;
    }
}
Esempio n. 4
0
AXIS2_EXTERN axiom_node_t *AXIS2_CALL
axis2_svc_client_send_receive_with_op_qname(
    axis2_svc_client_t * svc_client,
    const axutil_env_t * env,
    const axutil_qname_t * op_qname,
    const axiom_node_t * payload)
{
    axiom_soap_envelope_t *soap_envelope = NULL;
    axiom_soap_body_t *soap_body = NULL;
    axiom_node_t *soap_node = NULL;
    axis2_op_t *op = NULL;
    axutil_param_t *param = NULL;
    axutil_uri_t *action_uri = NULL;
    axis2_char_t *action_str = NULL;
    axis2_bool_t qname_free_flag = AXIS2_FALSE;

    axis2_msg_ctx_t *res_msg_ctx = NULL;
    axis2_msg_ctx_t *msg_ctx = NULL;

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

    svc_client->last_response_soap_envelope = NULL;
    svc_client->last_response_has_fault = AXIS2_FALSE;
    svc_client->auth_failed = AXIS2_FALSE;
    svc_client->required_auth_is_http = AXIS2_FALSE;
    if(svc_client->auth_type)
    {
        AXIS2_FREE(env->allocator, svc_client->auth_type);
    }
    svc_client->auth_type = NULL;

    op = axis2_svc_get_op_with_qname(svc_client->svc, env, op_qname);
    if(op)
    {
        param = axis2_op_get_param(op, env, AXIS2_SOAP_ACTION);
        if(param)
        {
            action_uri = (axutil_uri_t *)axutil_param_get_value(param, env);
            action_str = axutil_uri_to_string(action_uri, env, AXIS2_URI_UNP_OMITUSERINFO);
            axis2_options_set_action(svc_client->options, env, action_str);
        }
    }

    if(!op_qname)
    {
        op_qname = axutil_qname_create(env, AXIS2_ANON_OUT_IN_OP, NULL, NULL);
        if(!op_qname)
            return NULL;

        qname_free_flag = AXIS2_TRUE;
    }

    /* If dual channel blocking. We come to this block if the client indicate to use
     * a separate listener but don't provide a callback function to acted upon when
     * response is received in the listener thread. What we do here is we create a callback
     * and call axis2_svc_client_send_receive_non_blocking_with_op_qname with it. */
    if(axis2_options_get_use_separate_listener(svc_client->options, env))
    {
        axis2_callback_t *callback = NULL;
        axis2_msg_ctx_t *msg_ctx = NULL;
        long index = 0;

        /* This means doing a Request-Response invocation using two channels.
         If the transport is a two way transport (e.g. http), only one channel is used
         (e.g. in http cases 202 OK is sent to say no response available).
         Axis2 gets blocked and return when the response is available. */

        callback = axis2_callback_create(env);
        if(!callback)
        {
            return NULL;
        }

        /* Call two channel non blocking invoke to do the work and wait on the callback. We don't 
         * set a callback function for the callback. That functionality is handled here. 
         */
        axis2_svc_client_send_receive_non_blocking_with_op_qname(svc_client, env, op_qname,
            payload, callback);

        index = axis2_options_get_timeout_in_milli_seconds(svc_client->options, env) / 10;

        while(!axis2_callback_get_complete(callback, env))
        {
            if(index-- >= 0)
            {
                AXIS2_USLEEP(10000);
            }
            else
            {
                AXIS2_ERROR_SET(env->error, AXIS2_ERROR_RESPONSE_TIMED_OUT, AXIS2_FAILURE);
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Response time out.");
                return NULL;
            }
        }

        soap_envelope = axis2_callback_get_envelope(callback, env);
        msg_ctx = axis2_callback_get_msg_ctx(callback, env);
        axis2_op_client_add_in_msg_ctx(svc_client->op_client, env, msg_ctx);

        /* start of hack to get rid of memory leak */
        /*msg_ctx = axis2_msg_ctx_create(env, axis2_svc_ctx_get_conf_ctx(svc_client-> svc_ctx, env),
            NULL, NULL);
        if(!msg_ctx)
            return NULL;

        axis2_op_client_add_in_msg_ctx(svc_client->op_client, env, msg_ctx);

        axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope);*/
        /* end of hack to get rid of memory leak */

        /* process the result of the invocation */
        if(!soap_envelope)
        {
            if(axis2_callback_get_error(callback, env) != AXIS2_ERROR_NONE)
            {
                AXIS2_ERROR_SET(env->error, axis2_callback_get_error(callback, env), AXIS2_FAILURE);
                return NULL;
            }
        }
    }
    else
    {
        msg_ctx = axis2_msg_ctx_create(env, axis2_svc_ctx_get_conf_ctx(svc_client->svc_ctx, env),
            NULL, NULL);
        if(!msg_ctx)
            return NULL;

        if(!axis2_svc_client_fill_soap_envelope(env, svc_client, msg_ctx, payload))
        {
            return NULL;
        }

        if(!axis2_svc_client_create_op_client(svc_client, env, op_qname))
        {
            return NULL;
        }

        axis2_op_client_add_msg_ctx(svc_client->op_client, env, msg_ctx);
        axis2_op_client_execute(svc_client->op_client, env, AXIS2_TRUE);
        axis2_svc_client_set_http_info(svc_client, env, msg_ctx);
        svc_client->auth_failed = axis2_msg_ctx_get_auth_failed(msg_ctx, env);
        svc_client->required_auth_is_http = axis2_msg_ctx_get_required_auth_is_http(msg_ctx, env);
        if(axis2_msg_ctx_get_auth_type(msg_ctx, env))
        {
            svc_client->auth_type = axutil_strdup(env, axis2_msg_ctx_get_auth_type(msg_ctx, env));
        }
        res_msg_ctx = (axis2_msg_ctx_t *)axis2_op_client_get_msg_ctx(svc_client-> op_client, env,
            AXIS2_WSDL_MESSAGE_LABEL_IN);

        if(res_msg_ctx)
        {
            soap_envelope = axis2_msg_ctx_get_soap_envelope(res_msg_ctx, env);
        }
        else
        {
            axis2_op_client_add_msg_ctx(svc_client->op_client, env, res_msg_ctx);
            /* set in msg_ctx to be NULL to reset */
        }
    }

    if(qname_free_flag)
    {
        axutil_qname_free((axutil_qname_t *)op_qname, env);
    }

    if(!soap_envelope)
    {
        return NULL;
    }
    svc_client->last_response_soap_envelope = soap_envelope;

    soap_body = axiom_soap_envelope_get_body(soap_envelope, env);

    if(!soap_body)
    {
        axiom_node_t *node = axiom_soap_envelope_get_base_node(soap_envelope, env);
        if(node)
        {
            axiom_element_t *envelope_element = (axiom_element_t *)axiom_node_get_data_element(
                node, env);
            axiom_util_get_first_child_element_with_localname(envelope_element, env, node,
                AXIOM_SOAP_BODY_LOCAL_NAME, &soap_node);
            if(soap_node)
            {
                return axiom_node_get_first_element(soap_node, env);
            }
        }
        return NULL;
    }

    if(axis2_msg_ctx_get_doing_rest(res_msg_ctx, env))
    {
        /* All HTTP 4xx and 5xx status codes are treated as errors */
        if(axis2_msg_ctx_get_status_code(res_msg_ctx, env) >= 400)
        {
            svc_client->last_response_has_fault = AXIS2_TRUE;
        }
        else
        {
            svc_client->last_response_has_fault = AXIS2_FALSE;
        }
    }
    else
    {
        svc_client->last_response_has_fault = axiom_soap_body_has_fault(soap_body, env);
    }

    if(AXIOM_SOAP11 == axiom_soap_envelope_get_soap_version(soap_envelope, env))
    {
        axiom_soap_body_convert_fault_to_soap11(soap_body, env);
    }

    soap_node = axiom_soap_body_get_base_node(soap_body, env);
    if(!soap_node)
    {
        return NULL;
    }
    return axiom_node_get_first_element(soap_node, env);
}
Esempio n. 5
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axis2_svc_client_send_robust_with_op_qname(
    axis2_svc_client_t * svc_client,
    const axutil_env_t * env,
    const axutil_qname_t * op_qname,
    const axiom_node_t * payload)
{
    axis2_msg_ctx_t *msg_ctx = NULL;
    axis2_status_t status = AXIS2_FAILURE;
    axis2_bool_t qname_free_flag = AXIS2_FALSE;

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

    if(!op_qname)
    {
        op_qname = axutil_qname_create(env, AXIS2_ANON_ROBUST_OUT_ONLY_OP, NULL, NULL);
        if(!op_qname)
        {
            return AXIS2_FAILURE;
        }
        qname_free_flag = AXIS2_TRUE;
    }
    else
    {
        axis2_op_t *op = NULL;
        axis2_char_t *mep = NULL;
        axis2_svc_t *svc = NULL;
        svc = axis2_svc_client_get_svc(svc_client, env);
        if(!svc)
        {
            return AXIS2_FAILURE;
        }
        op = axis2_svc_get_op_with_qname(svc, env, op_qname);
        if(!op)
        {
            return AXIS2_FAILURE;
        }
        mep = (axis2_char_t *)axis2_op_get_msg_exchange_pattern(op, env);
        if(!mep || axutil_strcmp(AXIS2_MEP_URI_OUT_ONLY, mep) != 0)
        {
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "%s%s",
                "To use this method opeation uri should be", AXIS2_MEP_URI_OUT_ONLY);
            return AXIS2_FAILURE;
        }
    }

    svc_client->auth_failed = AXIS2_FALSE;
    svc_client->required_auth_is_http = AXIS2_FALSE;
    if(svc_client->auth_type)
    {
        AXIS2_FREE(env->allocator, svc_client->auth_type);
    }
    svc_client->auth_type = NULL;

    msg_ctx = axis2_msg_ctx_create(env, axis2_svc_ctx_get_conf_ctx(svc_client->svc_ctx, env), NULL,
        NULL);
    if(!axis2_svc_client_fill_soap_envelope(env, svc_client, msg_ctx, payload))
    {
        return AXIS2_FAILURE;
    }

    if(!axis2_svc_client_create_op_client(svc_client, env, op_qname))
    {
        return AXIS2_FAILURE;
    }

    axis2_op_client_add_out_msg_ctx(svc_client->op_client, env, msg_ctx);
    status = axis2_op_client_execute(svc_client->op_client, env, AXIS2_TRUE);
    axis2_svc_client_set_http_info(svc_client, env, msg_ctx);
    svc_client->auth_failed = axis2_msg_ctx_get_auth_failed(msg_ctx, env);
    svc_client->required_auth_is_http = axis2_msg_ctx_get_required_auth_is_http(msg_ctx, env);
    if(axis2_msg_ctx_get_auth_type(msg_ctx, env))
    {
        svc_client->auth_type = axutil_strdup(env, axis2_msg_ctx_get_auth_type(msg_ctx, env));
    }

    if(qname_free_flag)
    {
        axutil_qname_free((axutil_qname_t *)op_qname, env);
    }

    return status;
}