Пример #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);
    }
}
Пример #2
0
AXIS2_EXTERN axiom_mime_body_part_t *AXIS2_CALL
axiom_mime_body_part_create_from_om_text(
    const axutil_env_t *env,
    axiom_text_t *text)
{
    axiom_data_handler_t *data_handler = NULL;
    axiom_mime_body_part_t *mime_body_part = NULL;
    axis2_char_t *content_id = NULL;
    axis2_char_t *temp_content_id = NULL;
    const axis2_char_t *content_type = AXIOM_MIME_TYPE_OCTET_STREAM;

    mime_body_part = axiom_mime_body_part_create(env);
    if(!mime_body_part)
    {
        AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "MIME body part creation failed");
        return NULL;
    }

    /* Take the data_handler which is set by the sending applocation. */

    data_handler = axiom_text_get_data_handler(text, env);

    if(data_handler)
    {
        content_type = axiom_data_handler_get_content_type(data_handler, env);
    }

    axiom_mime_body_part_set_data_handler(mime_body_part, env, data_handler);
    content_id = (axis2_char_t *)"<";
    content_id = axutil_stracat(env, content_id, axiom_text_get_content_id(text, env));
    temp_content_id = axutil_stracat(env, content_id, ">");

    AXIS2_FREE(env->allocator, content_id);
    content_id = temp_content_id;

    /* Adding the content-id */
    axiom_mime_body_part_add_header(mime_body_part, env, AXIOM_MIME_HEADER_CONTENT_ID, content_id);

    /* Adding the content-type */
    axiom_mime_body_part_add_header(mime_body_part, env, AXIOM_MIME_HEADER_CONTENT_TYPE,
        axutil_strdup(env, content_type));

    /* Adding the content-transfer encoding */
    axiom_mime_body_part_add_header(mime_body_part, env,
        AXIOM_MIME_HEADER_CONTENT_TRANSFER_ENCODING, axutil_strdup(env,
            AXIOM_MIME_CONTENT_TRANSFER_ENCODING_BINARY));

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