You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ma...@apache.org on 2008/06/16 12:23:17 UTC
svn commit: r668102 - in
/webservices/axis2/branches/c/post_1_4_mtom/c/axiom: include/
src/attachments/ src/om/
Author: manjula
Date: Mon Jun 16 03:23:17 2008
New Revision: 668102
URL: http://svn.apache.org/viewvc?rev=668102&view=rev
Log: (empty)
Modified:
webservices/axis2/branches/c/post_1_4_mtom/c/axiom/include/axiom_data_handler.h
webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/ (props changed)
webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_body_part.h
webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_output.h
webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/data_handler.c
webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_body_part.c
webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_output.c
webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/om/ (props changed)
webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/om/om_output.c
Modified: webservices/axis2/branches/c/post_1_4_mtom/c/axiom/include/axiom_data_handler.h
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/axiom/include/axiom_data_handler.h?rev=668102&r1=668101&r2=668102&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/axiom/include/axiom_data_handler.h (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/axiom/include/axiom_data_handler.h Mon Jun 16 03:23:17 2008
@@ -184,6 +184,20 @@
const axis2_char_t * file_name,
const axis2_char_t * mime_type);
+ /* Add the binary to the array_list
+ * @param data_handler, a pointer to data handler struct
+ * data_handler, a pointer to data handler struct
+ * list, a pointer to an array_list which containing some message parts need
+ * to be written to the wire
+ * data_handler, a pointer to data handler struct
+ */
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ axiom_data_handler_add_binary_data(
+ axiom_data_handler_t *data_handler,
+ const axutil_env_t *env,
+ axutil_array_list_t *list);
+
/** @} */
#ifdef __cplusplus
Propchange: webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jun 16 03:23:17 2008
@@ -0,0 +1,2 @@
+.deps
+.libs
Modified: webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_body_part.h
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_body_part.h?rev=668102&r1=668101&r2=668102&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_body_part.h (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_body_part.h Mon Jun 16 03:23:17 2008
@@ -73,15 +73,31 @@
axiom_mime_body_part_free(
axiom_mime_body_part_t * mime_body_part,
const axutil_env_t * env);
+
+ AXIS2_EXTERN axis2_status_t AXIS2_CALL
+ axiom_mime_body_part_write_to_list(
+ axiom_mime_body_part_t *mime_body_part,
+ const axutil_env_t *env,
+ axutil_array_list_t *list);
/**
* Creates mime_body_part struct
* @return pointer to newly created mime_body_part
*/
AXIS2_EXTERN axiom_mime_body_part_t *AXIS2_CALL
-
axiom_mime_body_part_create(
const axutil_env_t * env);
+
+ /**
+ * Creates mime_body_part struct from a om_text
+ * @return pointer to newly created mime_body_part
+ */
+
+ 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);
+
#define AXIOM_MIME_BODY_PART_FREE(mime_body_part, env) \
axiom_mime_body_part_free (mime_body_part, env)
Modified: webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_output.h
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_output.h?rev=668102&r1=668101&r2=668102&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_output.h (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/axiom_mime_output.h Mon Jun 16 03:23:17 2008
@@ -42,6 +42,31 @@
* @ingroup axiom_mime_output
* @{
*/
+
+ typedef struct axiom_mime_output_part_t axiom_mime_output_part_t;
+
+
+ typedef enum axiom_mime_output_part_type_t
+ {
+
+ /** Char buffer */
+ AXIOM_MIME_OUTPUT_PART_BUFFER = 0,
+
+ /* A file */
+ AXIOM_MIME_OUTPUT_PART_FILE;
+
+ /* unknown type*/
+ AXIOM_MIME_OUTPUT_PART_UNKNOWN
+
+ } axiom_mime_output_part_type_t;
+
+ struct axiom_mime_output_part_t
+ {
+ axis2_byte_t *part;
+ axis2_char_t *file_name;
+ int part_size;
+ axiom_mime_output_part_type_t type;
+ }
AXIS2_EXTERN axis2_byte_t *AXIS2_CALL
axiom_mime_output_complete(
@@ -80,6 +105,16 @@
AXIS2_EXTERN axiom_mime_output_t *AXIS2_CALL
axiom_mime_output_create(
const axutil_env_t * env);
+
+ /**
+ * Creates mime_output part struct
+ * @return pointer to newly created mime_output_part
+ */
+
+ AXIS2_EXTERN axiom_mime_output_part_t *AXIS2_CALL
+ axiom_mime_output_part_create(
+ const axutil_env_t *env);
+
/** @} */
Modified: webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/data_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/data_handler.c?rev=668102&r1=668101&r2=668102&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/data_handler.c (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/data_handler.c Mon Jun 16 03:23:17 2008
@@ -18,6 +18,7 @@
#include <axiom_data_handler.h>
#include <stdio.h>
#include <sys/stat.h>
+#include "axiom_mime_output.h"
struct axiom_data_handler
{
@@ -392,3 +393,61 @@
return AXIS2_SUCCESS;
}
+
+/* This method will add the data_handler binary data to the array_list.
+ * If it is a buffer the part type is buffer. otherwise it is a file
+ */
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axiom_data_handler_add_binary_data(
+ axiom_data_handler_t *data_handler,
+ const axutil_env_t *env,
+ axutil_array_list_t *list)
+
+{
+ axiom_mime_output_part_t *binary_part = NULL;
+
+ binary_part = axiom_mime_output_part_create(env);
+
+ if(!binary_part)
+ {
+ return AXIS2_FAILUE;
+ }
+
+ if (data_handler->data_handler_type == AXIOM_DATA_HANDLER_TYPE_BUFFER)
+ {
+ binary_part->part = (axis2_byte_t *)data_handler->buffer;
+ binary_part->part_size = (axis2_byte_t *)data_handler->buffer_len;
+ binary_part->type = AXIOM_MIME_OUTPUT_PART_TYPE_BUFFER;
+ }
+
+ else if (data_handler->data_handler_type == AXIOM_DATA_HANDLER_TYPE_FILE
+ && data_handler->file_name)
+ {
+ struct stat stat_p;
+
+ if (stat(data_handler->file_name, &stat_p) == -1)
+ {
+ return AXIS2_FAILURE;
+ }
+ else if (stat_p.st_size == 0)
+ {
+ return AXIS2_SUCCESS;
+ }
+ else
+ {
+ binary_part->file_name = data_handler->file_name;
+ binary_part->part_size = stat_p.st_size;
+ binary_part->type = AXIOM_MIME_OUTPUT_PART_TYPE_FILE;
+ }
+ }
+ else
+ {
+ /* Data Handler File Name is missing */
+ return AXIS2_FAILURE;
+ }
+
+ axutil_array_list_add(list, env, binary_part);
+
+ return AXIS2_SUCCESS;
+}
Modified: webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_body_part.c
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_body_part.c?rev=668102&r1=668101&r2=668102&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_body_part.c (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_body_part.c Mon Jun 16 03:23:17 2008
@@ -16,6 +16,7 @@
*/
#include "axiom_mime_body_part.h"
+#include "axiom_mime_output.h"
#include <axiom_data_handler.h>
#include <axutil_hash.h>
@@ -26,6 +27,11 @@
axiom_data_handler_t *data_handler;
};
+/* This method just create a mime_body_part. It does not
+ * fill the header map.
+ */
+
+
AXIS2_EXTERN axiom_mime_body_part_t *AXIS2_CALL
axiom_mime_body_part_create(
const axutil_env_t *env)
@@ -57,6 +63,66 @@
return mime_body_part;
}
+/* This method will create the mime_body_part and fill the header map with
+ * default information. Default information are for binary attachments.
+ * Attachment information is taken from the information in data_handler in passed
+ * om_text.
+ */
+
+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;
+}
+
+
AXIS2_EXTERN void AXIS2_CALL
axiom_mime_body_part_free(
axiom_mime_body_part_t *mime_body_part,
@@ -117,12 +183,19 @@
return AXIS2_SUCCESS;
}
+
+/* This method will fill the array_list with binary and binary_beader information.
+ * If the binary is in a file this will not load the file to the memory. Because
+ * that will cause performance degradation when the file size is large. Instead
+ * this will add file information to the list so that when writing the message
+ * through transport_sender it can send the file by chunk.
+ */
+
AXIS2_EXTERN axis2_status_t AXIS2_CALL
-axiom_mime_body_part_write_to(
+axiom_mime_body_part_write_to_list(
axiom_mime_body_part_t *mime_body_part,
const axutil_env_t *env,
- axis2_byte_t **output_stream,
- int *output_stream_size)
+ axutil_array_list_t *list)
{
axutil_hash_index_t *hash_index = NULL;
const void *key = NULL;
@@ -135,14 +208,21 @@
axis2_status_t status = AXIS2_FAILURE;
axis2_byte_t *byte_stream = NULL;
int size = 0;
+ axiom_mime_output_part_t *mime_header_part = NULL;
+ axiom_mime_output_part_t *binary_part = NULL;
+ /* We have the mime headers in the hash with thier keys
+ * So first concatenate them to a one string */
+
for (hash_index = axutil_hash_first(mime_body_part->header_map, env);
hash_index; hash_index = axutil_hash_next(env, hash_index))
{
axutil_hash_this(hash_index, &key, NULL, &value);
if (key && value)
{
+ /* First conactenate to the already conacatenated stuff */
+
temp_header_str =
axutil_stracat(env, header_str, (axis2_char_t *) key);
if (header_str)
@@ -153,16 +233,24 @@
temp_header_str = axutil_stracat(env, header_str, ": ");
AXIS2_FREE(env->allocator, header_str);
header_str = temp_header_str;
+
+ /* Add the new stuff */
temp_header_str =
axutil_stracat(env, header_str, (axis2_char_t *) value);
AXIS2_FREE(env->allocator, header_str);
header_str = temp_header_str;
+
+ /* Next header will be in a new line. So lets add it */
+
temp_header_str = axutil_stracat(env, header_str, AXIS2_CRLF);
AXIS2_FREE(env->allocator, header_str);
header_str = temp_header_str;
}
}
+ /* If there is a data handler that's mean there is an attachment. Attachment
+ * will always start after an additional new line . So let's add it .*/
+
if (mime_body_part->data_handler)
{
temp_header_str = axutil_stracat(env, header_str, AXIS2_CRLF);
@@ -174,50 +262,42 @@
{
header_str_size = axutil_strlen(header_str);
}
+
+ /* Now we have the complete mime_headers string for a particular mime part.
+ * First wrap it as a mime_output_part_t .Then add it to the array list so
+ * later through the transport this can be written to the wire. */
+
+ mime_header_part = axiom_mime_output_part_create(env);
+
+ if(mime_header_part)
+ {
+ mime_header_part->part = (axis2_byte_t *)header_str;
+ mime_header_part->part_size = header_str_size;
+ mime_header_part->type = AXIOM_MIME_OUTPUT_PART_BUFFER;
+ }
+ else
+ {
+ return AXIS2_FAILURE;
+ }
+
+ axutil_array_list_add(list, env, mime_header_part);
/* TODO: We only support binary as of now,
* Need to support "base64", "uuencode", "x-uuencode", "x-uue" and,
* "quoted-printable"
*/
+
+ /* Then if the data_handler is there let's add the binary data, may be
+ * buffer , may be file name and information.
+ */
+
if (mime_body_part->data_handler)
{
- status = axiom_data_handler_read_from(mime_body_part->data_handler, env,
- &data_handler_stream, &data_handler_stream_size);
+ status = axiom_data_handler_add_binary_data(data_handler, env, list);
if (status != AXIS2_SUCCESS)
{
return status;
}
}
-
- size = header_str_size + data_handler_stream_size;
- byte_stream = AXIS2_MALLOC(env->allocator, (size) * sizeof(axis2_byte_t));
- if (!byte_stream)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "No memory. Cannot create binary stream");
-
- if (header_str)
- {
- AXIS2_FREE(env->allocator, header_str);
- }
- return AXIS2_FAILURE;
- }
- if (header_str)
- {
- memcpy(byte_stream, header_str, header_str_size);
- AXIS2_FREE(env->allocator, header_str);
- }
-
- if (data_handler_stream)
- {
- memcpy(byte_stream + header_str_size,
- data_handler_stream, data_handler_stream_size);
- data_handler_stream = NULL;
- }
-
- *output_stream = byte_stream;
- *output_stream_size = size;
-
return AXIS2_SUCCESS;
}
Modified: webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_output.c
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_output.c?rev=668102&r1=668101&r2=668102&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_output.c (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_output.c Mon Jun 16 03:23:17 2008
@@ -22,29 +22,19 @@
#include <axiom_text.h>
#include <axiom_mime_const.h>
-static axis2_status_t axis2_char_2_byte(
- const axutil_env_t *env,
- axis2_char_t *char_buffer,
- axis2_byte_t **byte_buffer,
- int *byte_buffer_size);
-
-static axiom_mime_body_part_t *axis2_create_mime_body_part(
- axiom_text_t *text,
- const axutil_env_t *env);
-static axis2_status_t axis2_write_body_part(
+static axis2_status_t
+axiom_mime_output_write_body_part_to_list(
axiom_mime_output_t *mime_output,
const axutil_env_t *env,
- axis2_byte_t **output_stream,
- int *output_stream_size,
- axiom_mime_body_part_t *part,
- axis2_char_t *boundary);
+ axutil_array_list_t *list,
+ axiom_mime_body_part_t *part);
-static axis2_status_t axis2_write_mime_boundary(
+static axis2_status_t
+axiom_mime_output_write_mime_boundary(
axiom_mime_output_t *mime_output,
const axutil_env_t *env,
- axis2_byte_t **output_stream,
- int *output_stream_size,
+ axutil_array_list_t *list,
axis2_char_t *boundary);
static axis2_status_t axis2_write_finish_writing_mime(
@@ -54,12 +44,6 @@
int *output_stream_size,
axis2_char_t *boundary);
-static axis2_status_t axis2_start_writing_mime(
- axiom_mime_output_t *mime_output,
- const axutil_env_t *env,
- axis2_byte_t **output_stream,
- int *output_stream_size,
- axis2_char_t *boundary);
AXIS2_EXTERN axiom_mime_output_t *AXIS2_CALL
axiom_mime_output_create(
@@ -80,6 +64,28 @@
return mime_output;
}
+AXIS2_EXTERN axiom_mime_output_part_t *AXIS2_CALL
+axiom_mime_output_part_create(
+ const axutil_env_t *env)
+{
+ axiom_mime_output_part_t *mime_output_part = NULL;
+ mime_output_part = AXIS2_MALLOC(env->allocator, sizeof(axiom_mime_output_part_t));
+
+ if(mime_output_part)
+ {
+ mime_output_part->part = NULL;
+ mime_output_part->file_name = NULL;
+ mime_output_part->part_size = 0;
+ mime_output_part->type = AXIOM_MIME_OUTPUT_PART_UNKNOWN;
+
+ return mime_output_part;
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
AXIS2_EXTERN void AXIS2_CALL
axiom_mime_output_free(
axiom_mime_output_t *mime_output,
@@ -306,35 +312,27 @@
return stream_buffer;
}
-static axis2_status_t
-axis2_start_writing_mime(
- axiom_mime_output_t *mime_output,
- const axutil_env_t *env,
- axis2_byte_t **output_stream,
- int *output_stream_size,
- axis2_char_t *boundary)
-{
- return axis2_write_mime_boundary(mime_output, env, output_stream,
- output_stream_size, boundary);
-}
+/* This method will create a mime_boundary buffer
+ * and based on the buffer creates a mime_output part
+ * This will be added to the array_list so later in the trasnport
+ *this can be put to the wire. */
static axis2_status_t
-axis2_write_mime_boundary(
+axiom_mime_output_write_mime_boundary(
axiom_mime_output_t *mime_output,
const axutil_env_t *env,
- axis2_byte_t **output_stream,
- int *output_stream_size,
+ axutil_array_list_t *list,
axis2_char_t *boundary)
{
axis2_byte_t *byte_buffer = NULL;
axis2_byte_t *byte_stream = NULL;
int size = 0;
-
- axis2_char_2_byte(env, boundary, &byte_buffer, &size);
- if (!byte_buffer)
- {
- return AXIS2_FAILURE;
- }
+ axiom_mime_output_part_t *boundary_part = NULL;
+
+ boundary_part = axiom_mime_output_part_create(env);
+
+ byte_buffer = (axis2_byte_t *)boundary;
+
byte_stream =
AXIS2_MALLOC(env->allocator, (size + 2) * sizeof(axis2_byte_t));
if (!byte_stream)
@@ -352,114 +350,59 @@
AXIS2_FREE(env->allocator, byte_buffer);
byte_buffer = NULL;
- *output_stream = byte_stream;
- *output_stream_size = size + 2;
+ boundary_part->part = byte_stream;
+ boundary_part->part_size = size + 2;
+ boundary_part->type = AXIOM_MIME_OUTPUT_PART_BUFFER;
+
+ axutil_array_list_add(list, env, boundary_part);
return AXIS2_SUCCESS;
}
-static axiom_mime_body_part_t *
-axis2_create_mime_body_part(
- axiom_text_t *text,
- const axutil_env_t *env)
-{
- 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;
- }
- 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;
-
- AXIOM_MIME_BODY_PART_ADD_HEADER(mime_body_part, env,
- AXIOM_MIME_HEADER_CONTENT_ID, content_id);
- AXIOM_MIME_BODY_PART_ADD_HEADER(mime_body_part, env,
- AXIOM_MIME_HEADER_CONTENT_TYPE, axutil_strdup(env, content_type));
- 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;
-}
-
static axis2_status_t
-axis2_write_body_part(
+axiom_mime_output_write_body_part_to_list(
axiom_mime_output_t *mime_output,
const axutil_env_t *env,
- axis2_byte_t **output_stream,
- int *output_stream_size,
- axiom_mime_body_part_t *part,
- axis2_char_t *boundary)
+ axutil_array_list_t *list,
+ axiom_mime_body_part_t *part)
{
- axis2_byte_t *byte_stream = NULL;
- axis2_byte_t *body_stream = NULL;
- int body_stream_size = 0;
-
- AXIOM_MIME_BODY_PART_WRITE_TO(part, env, &body_stream, &body_stream_size);
-
- byte_stream = AXIS2_MALLOC(env->allocator,
- (body_stream_size + 4) * sizeof(axis2_byte_t));
- if (!byte_stream)
- {
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "No memory. Cannot create byte stream");
- return AXIS2_FAILURE;
- }
-
- byte_stream[0] = AXIS2_CRLF[0];
- byte_stream[1] = AXIS2_CRLF[1];
-
- if (body_stream)
- {
- memcpy(byte_stream + 2, body_stream, body_stream_size);
- AXIS2_FREE(env->allocator, body_stream);
- body_stream = NULL;
- }
- else
- {
- AXIS2_LOG_WARNING(env->log, AXIS2_LOG_SI,
- "Body Stream not available for writing");
- }
-
-
- byte_stream[body_stream_size + 2] = AXIS2_CRLF[0];
- byte_stream[body_stream_size + 3] = AXIS2_CRLF[1];
-
- *output_stream = byte_stream;
- *output_stream_size = body_stream_size + 4;
-
+ axiom_mime_output_part_t *crlf1 = NULL;
+ axiom_mime_output_part_t *crlf2 = NULL;
+
+ /* There is a \r\n before the attachment data
+ * So first add it
+ */
+
+ crlf1 = axiom_mime_output_part_create(env);
+
+ crlf1->part = (axis2_byte_t *)axutil_strdup(env, AXIS2_CRLF);
+ crlf1->part_size = 2;
+ crlf1->type = AXIOM_MIME_OUTPUT_PART_BUFFER;
+
+ axutil_array_list_add(list, env, crlf1);
+
+ /* Write the attachemnt and realted haeders to the list */
+
+ axiom_mime_body_part_write_to_list(part, env, list);
+
+ /* Then add the next \r\n after the attachment */
+
+ crlf2 = axiom_mime_output_part_create(env);
+
+ crlf2->part = (axis2_byte_t *)axutil_strdup(env, AXIS2_CRLF);
+ crlf2->part_size = 2;
+ crlf2->type = AXIOM_MIME_OUTPUT_PART_BUFFER;
+
+ axutil_array_list_add(list, env, crlf2);
+
return AXIS2_SUCCESS;
-
}
static axis2_status_t
-axis2_write_finish_writing_mime(
+axiom_mime_output_finish_adding_parts(
axiom_mime_output_t *mime_output,
const axutil_env_t *env,
- axis2_byte_t **output_stream,
- int *output_stream_size,
+ axutil_array_list *list,
axis2_char_t *boundary)
{
axis2_byte_t *byte_buffer = NULL;
@@ -604,34 +547,179 @@
return content_type_string;
}
-static axis2_status_t
-axis2_char_2_byte(
+AXIS2_EXTERN axutil_arraylist_t *AXIS2_CALL
+axiom_mime_output_create_part_list(
+ axiom_mime_output_t *mime_output,
const axutil_env_t *env,
- axis2_char_t *char_buffer,
- axis2_byte_t **byte_buffer,
- int *byte_buffer_size)
+ axis2_char_t *soap_body,
+ axutil_array_list_t *binary_node_list,
+ axis2_char_t *boundary,
+ axis2_char_t *content_id,
+ axis2_char_t *char_set_encoding,
+ const axis2_char_t *soap_content_type)
{
- int length = 0;
- int i = 0;
- axis2_byte_t *bytes = NULL;
-
- length = (int) axutil_strlen(char_buffer);
- bytes = (axis2_byte_t *)
- AXIS2_MALLOC(env->allocator, length * sizeof(axis2_byte_t));
+ axis2_status_t status = AXIS2_FAILURE;
+ axis2_char_t *header_value = NULL;
+ axis2_char_t *temp_header_value = NULL;
+ axis2_char_t *content_id_string = NULL;
+ axis2_char_t *temp_content_id_string = NULL;
+ axiom_mime_body_part_t *root_mime_body_part = NULL;
+ axis2_byte_t *output_stream_start = NULL;
+ int output_stream_start_size = 0;
+ axis2_byte_t *output_stream_body = NULL;
+ int output_stream_body_size = 0;
+ axis2_byte_t *output_stream_body_parts = NULL;
+ int output_stream_body_parts_size = 0;
+ axis2_byte_t *boundary_stream = NULL;
+ int boundary_stream_size = 0;
+ axis2_byte_t *stream_buffer = NULL;
+ int stream_buffer_size = 0;
+ int soap_body_buffer_size = 0;
+ axis2_char_t *temp_soap_body_buffer = NULL;
+ axis2_char_t *soap_body_buffer = NULL;
+ axutil_array_list_t *part_list = NULL;
+ axiom_mime_output_part_t *soap_part = NULL;
+
+ part_list = axutil_array_list_create(env, 0);
+
+ if(!part_list)
+ {
+ AXIS2_LOG_ERROR(env->log, "No memory");
+ return NULL;
+ }
+
+ status = axiom_mime_output_write_mime_boundary(mime_output,
+ env, part_list, boundary);
+
+ if (status != AXIS2_SUCCESS)
+ {
+ return NULL;
+ }
+
+ root_mime_body_part = axiom_mime_body_part_create(env);
- if (!bytes)
+ if (!root_mime_body_part)
{
- AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
- AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
- "No memory. Cannot create byte buffer");
- return AXIS2_FAILURE;
+ return NULL;
}
- for (i = 0; i < length; i++)
+ /* Adding Content-Type Header */
+ header_value = axutil_strdup(env, AXIOM_MIME_TYPE_XOP_XML
+ ";" AXIOM_MIME_HEADER_FIELD_CHARSET "=");
+ temp_header_value = axutil_stracat(env, header_value, char_set_encoding);
+ AXIS2_FREE(env->allocator, header_value);
+ header_value = temp_header_value;
+ temp_header_value = axutil_stracat(env, header_value, ";"
+ AXIOM_MIME_HEADER_FIELD_TYPE "=\"");
+ AXIS2_FREE(env->allocator, header_value);
+ header_value = temp_header_value;
+ temp_header_value = axutil_stracat(env, header_value, soap_content_type);
+ AXIS2_FREE(env->allocator, header_value);
+ header_value = temp_header_value;
+ temp_header_value = axutil_stracat(env, header_value, "\";");
+ AXIS2_FREE(env->allocator, header_value);
+ header_value = temp_header_value;
+ AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env,
+ AXIOM_MIME_HEADER_CONTENT_TYPE, header_value);
+
+ /* Adding Content Transfer Encoding header */
+
+ AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env,
+ AXIOM_MIME_HEADER_CONTENT_TRANSFER_ENCODING,
+ axutil_strdup(env, AXIOM_MIME_CONTENT_TRANSFER_ENCODING_BINARY));
+
+ /* Adding Content ID header */
+
+ content_id_string = (axis2_char_t *) "<";
+ content_id_string = axutil_stracat(env, content_id_string, content_id);
+ temp_content_id_string = axutil_stracat(env, content_id_string, ">");
+ AXIS2_FREE(env->allocator, content_id_string);
+ content_id_string = temp_content_id_string;
+ AXIOM_MIME_BODY_PART_ADD_HEADER(root_mime_body_part, env,
+ AXIOM_MIME_HEADER_CONTENT_ID, content_id_string);
+
+ /* Now first write the headers needed for SOAP */
+
+ status = axiom_mime_output_write_body_part_to_list(mime_output, env, part_list,
+ root_mime_body_part);
+
+ if(status == AXIS2_FAILURE)
+ {
+ return NULL;
+ }
+
+ /* Now add the SOAP body */
+
+ AXIOM_MIME_BODY_PART_FREE(root_mime_body_part, env);
+ root_mime_body_part = NULL;
+
+ soap_part = axiom_mime_output_part_create(env);
+
+ if(!soap_part)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ soap_part->part = (axis2_byte_t *)soap_body_buffer;
+ soap_part->part_size = (int) axutil_strlen(soap_body_buffer);
+ soap_part->type = AXIOM_MIME_OUTPUT_PART_BUFFER;
+
+ axutil_array_list_add(part_list, env, soap_part);
+
+ /* Now we need to add each binary attachment to the array_list */
+
+ if (binary_node_list)
{
- bytes[i] = (axis2_byte_t) char_buffer[i];
+ int j = 0;
+ axis2_byte_t *temp_stream = NULL;
+ int temp_stream_size = 0;
+ axis2_byte_t *temp = NULL;
+ int temp_size = 0;
+ for (j = 0; j < axutil_array_list_size(binary_node_list, env); j++)
+ {
+ /* Getting each attachment text node from the node list */
+
+ axiom_text_t *text = (axiom_text_t *)
+ axutil_array_list_get(binary_node_list, env, j);
+ if (text)
+ {
+ axiom_mime_body_part_t *mime_body_part = NULL;
+ mime_body_part = axiom_mime_body_part_create_from_om_text(env, text);
+
+ /* Let's fill the mime_output_part arraylist with attachment data*/
+ if(!mime_body_part)
+ {
+ return NULL;
+ }
+
+ status = axiom_mime_output_write_body_part_to_list(mime_output,
+ env, part_list, mime_body_part);
+
+ if(status == AXIS2_FAILURE);
+ {
+ return NULL;
+ }
+
+ AXIOM_MIME_BODY_PART_FREE(mime_body_part, env);
+ mime_body_part = NULL;
+
+ /* Then we need to add a mime_boundary */
+ staus = axiom_mime_output_write_mime_boundary(env, part_list, boundary);
+
+ if(status == AXIS2_FAILURE)
+ {
+ return NULL;
+ }
+ }
+ }
}
- *byte_buffer = bytes;
- *byte_buffer_size = length;
- return AXIS2_SUCCESS;
+
+
+
+ axis2_write_finish_writing_mime(mime_output, env, &boundary_stream,
+ &boundary_stream_size, boundary);
+
+
}
+
+
Propchange: webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/om/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Jun 16 03:23:17 2008
@@ -0,0 +1,2 @@
+.deps
+.libs
Modified: webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/om/om_output.c
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/om/om_output.c?rev=668102&r1=668101&r2=668102&view=diff
==============================================================================
--- webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/om/om_output.c (original)
+++ webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/om/om_output.c Mon Jun 16 03:23:17 2008
@@ -676,3 +676,46 @@
}
return NULL;
}
+
+
+/*axis2_status_t AXIS2_CALL
+axiom_output_flush_to_wire(
+ axiom_output_t * om_output,
+ const axutil_env_t * env,
+ axutil_stream_t *stream)
+{
+ const axis2_char_t *soap_content_type = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ if (om_output->do_optimize)
+ {
+ axis2_byte_t *byte_stream = NULL;
+ axis2_char_t *root_content_id = NULL;
+ axis2_char_t *buffer =
+ (axis2_char_t *) axiom_xml_writer_get_xml(om_output->xml_writer,
+ env);
+ int stream_size = 0;
+ if (om_output->is_soap11)
+ {
+ soap_content_type = AXIOM_SOAP11_CONTENT_TYPE;
+ }
+ else
+ {
+ soap_content_type = AXIOM_SOAP12_CONTENT_TYPE;
+ }
+ om_output->mime_output = axiom_mime_output_create(env);
+ om_output->mime_boundry = axiom_output_get_mime_boundry(om_output, env);
+ root_content_id = axiom_output_get_root_content_id(om_output, env);
+ status = axiom_mime_output_write_to_wire(om_output->mime_output,
+ env, stream,
+ buffer, om_output->binary_node_list,
+ om_output->mime_boundry,
+ om_output->root_content_id,
+ om_output->char_set_encoding,
+ soap_content_type);
+ return status;
+ }
+ return status;
+}*/