Пример #1
0
AXIS2_EXTERN axutil_env_t *AXIS2_CALL
axutil_env_create_with_error(
    axutil_allocator_t *allocator,
    axutil_error_t *error)
{
    return axutil_env_create_with_error_log(allocator, error, NULL);
}
static int
ngx_squ_xml_parse(squ_State *l)
{
    char                  *name;
    ngx_str_t              xml;
    axiom_node_t          *node;
    axutil_env_t          *env;
    axutil_log_t          *log;
    axutil_error_t        *error;
    axiom_element_t       *elem;
    axiom_document_t      *doc;
    ngx_squ_thread_t      *thr;
    axutil_allocator_t    *a;
    axiom_xml_reader_t    *reader;
    axiom_stax_builder_t  *builder;

    thr = ngx_squ_thread(l);

    ngx_log_debug0(NGX_LOG_DEBUG_CORE, thr->log, 0, "squ xml parse");

    xml.data = (u_char *) squL_checklstring(l, -1, &xml.len);

    squ_createtable(l, 2, 2);

    a = ngx_squ_axis2c_allocator_create(thr);
    log = ngx_squ_axis2c_log_create(thr);
    error = axutil_error_create(a);
    env = axutil_env_create_with_error_log(a, error, log);

    reader = axiom_xml_reader_create_for_memory(env, xml.data, xml.len, NULL,
                                                AXIS2_XML_PARSER_TYPE_BUFFER);
    builder = axiom_stax_builder_create(env, reader);
    doc = axiom_stax_builder_get_document(builder, env);

    node = axiom_document_get_root_element(doc, env);

    if (axiom_node_get_node_type(node, env) != AXIOM_ELEMENT) {
        return 1;
    }

    elem = axiom_node_get_data_element(node, env);
    name = axiom_element_get_localname(elem, env);

    squ_newtable(l);

    ngx_squ_xml_parse_children(l, env, node, elem);

    squ_setfield(l, -2, name);

    return 1;
}
Пример #3
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");

}
Пример #4
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");

}
static int
ngx_squ_xml_serialize(squ_State *l)
{
    int                     top;
    char                   *uri, *prefix;
    axiom_node_t           *node;
    axutil_env_t           *env;
    axutil_log_t           *log;
    axutil_error_t         *error;
    axiom_output_t         *output;
    ngx_squ_thread_t       *thr;
    axiom_namespace_t      *ns;
    axiom_soap_body_t      *body;
    axutil_allocator_t     *a;
    axiom_xml_writer_t     *writer;
    axiom_soap_header_t    *header;
    axiom_soap_envelope_t  *envelope;

    thr = ngx_squ_thread(l);

    ngx_log_debug0(NGX_LOG_DEBUG_CORE, thr->log, 0, "squ xml serialize");

    top = squ_gettop(l);

    if (!squ_istable(l, top)) {
        return squL_error(l, "invalid argument, must be a table");
    }

    a = ngx_squ_axis2c_allocator_create(thr);
    log = ngx_squ_axis2c_log_create(thr);
    error = axutil_error_create(a);
    env = axutil_env_create_with_error_log(a, error, log);

    squ_getfield(l, top, "uri");
    uri = (char *) squL_optstring(l, -1,
                                  "http://www.w3.org/2003/05/soap-envelope");

    squ_getfield(l, top, "prefix");
    prefix = (char *) squL_optstring(l, -1, "soap");

    ns = axiom_namespace_create(env, uri, prefix);
    envelope = axiom_soap_envelope_create(env, ns);

    squ_getfield(l, top, "header");
    if (!squ_isnil(l, -1)) {
        if (!squ_istable(l, -1)) {
            return squL_error(l, "the value of \"header\" must be a table");
        }

        header = axiom_soap_header_create_with_parent(env, envelope);
        node = axiom_soap_header_get_base_node(header, env);

        ngx_squ_xml_serialize_tables(l, env, node);
    }

    squ_getfield(l, top, "body");
    if (!squ_isnil(l, -1)) {
        if (!squ_istable(l, -1)) {
            return squL_error(l, "the value of \"body\" must be a table");
        }

        body = axiom_soap_body_create_with_parent(env, envelope);
        node = axiom_soap_body_get_base_node(body, env);

        ngx_squ_xml_serialize_tables(l, env, node);
    }

    squ_settop(l, top);

    writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE,
                                                AXIS2_FALSE,
                                                AXIS2_XML_PARSER_TYPE_BUFFER);
    output = axiom_output_create(env, writer);
    axiom_soap_envelope_serialize(envelope, env, output, AXIS2_FALSE);

    squ_pushstring(l, axiom_xml_writer_get_xml(writer, env));

    return 1;
}