コード例 #1
0
ファイル: wsf_util.c プロジェクト: harunjuhasz/wsf
/* {{{ ws_read_payload */
axiom_node_t *
wsf_util_read_payload (
    axiom_xml_reader_t * reader,
    const axutil_env_t * env)
{
    axiom_stax_builder_t *builder = NULL;
    axiom_document_t *document = NULL;
    axiom_node_t *payload = NULL;

    builder = axiom_stax_builder_create (env, reader);

    if (!builder) {
        return NULL;
    }

    document = axiom_stax_builder_get_document (builder, env);

    if (!document) {
        return NULL;
    }

    payload = axiom_document_get_root_element (document, env);

    if (!payload) {
        return NULL;
    }
    axiom_document_build_all (document, env);

    /** free stax builder and associated document only */
    axiom_stax_builder_free_self (builder, env);

    return payload;
}
コード例 #2
0
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
ファイル: util.c プロジェクト: AdrianRys/wsf
axiom_node_t *
wsclient_soap_header (
    const axutil_env_t *env, 
    char *input_buffer)
{
    axiom_xml_reader_t *reader;
    axiom_stax_builder_t *builder;
    axiom_document_t *doc;
    axiom_node_t *node;
    char *input;
    input = input_buffer;

    if (input)
		reader = axiom_xml_reader_create_for_memory (env, input, strlen (input), NULL, AXIS2_XML_PARSER_TYPE_BUFFER);
    else
		return WSCLIENT_FAILURE;

    if (reader)
    {
		axiom_xml_reader_init ();
		builder = axiom_stax_builder_create (env, reader);
    }
    else 
		return WSCLIENT_FAILURE;

    if (builder)
    {
		doc  = axiom_stax_builder_get_document (builder, env);
		if (doc)
			axiom_document_build_all (doc, env);
		else
			return WSCLIENT_FAILURE;
		node = axiom_document_get_root_element (doc, env);
    }
    else
    {
		axiom_xml_reader_free (reader, env);
		return WSCLIENT_FAILURE;
    }
    return node;
}
コード例 #4
0
ファイル: wsf_util.c プロジェクト: harunjuhasz/wsf
axiom_node_t *
wsf_util_deserialize_buffer (
    const axutil_env_t * env,
    char *buffer)
{
    axiom_xml_reader_t *reader = NULL;
    axiom_stax_builder_t *builder = NULL;
    axiom_document_t *document = NULL;
    axiom_node_t *payload = NULL;

    reader =
        axiom_xml_reader_create_for_memory (env, buffer,
                                            axutil_strlen (buffer), "utf-8", AXIS2_XML_PARSER_TYPE_BUFFER);
    if (!reader) {
        return NULL;
    }

    builder = axiom_stax_builder_create (env, reader);

    if (!builder) {
        return NULL;
    }
    document = axiom_stax_builder_get_document (builder, env);
    if (!document) {
        AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, "Document is not found");
        return NULL;
    }

    payload = axiom_document_get_root_element (document, env);

    if (!payload) {
        AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
                         "Root element of the document \
				is not found");
        return NULL;
    }
コード例 #5
0
ファイル: main.c プロジェクト: Denisss025/wsfcpp
axiom_node_t *
return_policy_element(
    axis2_char_t * name,
    const axutil_env_t * env,
    axis2_char_t * wsdl_name)
{
    axiom_element_t *ele1 = NULL,
        *ele2 = NULL;
    axiom_document_t *document = NULL;
    axiom_node_t *node1 = NULL,
        *node2 = NULL,
        *policy_node = NULL;
    axiom_namespace_t *ns = NULL;
    axiom_xml_reader_t *reader = NULL;
    axiom_stax_builder_t *builder = NULL;
    char *buffer = NULL;
    axiom_attribute_t *attr = NULL;
    axis2_char_t *value = NULL;
    axis2_char_t *val = NULL;
    axutil_hash_t *attr_hash = NULL;
    axis2_char_t *xml_output = NULL;
    axutil_hash_index_t *hi;

/*
    f = fopen(wsdl_name, "r");
    if (!f)
        return NULL;

    reader = axiom_xml_reader_create_for_io(env, read_input, NULL , NULL, NULL);
*/
    reader = axiom_xml_reader_create_for_file(env, wsdl_name, NULL);

    if (!reader)
    {
        printf("ERROR CREATING PULLPARSER");
        return NULL;
    }

    builder = axiom_stax_builder_create(env, reader);

    if (!builder)
    {
        printf("ERROR CREATING PULL PARSER");
        return NULL;
    }

    document = axiom_stax_builder_get_document(builder, env);
    if (!document)
        return NULL;

    node1 = axiom_document_get_root_element(document, env);
    if (!node1)
    {
        printf(" root element null ");
        axiom_stax_builder_free(builder, env);
        return NULL;
    }

    do
    {
        node2 = axiom_document_build_next(document, env);

        if (!node2)
            break;

        if (axiom_node_get_node_type(node2, env) == AXIOM_ELEMENT)
        {
            ele2 = (axiom_element_t *) axiom_node_get_data_element(node2, env);
            attr_hash = axiom_element_get_all_attributes(ele2, env);
            if (attr_hash)
            {
                hi = axutil_hash_first(attr_hash, env);
                axutil_hash_this(hi, NULL, NULL, &attr);

                if (axutil_strcmp(axiom_attribute_get_value(attr, env), name) ==
                    0)
                {
                    policy_node = node2;
                }
            }
        }
    }
    while (node2);
    return policy_node;
}
コード例 #6
0
ファイル: security_admin_util.c プロジェクト: AdrianRys/wsf
AXIS2_EXTERN axutil_array_list_t* AXIS2_CALL
security_admin_load_scenarios(
		const axutil_env_t* env, 
		axis2_msg_ctx_t* msg_ctx)
{
	/* Read senarios from config file*/
	axis2_conf_ctx_t* conf_ctx = NULL;
	axis2_char_t* repo_path = NULL;
	axis2_char_t* scenario_config_file_path = NULL;
	axiom_xml_reader_t* xml_reader = NULL;
	axiom_document_t* document = NULL;
	axiom_stax_builder_t* stax_builder = NULL;
	axiom_node_t* scenario_config_root_node = NULL;
	axiom_element_t* scenario_config_root_element = NULL;
	axiom_children_iterator_t* children_ite = NULL;
	axutil_array_list_t* scenarios = NULL;
			
	/* Form absolute path to config file*/
	conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
	repo_path = axis2_conf_ctx_get_root_dir(conf_ctx, env);
	scenario_config_file_path = axutil_strcat(env, repo_path, AXIS2_PATH_SEP_STR, "services", 
		AXIS2_PATH_SEP_STR, "SecurityAdminService", AXIS2_PATH_SEP_STR, "scenario-config.xml", 
		NULL);

	xml_reader = axiom_xml_reader_create_for_file(env, scenario_config_file_path, NULL);
	AXIS2_FREE(env->allocator, scenario_config_file_path);
	if (!xml_reader) return NULL;

	stax_builder = axiom_stax_builder_create(env, xml_reader);
	if (!stax_builder) return NULL;

	document = axiom_stax_builder_get_document(stax_builder, env);
	if (!document) return NULL;

	/* Build XML document*/
	axiom_document_build_all(document, env);

	scenario_config_root_node = axiom_document_get_root_element(document, env);
	scenario_config_root_element = axiom_node_get_data_element(scenario_config_root_node, env);
	axiom_stax_builder_free_self(stax_builder, env);
			
	children_ite = axiom_element_get_children(scenario_config_root_element, env, 
		scenario_config_root_node);
	if (children_ite)
	{
		/* Get Scenario nodes and build hash*/
		while (axiom_children_iterator_has_next(children_ite, env))
		{
			axiom_node_t* node = NULL;

			node = axiom_children_iterator_next(children_ite, env);

			if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT)
			{
				axis2_char_t* localname = NULL;
				axiom_element_t* scenario_ele = NULL;
				axiom_children_iterator_t* ite = NULL;
	
				scenario_ele = axiom_node_get_data_element(node, env);

				localname = axiom_element_get_localname(scenario_ele, env);

				if (0 == axutil_strcmp(localname, "Scenario")) /* Scenario */
				{
					axis2_char_t* id = NULL;
					security_admin_scenario_data_t* data = NULL;

					/* Create scenarios hash*/
					if (!scenarios)
						scenarios = axutil_array_list_create(env, SEC_ADMIN_SCENARIO_COUNT);

					data = security_admin_scenario_data_create(env);

					/* Current scenario*/
					security_admin_scenario_data_set_current_scenario(data, AXIS2_TRUE);

					/* id*/
					id = axiom_element_get_attribute_value_by_name(scenario_ele, env, "id");
					security_admin_scenario_data_set_id(data, axutil_strdup(env, id));

					ite = axiom_element_get_children(scenario_ele, env, node);
					while (axiom_children_iterator_has_next(ite, env))
					{
						axiom_node_t* node = NULL;
						node = axiom_children_iterator_next(ite, env);

						if (axiom_node_get_node_type(node, env) == AXIOM_ELEMENT)
						{
							axiom_element_t* node_ele = NULL;
							axis2_char_t* localname = NULL;
							axis2_char_t* text = NULL;

							node_ele = axiom_node_get_data_element(node, env);

							localname = axiom_element_get_localname(node_ele, env);
							text = axiom_element_get_text(node_ele, env, node);
									
							if (0 == axutil_strcmp(localname, "Summary")) /* Summary */
							{
								security_admin_scenario_data_set_summary(data, 
									axutil_strdup(env, text));
							}
							else if (0 == axutil_strcmp(localname, "Description")) /* Description */
							{
								security_admin_scenario_data_set_description(data, 
									axutil_strdup(env, text));
							}
							else if (0 == axutil_strcmp(localname, "Category")) /* Category */
							{
								security_admin_scenario_data_set_category(data, 
									axutil_strdup(env, text));
							}
							/*else if (0 == axutil_strcmp(localname, "WsuId")*/ /* WsuId */
							/*{
							}*/
							else if (0 == axutil_strcmp(localname, "Type")) /* Type */
							{
								security_admin_scenario_data_set_type(data, 
									axutil_strdup(env, text));
							}
							else if (0 == axutil_strcmp(localname, "Modules")) /* Modules */
							{
										
							}
						}
					}

					/* Add scenario data into the hash map*/
					axutil_array_list_add(scenarios, env, data);
				}
			}
		}
	}

	return scenarios;
}