Exemple #1
0
AXIS2_EXTERN void AXIS2_CALL
axiom_text_free(
    axiom_text_t * om_text,
    const axutil_env_t * env)
{
    AXIS2_ENV_CHECK_VOID(env);

    if(om_text->value)
    {
        axutil_string_free(om_text->value, env);
    }

    if(om_text->ns)
    {
        axiom_namespace_free(om_text->ns, env);
    }

    if(om_text->content_id)
    {
        AXIS2_FREE(env->allocator, om_text->content_id);
    }

    if(om_text->om_attribute)
    {
        axiom_attribute_free(om_text->om_attribute, env);
    }

    if(om_text->data_handler)
    {
        axiom_data_handler_free(om_text->data_handler, env);
    }

    AXIS2_FREE(env->allocator, om_text);
    return;
}
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_soap_fault_text_set_lang(
    axiom_soap_fault_text_t * fault_text,
    const axutil_env_t * env,
    const axis2_char_t * lang)
{
    int status = AXIS2_SUCCESS;
    axiom_element_t *om_ele = NULL;

    AXIS2_PARAM_CHECK(env->error, lang, AXIS2_FAILURE);

    if(fault_text->lang_attribute)
    {
        axis2_char_t *attr_lang = NULL;
        attr_lang = axiom_attribute_get_value(fault_text->lang_attribute, env);
        if(attr_lang)
        {
            if(axutil_strcmp(attr_lang, lang) == 0)
            {

                /** this attribute already exists */
                return AXIS2_SUCCESS;
            }
        }
        axiom_attribute_set_value(fault_text->lang_attribute, env, lang);
        return AXIS2_SUCCESS;
    }

    fault_text->lang_attribute = axiom_attribute_create(env,
        AXIOM_SOAP12_SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME, lang, fault_text-> lang_namespace);
    if(!fault_text->lang_attribute)
    {
        return AXIS2_FAILURE;
    }

    if(!fault_text->om_ele_node)
    {
        return AXIS2_FAILURE;
    }
    om_ele = (axiom_element_t *)axiom_node_get_data_element(fault_text->om_ele_node, env);
    if(!om_ele)
    {
        return AXIS2_FAILURE;
    }

    status = axiom_element_add_attribute(om_ele, env, fault_text->lang_attribute,
        fault_text->om_ele_node);

    if(status == AXIS2_SUCCESS)
    {
        fault_text->lang_ns_used = AXIS2_TRUE;
    }
    else
    {
        axiom_attribute_free(fault_text->lang_attribute, env);
        fault_text->lang_attribute = NULL;
    }
    return status;
}
AXIS2_EXTERN void AXIS2_CALL
axiom_attribute_free_void_arg(
    void *attribute,
    const axutil_env_t * env)
{
    axiom_attribute_t *om_attribute_l = NULL;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    om_attribute_l = (axiom_attribute_t *)attribute;
    axiom_attribute_free(om_attribute_l, env);
    return;
}
Exemple #4
0
AXIS2_EXTERN axis2_status_t AXIS2_CALL
axiom_text_serialize(
    axiom_text_t * om_text,
    const axutil_env_t * env,
    axiom_output_t * om_output)
{
    int status = AXIS2_SUCCESS;
    axis2_char_t *attribute_value = NULL;
    const axis2_char_t *text = NULL;
    axiom_xml_writer_t *om_output_xml_writer = NULL;

    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
    AXIS2_PARAM_CHECK(env->error, om_output, AXIS2_FAILURE);

    if(!axiom_text_get_is_binary(om_text, env))
    {
        if(om_text->value)
        {
            status = axiom_output_write(om_output, env, AXIOM_TEXT, 1, axutil_string_get_buffer(
                om_text->value, env));
        }
    }
    else
    {
        om_output_xml_writer = axiom_output_get_xml_writer(om_output, env);
        if(axiom_output_is_optimized(om_output, env) && om_text->optimize)
        {
            if(!(axiom_text_get_content_id(om_text, env)))
            {
                axis2_char_t *content_id = axiom_output_get_next_content_id(om_output, env);
                if(content_id)
                {
                    om_text->content_id = axutil_strdup(env, content_id);
                }
            }

            attribute_value = axutil_stracat(env, "cid:", om_text->content_id);

            /*send binary as MTOM optimised */
            if(om_text->om_attribute)
            {
                axiom_attribute_free(om_text->om_attribute, env);
                om_text->om_attribute = NULL;
            }

            om_text->om_attribute = axiom_attribute_create(env, "href", attribute_value, NULL);

            AXIS2_FREE(env->allocator, attribute_value);
            attribute_value = NULL;

            if(!om_text->is_swa) /* This is a hack to get SwA working */
            {
                axiom_text_serialize_start_part(om_text, env, om_output);
            }
            else
            {
                status = axiom_output_write(om_output, env, AXIOM_TEXT, 1, om_text->content_id);
            }

            axiom_output_write_optimized(om_output, env, om_text);

            axiom_output_write(om_output, env, AXIOM_ELEMENT, 0);
        }
        else
        {
            text = axiom_text_get_text(om_text, env);
            axiom_xml_writer_write_characters(om_output_xml_writer, env, (axis2_char_t *)text);
        }
    }
    return status;
}
Exemple #5
0
/**
 * Traverse thru the node and its descendents. Check if the node has a particular attribute with 
 * name as in @attr and namespace as in @ns. Returns the attribute value.
 * @param env Environment. MUST NOT be NULL,
 * @param node the node to be searched
 * @param attribute_name the attribute name of the node
 * @param ns namespace of the attribute
 * @return the attribute value if found, else NULL
 */
AXIS2_EXTERN axis2_char_t* AXIS2_CALL
oxs_axiom_get_attribute_value_of_node_by_name(
    const axutil_env_t *env,
    axiom_node_t *node,
    axis2_char_t *attribute_name,
    axis2_char_t *ns_uri)
{
    axis2_char_t *found_val = NULL;
    axiom_element_t *ele = NULL;
    axutil_hash_t *attr_list = NULL;
    axutil_hash_index_t *hi = NULL;
    
    ele = axiom_node_get_data_element(node, env);

    /* Get attribute list of the element */
    attr_list = axiom_element_extract_attributes(ele, env, node);
    if(!attr_list)
    {
        return NULL;
    }

    /* namespace uri can be NULL. In that case, use empty string */
    if(!ns_uri)
    {
        ns_uri = "";
    }

    /* Traverse thru all the attributes. If both localname and the nsuri matches return the val */
    for (hi = axutil_hash_first(attr_list, env); hi; hi = axutil_hash_next(env, hi))
    {
        void *attr = NULL;
        axiom_attribute_t *om_attr = NULL;
        axutil_hash_this(hi, NULL, NULL, &attr);
        if (attr)
        {
            axis2_char_t *this_attr_name = NULL;
            axis2_char_t *this_attr_ns_uri = NULL;
            axiom_namespace_t *attr_ns = NULL;

            om_attr = (axiom_attribute_t*)attr;
            this_attr_name = axiom_attribute_get_localname(om_attr, env);
            attr_ns = axiom_attribute_get_namespace(om_attr, env);
            if(attr_ns)
            {
                this_attr_ns_uri = axiom_namespace_get_uri(attr_ns, env);
            }
            else
            {
                this_attr_ns_uri = "";
            }
            
            if((!axutil_strcmp(attribute_name, this_attr_name)) && 
                (!axutil_strcmp(ns_uri, this_attr_ns_uri)))
            {
                /* Got it !!! */
                found_val = axiom_attribute_get_value(om_attr, env);
				AXIS2_FREE(env->allocator, hi);
                break;
            }
        }
    }

    for(hi = axutil_hash_first(attr_list, env); hi; hi = axutil_hash_next(env, hi))
    {
        void *val = NULL;
        axutil_hash_this(hi, NULL, NULL, &val);
        if (val)
        {
            axiom_attribute_free((axiom_attribute_t *)val, env);
            val = NULL;
        }
    }
    axutil_hash_free(attr_list, env);
    attr_list = NULL;

    return found_val;
}