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/07/22 10:43:42 UTC

svn commit: r678680 [1/4] - in /webservices/axis2/trunk/c: ./ axiom/include/ axiom/src/attachments/ axiom/src/om/ include/ samples/ samples/client/mtom/ samples/client/mtom/resources/ samples/server/ samples/server/mtom/ src/core/context/ src/core/desc...

Author: manjula
Date: Tue Jul 22 01:43:36 2008
New Revision: 678680

URL: http://svn.apache.org/viewvc?rev=678680&view=rev
Log:
Adding mtom caching supoort for mtom.

Added:
    webservices/axis2/trunk/c/axiom/include/axiom_caching_callback.h
      - copied unchanged from r663049, webservices/axis2/branches/c/post_1_4_mtom/c/axiom/include/axiom_caching_callback.h
    webservices/axis2/trunk/c/axiom/include/axiom_mime_part.h
      - copied unchanged from r674731, webservices/axis2/branches/c/post_1_4_mtom/c/axiom/include/axiom_mime_part.h
    webservices/axis2/trunk/c/axiom/src/attachments/mime_part.c
      - copied, changed from r674731, webservices/axis2/branches/c/post_1_4_mtom/c/axiom/src/attachments/mime_part.c
Removed:
    webservices/axis2/trunk/c/axiom/src/attachments/axiom_mime_output.h
    webservices/axis2/trunk/c/axiom/src/attachments/mime_output.c
Modified:
    webservices/axis2/trunk/c/   (props changed)
    webservices/axis2/trunk/c/axiom/include/axiom_data_handler.h
    webservices/axis2/trunk/c/axiom/include/axiom_mime_parser.h
    webservices/axis2/trunk/c/axiom/include/axiom_output.h
    webservices/axis2/trunk/c/axiom/src/attachments/   (props changed)
    webservices/axis2/trunk/c/axiom/src/attachments/Makefile.am
    webservices/axis2/trunk/c/axiom/src/attachments/axiom_mime_body_part.h
    webservices/axis2/trunk/c/axiom/src/attachments/data_handler.c
    webservices/axis2/trunk/c/axiom/src/attachments/mime_body_part.c
    webservices/axis2/trunk/c/axiom/src/attachments/mime_parser.c
    webservices/axis2/trunk/c/axiom/src/om/   (props changed)
    webservices/axis2/trunk/c/axiom/src/om/om_output.c
    webservices/axis2/trunk/c/include/axis2_const.h
    webservices/axis2/trunk/c/include/axis2_http_client.h
    webservices/axis2/trunk/c/include/axis2_http_sender.h
    webservices/axis2/trunk/c/include/axis2_http_simple_response.h
    webservices/axis2/trunk/c/include/axis2_http_status_line.h
    webservices/axis2/trunk/c/include/axis2_http_transport_utils.h
    webservices/axis2/trunk/c/include/axis2_msg_ctx.h
    webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c
    webservices/axis2/trunk/c/samples/client/mtom/resources/Makefile.am
    webservices/axis2/trunk/c/samples/configure.ac
    webservices/axis2/trunk/c/samples/server/axis2.xml
    webservices/axis2/trunk/c/samples/server/mtom/   (props changed)
    webservices/axis2/trunk/c/samples/server/mtom/mtom.c
    webservices/axis2/trunk/c/src/core/context/msg_ctx.c
    webservices/axis2/trunk/c/src/core/description/   (props changed)
    webservices/axis2/trunk/c/src/core/engine/   (props changed)
    webservices/axis2/trunk/c/src/core/transport/http/common/   (props changed)
    webservices/axis2/trunk/c/src/core/transport/http/common/http_simple_response.c
    webservices/axis2/trunk/c/src/core/transport/http/common/http_status_line.c
    webservices/axis2/trunk/c/src/core/transport/http/common/http_worker.c
    webservices/axis2/trunk/c/src/core/transport/http/common/simple_http_svr_conn.c
    webservices/axis2/trunk/c/src/core/transport/http/sender/   (props changed)
    webservices/axis2/trunk/c/src/core/transport/http/sender/http_client.c
    webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c
    webservices/axis2/trunk/c/src/core/transport/http/sender/http_transport_sender.c
    webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c
    webservices/axis2/trunk/c/src/core/transport/http/util/   (props changed)
    webservices/axis2/trunk/c/src/core/transport/http/util/http_transport_utils.c
    webservices/axis2/trunk/c/util/include/axutil_utils.h
    webservices/axis2/trunk/c/util/src/   (props changed)
    webservices/axis2/trunk/c/util/src/utils.c

Propchange: webservices/axis2/trunk/c/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jul 22 01:43:36 2008
@@ -0,0 +1 @@
+.build.sh.swp

Propchange: webservices/axis2/trunk/c/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Jul 22 01:43:36 2008
@@ -1 +1 @@
-/webservices/axis2/branches/c/post_1_4_mtom/c:1-655428
+/webservices/axis2/branches/c/post_1_4_mtom/c:1-678647

Modified: webservices/axis2/trunk/c/axiom/include/axiom_data_handler.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/include/axiom_data_handler.h?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/include/axiom_data_handler.h (original)
+++ webservices/axis2/trunk/c/axiom/include/axiom_data_handler.h Tue Jul 22 01:43:36 2008
@@ -75,6 +75,29 @@
     /**
      * @param data_handler, a pointer to data handler struct
      * @param env environment, MUST NOT be NULL.
+     * @return bool whether attachment is cached or not
+     */
+    AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+    axiom_data_handler_get_cached(
+        axiom_data_handler_t * data_handler,
+        const axutil_env_t * env);
+	
+    /**
+     * @param data_handler, a pointer to data handler struct
+     * @param env environment, MUST NOT be NULL.
+	 * @param cached, 
+     * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error.
+     */
+    AXIS2_EXTERN void AXIS2_CALL
+    axiom_data_handler_set_cached(
+        axiom_data_handler_t * data_handler,
+        const axutil_env_t * env,
+		axis2_bool_t cached);
+
+
+    /**
+     * @param data_handler, a pointer to data handler struct
+     * @param env environment, MUST NOT be NULL.
      * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error.
      */
     AXIS2_EXTERN axis2_byte_t *AXIS2_CALL
@@ -144,6 +167,16 @@
     /**
      * @param data_handler, a pointer to data handler struct
      * @param env environment, MUST NOT be NULL.
+     * @return file name, in the case of file type data handler.
+     */
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    axiom_data_handler_get_file_name(
+        axiom_data_handler_t * data_handler,
+        const axutil_env_t * env);
+
+    /**
+     * @param data_handler, a pointer to data handler struct
+     * @param env environment, MUST NOT be NULL.
      * @return status code, AXIS2_SUCCESS on success and AXIS2_FAILURE on error.
      */
     AXIS2_EXTERN void AXIS2_CALL
@@ -161,6 +194,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

Modified: webservices/axis2/trunk/c/axiom/include/axiom_mime_parser.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/include/axiom_mime_parser.h?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/include/axiom_mime_parser.h (original)
+++ webservices/axis2/trunk/c/axiom/include/axiom_mime_parser.h Tue Jul 22 01:43:36 2008
@@ -38,8 +38,8 @@
 {
 #endif
 
-#define AXIOM_MIME_PARSER_BUFFER_SIZE (1024 * 1024)
-#define AXIOM_MIME_PARSER_MAX_CHUNK_BUFFERS 1000
+#define AXIOM_MIME_PARSER_BUFFER_SIZE (1024 * 1024/2)
+#define AXIOM_MIME_PARSER_MAX_BUFFERS 1000
 
 #define AXIOM_MIME_PARSER_END_OF_MIME_MAX_COUNT 100
 
@@ -128,7 +128,7 @@
       * @return mime parts as a hash map 
       */
     AXIS2_EXTERN void AXIS2_CALL
-    axiom_mime_parser_set_chunk_buffer_size(
+    axiom_mime_parser_set_buffer_size(
         axiom_mime_parser_t * mime_parser,
         const axutil_env_t * env,
         int size);
@@ -141,11 +141,27 @@
       * @return VOID
       */
     AXIS2_EXTERN void AXIS2_CALL
-    axiom_mime_parser_set_max_chunk_buffers(
+    axiom_mime_parser_set_max_buffers(
         axiom_mime_parser_t * mime_parser,
         const axutil_env_t * env,
         int num);
 
+    
+    /**
+      * Set attachment dir specified in the axis2.xml
+      * @param mime_parser the pointer for the mime parser struct 
+      * @param env Environment. MUST NOT be NULL.
+      * @param attachment_dir is string containg the directory path
+      * @return VOID
+      */
+
+    AXIS2_EXTERN void AXIS2_CALL
+    axiom_mime_parser_set_attachment_dir(
+        axiom_mime_parser_t *mime_parser,
+        const axutil_env_t *env,
+        axis2_char_t *attachment_dir);
+
+
 
 
     /** @} */

Modified: webservices/axis2/trunk/c/axiom/include/axiom_output.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/include/axiom_output.h?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/include/axiom_output.h (original)
+++ webservices/axis2/trunk/c/axiom/include/axiom_output.h Tue Jul 22 01:43:36 2008
@@ -24,6 +24,7 @@
 #include <axutil_env.h>
 #include <axiom_node.h>
 #include <axiom_xml_writer.h>
+#include <axutil_array_list.h>
 
 #ifdef __cplusplus
 extern "C"
@@ -233,12 +234,16 @@
     /**
      *
      */
-    AXIS2_EXTERN axis2_byte_t *AXIS2_CALL
-    axiom_output_flush(
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+        axiom_output_flush(
         axiom_output_t * om_output,
-        const axutil_env_t * env,
-        axis2_byte_t ** output_stream,
-        int *output_stream_size);
+        const axutil_env_t * env);
+
+    AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+    axiom_output_get_mime_parts(
+        axiom_output_t * om_output,
+        const axutil_env_t * env);
+
 
     /** @} */
 

Propchange: webservices/axis2/trunk/c/axiom/src/attachments/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jul 22 01:43:36 2008
@@ -0,0 +1,2 @@
+.deps
+.libs

Modified: webservices/axis2/trunk/c/axiom/src/attachments/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/attachments/Makefile.am?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/attachments/Makefile.am (original)
+++ webservices/axis2/trunk/c/axiom/src/attachments/Makefile.am Tue Jul 22 01:43:36 2008
@@ -1,6 +1,6 @@
 noinst_LTLIBRARIES = libaxis2_attachments.la
 AM_CPPFLAGS = $(CPPFLAGS)
-libaxis2_attachments_la_SOURCES = mime_output.c \
+libaxis2_attachments_la_SOURCES = mime_part.c \
 					data_handler.c \
 					mime_body_part.c \
                     mime_parser.c
@@ -11,5 +11,5 @@
             -I$(top_builddir)/parser \
 			-I ../../../util/include
 
-EXTRA_DIST = axiom_mime_body_part.h axiom_mime_output.h
+EXTRA_DIST = axiom_mime_body_part.h 
 

Modified: webservices/axis2/trunk/c/axiom/src/attachments/axiom_mime_body_part.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/attachments/axiom_mime_body_part.h?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/attachments/axiom_mime_body_part.h (original)
+++ webservices/axis2/trunk/c/axiom/src/attachments/axiom_mime_body_part.h Tue Jul 22 01:43:36 2008
@@ -32,6 +32,8 @@
 #include <axutil_string.h>
 #include <axutil_array_list.h>
 #include <axiom_data_handler.h>
+#include <axiom_text.h>
+#include <axiom_mime_const.h>
 
 #ifdef __cplusplus
 extern "C"
@@ -73,15 +75,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/trunk/c/axiom/src/attachments/data_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/attachments/data_handler.c?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/attachments/data_handler.c (original)
+++ webservices/axis2/trunk/c/axiom/src/attachments/data_handler.c Tue Jul 22 01:43:36 2008
@@ -18,16 +18,32 @@
 #include <axiom_data_handler.h>
 #include <stdio.h>
 #include <sys/stat.h>
+#include <axiom_mime_part.h>
 
 struct axiom_data_handler
 {
+    /* The content type */
     axis2_char_t *mime_type;
+    
+    /* If in a file then the file name*/
     axis2_char_t *file_name;
+
+    /* If it is in a buffer then the buffer */
     axis2_byte_t *buffer;
+
+    /* The length of the buffer */
     int buffer_len;
+
+    /* Is this a data_handler with a file name or a buffer*/
     axiom_data_handler_type_t data_handler_type;
+
+    /* When parsing whether we have cached it or not */
+    axis2_bool_t cached;
 };
 
+
+/* Creates the data_handler. The file name is not mandatory */
+
 AXIS2_EXTERN axiom_data_handler_t *AXIS2_CALL
 axiom_data_handler_create(
     const axutil_env_t *env,
@@ -54,6 +70,7 @@
     data_handler->buffer_len = 0;
     /* By default, a Data Handler is of type Buffer */
     data_handler->data_handler_type = AXIOM_DATA_HANDLER_TYPE_BUFFER;
+    data_handler->cached = AXIS2_FALSE;
 
     if (mime_type)
     {
@@ -128,6 +145,25 @@
     return AXIS2_SUCCESS;
 }
 
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axiom_data_handler_get_cached(
+    axiom_data_handler_t *data_handler,
+    const axutil_env_t *env)
+{
+    return data_handler->cached;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axiom_data_handler_set_cached(
+    axiom_data_handler_t *data_handler,
+    const axutil_env_t *env,
+	axis2_bool_t cached)
+{
+    data_handler->cached = cached;
+}
+
+
 AXIS2_EXTERN axis2_byte_t *AXIS2_CALL
 axiom_data_handler_get_input_stream(
     axiom_data_handler_t *data_handler,
@@ -144,6 +180,11 @@
     return data_handler->buffer_len;
 }
 
+
+/* With MTOM caching support this function is no longer used
+ * Because this will load whole file in to buffer. So for large 
+ * attachment this is not wise */
+
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axiom_data_handler_read_from(
     axiom_data_handler_t *data_handler,
@@ -314,6 +355,12 @@
     return AXIS2_SUCCESS;
 }
 
+/* This function will write the data in the buffer 
+ * to a file. When caching is being used this will 
+ * not be called , because the parser it self cache 
+ * the attachment while parsing */
+
+
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axiom_data_handler_write_to(
     axiom_data_handler_t *data_handler,
@@ -371,3 +418,88 @@
 
     return AXIS2_SUCCESS;
 }
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+axiom_data_handler_get_file_name(
+    axiom_data_handler_t *data_handler,
+    const axutil_env_t *env)
+{
+    if (data_handler->file_name)
+    {
+        return data_handler->file_name;
+    }
+    else
+    {
+        return NULL;
+    }
+}
+
+
+/* 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. In the
+ * case of file the array_list have just the file name and the size. The content
+ * is not loaded to the memory.
+ */
+
+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_part_t *binary_part = NULL;
+    
+    binary_part = axiom_mime_part_create(env);
+    
+    if(!binary_part)
+    {
+        return AXIS2_FAILURE;
+    }    
+    
+    if (data_handler->data_handler_type == AXIOM_DATA_HANDLER_TYPE_BUFFER)
+    {
+        /*binary_part->part = (axis2_byte_t *)axutil_strdup(env, data_handler->buffer);*/
+        binary_part->part = (axis2_byte_t *)AXIS2_MALLOC(env->allocator, 
+            (data_handler->buffer_len) * sizeof(axis2_byte_t));
+        memcpy(binary_part->part, data_handler->buffer, data_handler->buffer_len);
+
+        binary_part->part_size = data_handler->buffer_len;
+        binary_part->type = AXIOM_MIME_PART_BUFFER;
+    }
+
+    /* In the case of file we first calculate the file size
+     * and then add the file name */
+    
+    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 = (axis2_char_t *)axutil_strdup(env, data_handler->file_name);
+            binary_part->part_size = stat_p.st_size;
+            binary_part->type = AXIOM_MIME_PART_FILE;
+        }    
+    }
+    else
+    {
+        /* Data Handler File Name is missing */
+        return AXIS2_FAILURE;
+    }
+
+    /* Finaly we add the binary details to the list */    
+
+    axutil_array_list_add(list, env, binary_part);
+
+    return AXIS2_SUCCESS;
+}

Modified: webservices/axis2/trunk/c/axiom/src/attachments/mime_body_part.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/axiom/src/attachments/mime_body_part.c?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/axiom/src/attachments/mime_body_part.c (original)
+++ webservices/axis2/trunk/c/axiom/src/attachments/mime_body_part.c Tue Jul 22 01:43:36 2008
@@ -16,6 +16,7 @@
  */
 
 #include "axiom_mime_body_part.h"
+#include <axiom_mime_part.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,
@@ -89,6 +155,9 @@
     return;
 }
 
+/* This method will add a mime_header to the hash */
+
+
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axiom_mime_body_part_add_header(
     axiom_mime_body_part_t *mime_body_part,
@@ -117,12 +186,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;
@@ -130,19 +206,21 @@
     axis2_char_t *header_str = NULL;
     axis2_char_t *temp_header_str = NULL;
     int header_str_size = 0;
-    axis2_byte_t *data_handler_stream = NULL;
-    int data_handler_stream_size = 0;
     axis2_status_t status = AXIS2_FAILURE;
-    axis2_byte_t *byte_stream = NULL;
-    int size = 0;
+    axiom_mime_part_t *mime_header_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 +231,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 +260,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_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_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(mime_body_part->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;
 }