Exemple #1
0
AXIS2_EXTERN axis2_bool_t AXIS2_CALL
axis2_svc_is_param_locked(
    axis2_svc_t * svc,
    const axutil_env_t * env,
    const axis2_char_t * param_name)
{
    axis2_bool_t locked = AXIS2_FALSE;
    axutil_param_t *param = NULL;
    axis2_svc_grp_t *parent = NULL;
    axis2_bool_t ret = AXIS2_FALSE;

    AXIS2_PARAM_CHECK(env->error, param_name, AXIS2_FALSE);

    /* Checking the locked value of parent */

    parent = axis2_svc_get_parent(svc, env);
    if(parent)
        locked = axis2_svc_grp_is_param_locked(parent, env, param_name);
    if(parent && locked)
    {
        return AXIS2_TRUE;
    }
    param = axis2_svc_get_param(svc, env, param_name);
    if(param)
    {
        ret = axutil_param_is_locked(param, env);
    }
    return ret;
}
Exemple #2
0
AXIS2_EXTERN axis2_svc_grp_ctx_t *AXIS2_CALL
axis2_conf_ctx_fill_ctxs(
    axis2_conf_ctx_t * conf_ctx,
    const axutil_env_t * env,
    axis2_msg_ctx_t * msg_ctx)
{
    axis2_char_t *svc_grp_ctx_id = NULL;
    axis2_svc_grp_ctx_t *svc_grp_ctx = NULL;
    axis2_svc_ctx_t *svc_ctx = NULL;
    axis2_svc_t *svc = NULL;
    axis2_svc_grp_t *svc_grp = NULL;
    const axutil_qname_t *qname = NULL;
    axis2_char_t *svc_id = NULL;
    axis2_op_ctx_t *op_ctx = NULL;

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

    svc = axis2_msg_ctx_get_svc(msg_ctx, env);
    if(!svc)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_SERVICE_NOT_YET_FOUND, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
            "Service not yet found in message context. Cannot proceed");

        return NULL;
    }

    qname = axis2_svc_get_qname(svc, env);
    if(!qname)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service found in message context has no name.");
        return NULL;
    }

    svc_id = axutil_qname_get_localpart(qname, env);
    if(!svc_id)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Service found in message context has no name.");
        return NULL;
    }

    svc_grp = axis2_svc_get_parent(svc, env);
    if(svc_grp)
    {
        svc_grp_ctx_id = (axis2_char_t *)axis2_svc_grp_get_name(svc_grp, env);
    }

    if(!svc_grp_ctx_id)
    {
        svc_grp_ctx_id = (axis2_char_t *)axutil_string_get_buffer(axis2_msg_ctx_get_svc_grp_ctx_id(
            msg_ctx, env), env);
    }

    /* By this time service group context id must have a value, either from transport or from 
     * addressing 
     */
    if(svc_grp_ctx_id)
    {
        svc_grp_ctx = (axis2_svc_grp_ctx_t *)axutil_hash_get(conf_ctx->svc_grp_ctx_map,
            svc_grp_ctx_id, AXIS2_HASH_KEY_STRING);

        if(svc_grp_ctx)
        {
            svc_ctx = axis2_svc_grp_ctx_get_svc_ctx(svc_grp_ctx, env, svc_id);
            if(!svc_ctx)
            {
                AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC_GRP, AXIS2_FAILURE);
                AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                    "Service group context has no servie context set for service %s", svc_id);

                return NULL;
            }
        }
    }

    if(!svc_grp_ctx_id)
    {
        svc_grp_ctx_id = axutil_uuid_gen(env);
        if(svc_grp_ctx_id)
        {
            axutil_string_t *svc_grp_ctx_id_str = axutil_string_create_assume_ownership(env,
                &svc_grp_ctx_id);

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

    if(!svc_grp_ctx)
    {
        axis2_svc_grp_t *svc_group;
        svc_group = axis2_svc_get_parent(svc, env);
        svc_grp_ctx = axis2_svc_grp_get_svc_grp_ctx(svc_group, env, conf_ctx);
        svc_ctx = axis2_svc_grp_ctx_get_svc_ctx(svc_grp_ctx, env, svc_id);
        if(!svc_ctx)
        {
            AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC_GRP, AXIS2_FAILURE);
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
                "Service group context has no servie context set for service %s", svc_id);

            return NULL;
        }

        axis2_svc_grp_ctx_set_id(svc_grp_ctx, env, svc_grp_ctx_id);
        axis2_conf_ctx_register_svc_grp_ctx(conf_ctx, env, svc_grp_ctx_id, svc_grp_ctx);
    }

    /* When you come here operation context MUST have already been assigned
     to the message context */
    op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
    if(!op_ctx)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_MSG_CTX, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Operation context not set for message context");
        return NULL;
    }

    axis2_op_ctx_set_parent(op_ctx, env, svc_ctx);
    axis2_msg_ctx_set_svc_ctx(msg_ctx, env, svc_ctx);
    axis2_msg_ctx_set_svc_grp_ctx(msg_ctx, env, svc_grp_ctx);
    return svc_grp_ctx;
}
AXIS2_EXTERN axis2_svc_client_t *AXIS2_CALL
axis2_svc_client_create_with_conf_ctx_and_svc(
    const axutil_env_t * env,
    const axis2_char_t * client_home,
    axis2_conf_ctx_t * conf_ctx,
    axis2_svc_t * svc)
{
    axis2_svc_client_t *svc_client = NULL;
    axis2_svc_grp_t *svc_grp = NULL;
    axis2_svc_grp_ctx_t *svc_grp_ctx = NULL;
    const axis2_char_t *svc_grp_name = NULL;

    svc_client = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_client_t));
    if(!svc_client)
    {
        AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "No memory. Cannot create service client.");
        return NULL;
    }

    svc_client->svc = NULL;
    svc_client->conf = NULL;
    svc_client->conf_ctx = NULL;
    svc_client->svc_ctx = NULL;
    svc_client->options = NULL;
    svc_client->override_options = NULL;
    svc_client->headers = NULL;
    svc_client->callback_recv = NULL;
    svc_client->listener_manager = NULL;
    svc_client->op_client = NULL;
    svc_client->last_response_soap_envelope = NULL;
    svc_client->last_response_has_fault = AXIS2_FALSE;
    svc_client->reuse = AXIS2_FALSE;
    svc_client->auth_failed = AXIS2_FALSE;
    svc_client->required_auth_is_http = AXIS2_FALSE;
    svc_client->auth_type = NULL;
    svc_client->http_headers = NULL;
    svc_client->keep_externally_passed_ctx_and_svc = AXIS2_FALSE;

    if(!axis2_svc_client_init_data(env, svc_client))
    {
        axis2_svc_client_free(svc_client, env);
        return NULL;
    }

    /*create the default conf_ctx if it is NULL */
    if(!axis2_svc_client_init_transports_from_conf_ctx(env, svc_client, conf_ctx, client_home))
    {
        axis2_svc_client_free(svc_client, env);
        return NULL;
    }

    svc_client->conf = axis2_conf_ctx_get_conf(svc_client->conf_ctx, env);

    if(svc)
    {
        svc_client->keep_externally_passed_ctx_and_svc = AXIS2_TRUE;
        svc_client->svc = svc;
    }
    else
    {
        svc_client->svc = axis2_svc_client_create_annonymous_svc(svc_client, env);
        if(!svc_client->svc)
        {
            axis2_svc_client_free(svc_client, env);
            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot create annonymous service.");
            return NULL;
        }
    }

    /** add the service to the config context if it isn't in there already */
    if(!axis2_conf_get_svc(svc_client->conf, env, axis2_svc_get_name(svc_client->svc, env)))
    {
        axis2_conf_add_svc(svc_client->conf, env, svc_client->svc);
    }

    /** create a service context for myself: create a new service group
     context and then get the service context for myself as I'll need that
     later for stuff that I gotta do */
    svc_grp = axis2_svc_get_parent(svc_client->svc, env);
    if(!svc_grp)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Cannot access service group of service client.");
        return NULL;
    }

    svc_grp_ctx = axis2_svc_grp_get_svc_grp_ctx(svc_grp, env, svc_client->conf_ctx);
    if(!svc_grp_ctx)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
            "Cannot access service group context of service client.");
        return NULL;
    }

    svc_grp_name = axis2_svc_grp_get_name(svc_grp, env);
    if(!svc_grp_name)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
            "Cannot access service group name of service client.");
        return NULL; /* service group name is mandatory */
    }

    axis2_conf_ctx_register_svc_grp_ctx(svc_client->conf_ctx, env, svc_grp_name, svc_grp_ctx);

    svc_client->svc_ctx = axis2_svc_grp_ctx_get_svc_ctx(svc_grp_ctx, env, axis2_svc_get_name(
        svc_client->svc, env));

    return svc_client;
}