Ejemplo n.º 1
0
void wsf_util_unpack_attachments (
    const axutil_env_t *env,
    axiom_node_t 	   *node,
    VALUE			   *message)
{
    axiom_text_t * text_element = NULL;
    axiom_data_handler_t *data_handler = NULL;
    axis2_char_t *content = NULL;
    unsigned int content_length = 0;
    axis2_char_t *content_type = NULL;
    axis2_char_t *cid = NULL;
    axiom_node_t *child_node = NULL;

    if (!node)
        return;

    // Process current node
    if (axiom_node_get_node_type (node, env) == AXIOM_TEXT)
    {
        text_element = (axiom_text_t *)axiom_node_get_data_element(node, env);
        if (text_element)
        {
            data_handler = axiom_text_get_data_handler (text_element, env);
            if (data_handler)
            {
                axiom_data_handler_read_from (data_handler, env, &content, &content_length);
                content_type = axiom_data_handler_get_content_type (data_handler, env);
                cid = axiom_text_get_content_id (text_element, env);

                if (content && content_type && cid)
                {
                    VALUE cont_id;
                    VALUE cont;
                    VALUE cont_type;

                    cont_id = rb_str_new2(cid);
                    cont_type = rb_str_new2(content_type);
                    cont = rb_str_new(content, content_length);

                    rb_funcall(*message, rb_intern("add_attachment_content"), 2, cont_id, cont);
                    rb_funcall(*message, rb_intern("add_content_type"), 2, cont_id, cont_type);
                }
            }
        }
    }

    // Process child nodes
    child_node = axiom_node_get_first_child (node, env);
    while (child_node)
    {
        wsf_util_unpack_attachments (env, child_node, message);

        child_node = axiom_node_get_next_sibling (child_node, env);
    }
}
Ejemplo n.º 2
0
AXIS2_EXTERN const axis2_char_t *AXIS2_CALL
axiom_text_get_text(
    axiom_text_t * om_text,
    const axutil_env_t * env)
{
    AXIS2_ENV_CHECK(env, NULL);
    AXIS2_PARAM_CHECK(env->error, om_text, NULL);
    if(om_text->value)
    {
        return axutil_string_get_buffer(om_text->value, env);
    }
    else
    {
        axis2_char_t *data_handler_stream = NULL;
        size_t data_handler_stream_size = 0;
        if(om_text->data_handler)
        {
            size_t encoded_len = 0;
            axis2_char_t *encoded_str = NULL;
            axiom_data_handler_read_from(om_text->data_handler, env, &data_handler_stream,
                &data_handler_stream_size);
            if(data_handler_stream)
            {
                encoded_len = (size_t)axutil_base64_encode_len((int)data_handler_stream_size);
                encoded_str = AXIS2_MALLOC(env->allocator, encoded_len + 2);
                if(encoded_str)
                {
                    encoded_len = (size_t)axutil_base64_encode(encoded_str, data_handler_stream,
                        (int)data_handler_stream_size);
                    encoded_str[encoded_len] = '\0';
                    return encoded_str;
                }
            }
        }
    }
    return NULL;
}