Пример #1
0
axutil_env_t *test_init()
{
    axutil_allocator_t *allocator = axutil_allocator_init(NULL);
    axutil_error_t *error = (axutil_error_t*)axis2_error_create(allocator);
    axutil_env_t *env = axutil_env_create_with_error(allocator, error);
    return env;
}
Пример #2
0
void
axis2_test_svc_client_blocking(
    )
{
    axutil_env_t *env = NULL;
    axis2_options_t *options = NULL;
    const axis2_char_t *client_home = NULL;
    axis2_svc_client_t *svc_client = NULL;
    axiom_node_t *payload = NULL;
    axiom_node_t *ret_node = NULL;
    const axis2_char_t *address = NULL;
    axis2_endpoint_ref_t *endpoint_ref = NULL;

    axutil_allocator_t *allocator = axutil_allocator_init(NULL);
    axiom_element_t *result_ele = NULL;
    const axis2_char_t *echo_text = "echo_text";
    axis2_char_t *result = NULL;

    env = axutil_env_create(allocator);
    address = "http://localhost:9090/axis2/services/echo/echo";
    endpoint_ref = axis2_endpoint_ref_create(env, address);
    client_home = AXIS2_GETENV("AXIS2C_HOME");
    if (!client_home)
        client_home = "../../deploy";

    svc_client = axis2_svc_client_create(env, client_home);

    if (!svc_client)
    {
        printf("axis2_test axis2_svc_client_create FAILURE\n");
        printf
            ("Client repository path not properly set. Please check AXIS2C_HOME setting\n");
        return;
    }

    options = axis2_options_create(env);
    axis2_options_set_to(options, env, endpoint_ref);
    axis2_svc_client_set_options(svc_client, env, options);

    payload = build_om_payload_for_echo_svc(env, echo_text);
    ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
    if (ret_node)
    {
        if (axiom_node_get_node_type(ret_node, env) == AXIOM_ELEMENT)
        {
            ret_node = axiom_node_get_first_child(ret_node, env);
            result_ele =
                (axiom_element_t *) axiom_node_get_data_element(ret_node, env);
            result = axiom_element_get_text(result_ele, env, ret_node);
            if (!strcmp(result, echo_text))
                printf("axis2_test SVC_CLIENT_SEND_RECEIVE SUCCESS\n");
            else
                printf("axis2_test SVC_CLIENT_SEND_RECEIVE FAILURE\n");
        }
    }

    axis2_svc_client_free(svc_client, env);
}
Пример #3
0
int
main(
    int argc,
    char **argv)
{
    axis2_status_t status = AXIS2_FAILURE;
    int i = 0;
    axutil_array_list_t *policy_list = NULL;
    axutil_array_list_t *policy_node_list = NULL;
    neethi_policy_t *resultant = NULL;
    axutil_allocator_t *allocator = axutil_allocator_init(NULL);
    axutil_error_t *error = axutil_error_create(allocator);
    const axutil_env_t *env = axutil_env_create_with_error(allocator, error);

    policy_list = axutil_array_list_create(env, 0);
    policy_node_list = axutil_array_list_create(env, 0);

    get_all_policy(argv[1], env, policy_node_list, argv[2]);

    for (i = 0; i < axutil_array_list_size(policy_node_list, env); i++)
    {
        axiom_node_t *node = NULL;
        node = (axiom_node_t *) axutil_array_list_get(policy_node_list, env, i);
        status = load_policy_array(policy_list, node, env);
    }

    resultant = merge_policylist(policy_list, env);
    if (!resultant)
    {
        printf("Error Merging\n");
        return 0;
    }
    else
    {
        axiom_node_t *s_node = NULL;
        axis2_char_t *buff = NULL;
        s_node = neethi_engine_serialize(resultant, env);
        if (!s_node)
        {
            printf("Serializing failed\n");
            return 0;
        }
        buff = axiom_node_to_string(s_node, env);
        printf("\n%s", buff);
    }
    printf("Successful\n");
    return 0;

}
Пример #4
0
AXIS2_EXTERN axutil_env_t *AXIS2_CALL
axutil_env_create_all(
    const axis2_char_t *log_file,
    const axutil_log_levels_t log_level)
{
    axutil_env_t *env = NULL;
    axutil_error_t *error = NULL;
    axutil_log_t *log = NULL;
    axutil_allocator_t *allocator = NULL;
    axutil_thread_pool_t *thread_pool = NULL;

    allocator = axutil_allocator_init(NULL);
    error = axutil_error_create(allocator);

    if(log_file)
    {
        log = axutil_log_create(allocator, NULL, log_file);
    }

    /* if log file name was not given or the log could not be create with 
     given name, create default log */
    if(!log)
    {
        log = axutil_log_create_default(allocator);
    }

    thread_pool = axutil_thread_pool_init(allocator);

    env = axutil_env_create_with_error_log_thread_pool(allocator, error, log, thread_pool);
    if(env->log)
    {
        /*if(AXIS2_LOG_LEVEL_CRITICAL <= log_level && log_level <= AXIS2_LOG_LEVEL_TRACE)*/
	if (log_level <= AXIS2_LOG_LEVEL_TRACE)
        {
            env->log->level = log_level;
        }
        else
        {
            env->log->level = AXIS2_LOG_LEVEL_DEBUG; /* default log level is debug */
        }
    }

    env->ref = 1;
    env->get_session_fn = NULL;
    env->set_session_fn = NULL;

    return env;
}
Пример #5
0
void
test_log_write(
    )
{
    char msg[20];
    printf("start of test_log_write\n\n");
    axutil_allocator_t *allocator = axutil_allocator_init(NULL);
    if (!allocator)
    {
        printf("allocator is NULL\n");
        return;
    }
    axutil_error_t *error = axutil_error_create(allocator);
    if (!error)
    {
        printf("cannot create error\n");
        return;
    }
    axutil_log_t *log22 = axutil_log_create(allocator, NULL, NULL);
    if (!log22)
    {
        printf("cannot create log\n");
        return;
    }
    log22->level = AXIS2_LOG_LEVEL_DEBUG;

    const axutil_env_t *env =
        axutil_env_create_with_error_log(allocator, error, log22);
    if (!env)
    {
        printf("cannot create env with error and log\n");
        return;
    }
    strcpy(msg, "abcd test123");

    AXIS2_LOG_CRITICAL(env->log, AXIS2_LOG_SI, "log1 %s", "test1");
    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "log2 %d", 2);
    AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI, "log3 %s", "test3");
    AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, "log4 %s %s", "info1", "info2");
    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "log5 %s %d", "test", 5);
    printf("end of test_log_write \n\n");

}
Пример #6
0
void
test_axutil_dir_handler_list_service_or_module_dirs(
    )
{
    int i,
     isize;
    axutil_file_t *file = NULL;
    axis2_char_t *filename = NULL;
    axutil_allocator_t *allocator = axutil_allocator_init(NULL);
    axutil_error_t *error = axutil_error_create(allocator);
    axutil_log_t *log = axutil_log_create(allocator, NULL, NULL);
    const axutil_env_t *env =
        axutil_env_create_with_error_log(allocator, error, log);

    axis2_char_t *pathname = axutil_strdup(env, "/tmp/test/");

    axutil_array_list_t *arr_folders =
        axutil_dir_handler_list_service_or_module_dirs(env, pathname);
    if (arr_folders == NULL)
    {
        printf("List of folders is NULL\n");
        return;
    }

    isize = axutil_array_list_size(arr_folders, env);
    printf("Folder array size = %d \n", isize);

    for (i = 0; i < isize; ++i)
    {
        file = (axutil_file_t *) axutil_array_list_get(arr_folders, env, i);
        filename = axutil_file_get_name(file, env);
        printf("filename = %s \n", filename);
    }
    printf
        ("----end of test_axutil_dir_handler_list_service_or_module_dirs----\n");

}
Пример #7
0
int
main(
    int argc,
    char *argv[])
{
    axutil_allocator_t *allocator = NULL;
    axutil_env_t *env = NULL;
    extern char *optarg;
    extern int optopt;
    int c;
    int log_file_size = AXUTIL_LOG_FILE_SIZE;
    axutil_log_levels_t log_level = AXIS2_LOG_LEVEL_DEBUG;
    const axis2_char_t *log_file = AXIS2_TCP_SERVER_LOG_FILE_NAME;
    int port = AXIS2_TCP_SERVER_PORT;
    const axis2_char_t *repo_path = AXIS2_TCP_SERVER_REPO_PATH;

    while((c = AXIS2_GETOPT(argc, argv, ":p:r:ht:l:s:f:")) != -1)
    {

        switch(c)
        {
            case 'p':
                port = AXIS2_ATOI(optarg);
                break;
            case 'r':
                repo_path = optarg;
                break;
            case 't':
                axis2_tcp_socket_read_timeout = AXIS2_ATOI(optarg) * 1000;
                break;
            case 'l':
                log_level = AXIS2_ATOI(optarg);
                if(log_level < AXIS2_LOG_LEVEL_CRITICAL)
                    log_level = AXIS2_LOG_LEVEL_CRITICAL;
                if(log_level > AXIS2_LOG_LEVEL_TRACE)
                    log_level = AXIS2_LOG_LEVEL_TRACE;
                break;
            case 's':
                log_file_size = 1024 * 1024 * AXIS2_ATOI(optarg);
                break;
            case 'f':
                log_file = optarg;
                break;
            case 'h':
                usage(argv[0]);
                return 0;
            case ':':
                fprintf(stderr, "\nOption -%c requires an operand\n", optopt);
                usage(argv[0]);
                return -1;
            case '?':
                if(isprint(optopt))
                    fprintf(stderr, "\nUnknown option `-%c'.\n", optopt);
                usage(argv[0]);
                return -1;
        }
    }

    allocator = axutil_allocator_init(NULL);
    if(!allocator)
    {
        system_exit(NULL, -1);
    }
    env = init_syetem_env(allocator, log_file);
    env->log->level = log_level;
    env->log->size = log_file_size;
    axutil_error_init();
    system_env = env;

#ifndef WIN32
    signal(SIGINT, sig_handler);
    signal(SIGPIPE, sig_handler);
#endif

    AXIS2_LOG_INFO(env->log, "Starting Axis2 TCP server....");
    AXIS2_LOG_INFO(env->log, "Server port : %d", port);
    AXIS2_LOG_INFO(env->log, "Repo location : %s", repo_path);
    AXIS2_LOG_INFO(env->log, "Read Timeout : %d ms", axis2_tcp_socket_read_timeout);

    server = axis2_tcp_server_create(env, repo_path, port);
    if(!server)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Server creation failed: Error code:" " %d :: %s",
            env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error));
        system_exit(env, -1);

    }
    printf("Started Simple Axis2 TCP Server ...\n");
    if(axis2_transport_receiver_start(server, env) == AXIS2_FAILURE)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Server start failed: Error code:" " %d :: %s",
            env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error));
        system_exit(env, -1);
    }
    return 0;
}
Пример #8
0
int
main(
    int argc,
    char *argv[])
{
    int c;
    axutil_allocator_t *allocator;
    guththila_reader_t *red;
    axutil_env_t *environment;
    guththila_t *parser;
    char *xml_buffer;
    allocator = axutil_allocator_init(NULL);
    xml_buffer
        = "<?xml version = \"1.0\"?><test a=\"din\">addddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd123</test>";
    environment = axutil_env_create(allocator);

    if(argc > 1)
        red = guththila_reader_create_for_file(environment, argv[1]);
    else
    {
        if(xml_buffer)
        {
            int size = 0;
            size = strlen(xml_buffer);
            red = guththila_reader_create_for_memory(environment, (void *)xml_buffer, size, NULL);
        }
    }

    parser = guththila_create(environment, red);
    guththila_read(environment, parser);

    while((c = guththila_next(environment, parser)) != -1)
    {
        switch(c)
        {
            case GUTHTHILA_START_DOCUMENT:
            {
                int ix;
                printf("<?xml ");

                ix = guththila_get_attribute_count(environment, parser);
                for(; ix > 0; ix--)
                {
                    guththila_attribute_t *a;
                    char *p;
                    a = guththila_get_attribute(environment, parser);
                    p = guththila_get_attribute_name(environment, parser, a);
                    printf("%s=\"", p);
                    AXIS2_FREE(allocator, p);
                    p = guththila_get_attribute_value(environment, parser, a);
                    printf("%s\" ", p);
                    AXIS2_FREE(allocator, p);
                    guththila_attribute_free(environment, a);
                }
                printf("?>\n");
            }
                break;
            case GUTHTHILA_START_ELEMENT:
            case GUTHTHILA_EMPTY_ELEMENT:
            {
                int ia;
                int d;
                char *p;
                guththila_depth_t *depth;

                printf("<");
                p = guththila_get_prefix(environment, parser);
                if(p)
                {
                    printf("%s:", p);
                    AXIS2_FREE(allocator, p);
                }
                p = guththila_get_name(environment, parser);
                printf("%s", p);
                AXIS2_FREE(allocator, p);

                ia = guththila_get_attribute_count(environment, parser);
                for(; ia > 0; ia--)
                {
                    /* p = guththila_get_attribute_prefix_by_number
                     (parser, ia); */
                    p = guththila_get_attribute_prefix_by_number(environment, parser, ia);
                    if(p)
                    {
                        printf(" %s:", p);
                        AXIS2_FREE(allocator, p);
                        p = guththila_get_attribute_name_by_number(environment, parser, ia);
                        printf("%s=\"", p);
                        AXIS2_FREE(allocator, p);
                        p = guththila_get_attribute_value_by_number(environment, parser, ia);
                        printf("%s\"", p);
                        AXIS2_FREE(allocator, p);
                    }
                    else
                    {
                        p = guththila_get_attribute_name_by_number(environment, parser, ia);
                        printf(" %s=\"", p);
                        AXIS2_FREE(allocator, p);
                        p = guththila_get_attribute_value_by_number(environment, parser, ia);
                        printf("%s\"", p);
                        AXIS2_FREE(allocator, p);
                    }
                }
                depth = (guththila_depth_t *)axutil_stack_get(parser->dep, environment);
                d = depth->count;
                for(; d > 0; d--)
                {
                    p = guththila_get_namespace_prefix_by_number(environment, parser, d);
                    if(strncmp(p, "xmlns", 5))
                    {
                        printf(" xmlns:");
                        printf("%s=\"", p);
                    }
                    else
                        printf(" xmlns=\"");
                    AXIS2_FREE(allocator, p);
                    p = guththila_get_namespace_uri_by_number(environment, parser, d);
                    printf("%s\"", p);
                    AXIS2_FREE(allocator, p);
                }
                if(parser->guththila_event == GUTHTHILA_START_ELEMENT)
                    printf(">");
                else if(parser->guththila_event == GUTHTHILA_EMPTY_ELEMENT)
                    printf("/>");
                else
                    printf("error \n");

            }
                break;
            case GUTHTHILA_END_ELEMENT:
            {
                char *p;
                printf("</");
                p = guththila_get_prefix(environment, parser);
                if(p)
                {
                    printf("%s:", p);
                    AXIS2_FREE(allocator, p);
                }
                p = guththila_get_name(environment, parser);
                printf("%s", p);
                AXIS2_FREE(allocator, p);
                printf(">");
            }
                break;
            case GUTHTHILA_CHARACTER:
            {
                char *p = NULL;
                p = guththila_get_value(environment, parser);
                /*    if (!parser->is_whitespace) */
                /*                 { */
                /*                     printf(p); */
                /*                 } */
                printf("%s", p);
                AXIS2_FREE(allocator, p);
            }
                break;
            case GUTHTHILA_COMMENT:
                break;
        };
    }
    guththila_reader_free(environment, red);
    guththila_free(environment, parser);
    axutil_env_free(environment);
    return 0;
}
Пример #9
0
int
axis2_test_msg_info_headers(
    )
{
    axis2_endpoint_ref_t *to = NULL;
    axis2_endpoint_ref_t *from = NULL;
    axis2_endpoint_ref_t *reply_to = NULL;
    axis2_endpoint_ref_t *fault_to = NULL;
    axis2_endpoint_ref_t *axis2_endpoint_ref = NULL;
    axis2_status_t status = AXIS2_FAILURE;
    axis2_msg_info_headers_t *axis2_msg_info_headers = NULL;
    axutil_allocator_t *allocator = axutil_allocator_init(NULL);
    const axutil_env_t *env = axutil_env_create(allocator);
    const axis2_char_t *action = "test action";
    const axis2_char_t *get_action = NULL;
    to = axis2_endpoint_ref_create(env, "to");
    from = axis2_endpoint_ref_create(env, "from");
    reply_to = axis2_endpoint_ref_create(env, "reply to");
    fault_to = axis2_endpoint_ref_create(env, "fault to");

    axis2_msg_info_headers = axis2_msg_info_headers_create(env, NULL, action);
    if (axis2_msg_info_headers)
        printf("SUCCESS axis2_msg_info_headers_create\n");
    else
    {
        printf("ERROR AXIS2_MSG_INFO_HEADERS_CREATE\n");
        return -1;
    }

    status = axis2_msg_info_headers_set_to(axis2_msg_info_headers, env, to);

    if (status == AXIS2_SUCCESS)
        printf("SUCCESS axis2_msg_info_headers_set_to\n");
    else
    {
        printf("ERROR axis2_msg_info_headers_set_to");
        return -1;
    }

    axis2_endpoint_ref =
        axis2_msg_info_headers_get_to(axis2_msg_info_headers, env);

    if (axis2_endpoint_ref)
        printf("SUCCESS axis2_msg_info_headers_get_to\n");
    else
    {
        printf("ERROR axis2_msg_info_headers_get_to\n");
        return -1;
    }

    status = AXIS2_FAILURE;
    status = axis2_msg_info_headers_set_from(axis2_msg_info_headers, env, from);

    if (status)
        printf("SUCCESS axis2_msg_info_headers_set_from\n");
    else
    {
        printf("ERROR axis2_msg_info_headers_set_from\n");
        return -1;
    }

    axis2_endpoint_ref = NULL;
    axis2_endpoint_ref =
        axis2_msg_info_headers_get_from(axis2_msg_info_headers, env);

    if (axis2_endpoint_ref)
        printf("SUCCESS axis2_msg_info_headers_get_from\n");
    else
    {
        printf("ERROR axis2_msg_info_headers_get_from\n");
        return -1;
    }

    axis2_endpoint_ref = NULL;
    axis2_endpoint_ref =
        axis2_msg_info_headers_get_reply_to(axis2_msg_info_headers, env);

    if (status)
        printf("SUCCESS axis2_msg_info_headers_get_reply_to\n");
    else
    {
        printf("ERROR axis2_msg_info_headers_get_reply_to\n");
        return -1;
    }

    status = AXIS2_FAILURE;
    status =
        axis2_msg_info_headers_set_reply_to(axis2_msg_info_headers, env,
                                            reply_to);

    if (status)
        printf("SUCCESS axis2_msg_info_headers_set_reply_to\n");
    else
    {
        printf("ERROR axis2_msg_info_headers_set_reply_to\n");
        return -1;
    }

    status = AXIS2_FAILURE;
    status =
        axis2_msg_info_headers_set_fault_to(axis2_msg_info_headers, env,
                                            fault_to);
    if (status)
        printf("SUCCESS axis2_msg_info_headers_set_fault_to\n");
    else
    {
        printf("ERROR axis2_msg_info_headers_set_fault_to\n");
        return -1;
    }

    axis2_endpoint_ref = NULL;
    axis2_endpoint_ref =
        axis2_msg_info_headers_get_fault_to(axis2_msg_info_headers, env);
    if (axis2_endpoint_ref)
        printf("SUCCESS axis2_msg_info_headers_get_fault_to\n");
    else
    {
        printf("ERROR axis2_msg_info_headers_get_fault_to\n");
        return -1;
    }

    get_action = axis2_msg_info_headers_get_action(axis2_msg_info_headers, env);
    if (get_action)
        printf("SUCCESS axis2_msg_info_headers_get_action\n");
    else
    {
        printf("ERROR axis2_msg_info_headers_get_action\n");
        return -1;
    }

    status = AXIS2_FAILURE;
    status =
        axis2_msg_info_headers_set_action(axis2_msg_info_headers, env, action);
    if (status)
        printf("SUCCESS axis2_msg_info_headers_set_action\n");
    else
    {
        printf("ERROR axis2_msg_info_headers_set_action\n");
    }

    status = AXIS2_FAILURE;
    /* status = axis2_msg_info_headers_free(axis2_msg_info_headers, env); */
    if (status)
        printf("SUCCESS axis2_msg_info_headers_free\n");
    else
    {
        printf("ERROR axis2_msg_info_headers_free\n");
    }
    return 0;
}