Exemplo n.º 1
0
/* {{{ 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;
}
Exemplo n.º 2
0
AXIS2_EXTERN axiom_node_t* AXIS2_CALL
load_sample_xml(const axutil_env_t *env,
        axiom_node_t* tmpl,
        axis2_char_t* filename
               )
{

    axiom_document_t *doc = NULL;
    axiom_stax_builder_t *builder = NULL;
    axiom_xml_reader_t *reader = NULL;
    /*axiom_xml_writer_t *writer = NULL;*/

    reader = axiom_xml_reader_create_for_file(env, filename, NULL);
    if (!reader) printf("\n Reader is NULL");
    builder = axiom_stax_builder_create(env, reader);
    if (!builder) printf("\n builder is NULL");
    doc = axiom_document_create(env, NULL, builder);
    if (!doc) printf("\n doc is NULL");
    tmpl = axiom_document_build_all(doc, env);

    axiom_stax_builder_free_self(builder, env);
    builder = NULL;
    /*    tmpl = axiom_document_get_root_element(doc, env);*/
    if (!tmpl) printf("\n tmpl is NULL");
    return tmpl;
}
Exemplo n.º 3
0
axiom_node_t *
wsf_wsdl_util_deserialize_buffer(
    const axutil_env_t* env,  
    axis2_char_t* buffer)
{
    axiom_node_t* payload = NULL;
    axiom_document_t* document = NULL;
    axiom_xml_reader_t* reader = NULL;
    axiom_stax_builder_t* builder = NULL;

    reader = axiom_xml_reader_create_for_memory (env, 
                                                 buffer,
                                                 axutil_strlen (buffer), 
                                                 WSF_WSDL_ENCODING_UTF_8, 
                                                 AXIS2_XML_PARSER_TYPE_BUFFER);
    if (reader) 
    {
       builder = axiom_stax_builder_create (env, reader);
    }

    if (builder) 
    {
        document = axiom_stax_builder_get_document (builder, env);
    }
     
    if (document) 
    {
        payload = axiom_document_build_all (document, env);
    }

    if (builder)
    {
        axiom_stax_builder_free_self (builder, env);
    }

    if (!payload) 
    {
        AXIS2_LOG_ERROR_MSG(env->log, "Deserialization failed..");
    }

    return payload;
}
Exemplo n.º 4
0
axiom_node_t *
wsf_wsdl_util_deserialize_file(
    const axutil_env_t* env,  
    axis2_char_t* file_name)
{
    axiom_node_t* payload = NULL;
    axiom_document_t* document = NULL;
    axiom_xml_reader_t* reader = NULL;
    axiom_stax_builder_t* builder = NULL;

    reader = axiom_xml_reader_create_for_file (env, file_name, WSF_WSDL_ENCODING_UTF_8);

    if (reader) 
    {
        builder = axiom_stax_builder_create (env, reader);
    }

    if (builder) 
    {
        document = axiom_stax_builder_get_document (builder, env);
    }

    if (document) 
    {
        payload = axiom_document_build_all (document, env);
    }

    if (builder)
    {
        axiom_stax_builder_free_self (builder, env);
    }

    if (!payload) 
    {
        AXIS2_LOG_ERROR_MSG(env->log, "Deserialization failed..");
    }

    return payload;
}
Exemplo n.º 5
0
WSF_WSDL_EXTERN axis2_bool_t WSF_WSDL_CALL 
wsdl_util_create_type_map(
    const axutil_env_t* env, 
    axis2_char_t* type_map_xml_file, 
    axiom_node_t** type_map)
{
    axiom_xml_reader_t* typemap_xml_reader = NULL;
    axiom_document_t* typemap_document = NULL;
    axiom_stax_builder_t* typemap_om_builder = NULL;

    typemap_xml_reader = axiom_xml_reader_create_for_file(env, type_map_xml_file, NULL); /* encoding ?? */
    if (!typemap_xml_reader)
    {
        AXIS2_LOG_ERROR_MSG(env->log, "Failed to create xml reader for typemap");
        return AXIS2_FAILURE;
    }

    typemap_om_builder = axiom_stax_builder_create(env, typemap_xml_reader);
    if (!typemap_om_builder)
    {
        AXIS2_LOG_ERROR_MSG(env->log, "Failed to create om builder for typemap");
        axiom_xml_reader_free(typemap_xml_reader, env);
        return AXIS2_FAILURE;
    }
    
    typemap_document = axiom_stax_builder_get_document(typemap_om_builder, env);
    if (!typemap_document)
    {
        AXIS2_LOG_ERROR_MSG(env->log, "Failed to create document for typemap");
        axiom_stax_builder_free(typemap_om_builder, env);
        return AXIS2_FAILURE;
    }        
   
    *type_map = axiom_document_build_all(typemap_document, env);
     
    axiom_stax_builder_free_self(typemap_om_builder, env); 
    
    return AXIS2_SUCCESS;
}
Exemplo n.º 6
0
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;
}