axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sam...@apache.org
Subject svn commit: r398083 - in /webservices/axis2/trunk/c: include/ modules/core/transport/http/ modules/xml/attachments/ modules/xml/soap/ samples/ samples/client/mtom/ samples/server/ test/xml/om/ test/xml/soap/
Date Sat, 29 Apr 2006 04:26:00 GMT
Author: samisa
Date: Fri Apr 28 21:25:59 2006
New Revision: 398083

URL: http://svn.apache.org/viewcvs?rev=398083&view=rev
Log:
More changes to get the MTOM working on the server side

Modified:
    webservices/axis2/trunk/c/include/axis2_data_handler.h
    webservices/axis2/trunk/c/include/axis2_http_transport.h
    webservices/axis2/trunk/c/include/axis2_soap.h
    webservices/axis2/trunk/c/include/axis2_soap_builder.h
    webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c
    webservices/axis2/trunk/c/modules/xml/attachments/data_handler.c
    webservices/axis2/trunk/c/modules/xml/attachments/mime_body_part.c
    webservices/axis2/trunk/c/modules/xml/soap/soap_builder.c
    webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c
    webservices/axis2/trunk/c/samples/configure.ac
    webservices/axis2/trunk/c/samples/server/Makefile.am
    webservices/axis2/trunk/c/test/xml/om/test_om.c
    webservices/axis2/trunk/c/test/xml/soap/test_soap.c

Modified: webservices/axis2/trunk/c/include/axis2_data_handler.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_data_handler.h?rev=398083&r1=398082&r2=398083&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_data_handler.h (original)
+++ webservices/axis2/trunk/c/include/axis2_data_handler.h Fri Apr 28 21:25:59 2006
@@ -62,18 +62,39 @@
  */
 struct axis2_data_handler_ops
 {
-	axis2_char_t * (AXIS2_CALL *get_content_type)(axis2_data_handler_t *data_handler, axis2_env_t
**env); 
+	axis2_char_t *(AXIS2_CALL *
+    get_content_type)(axis2_data_handler_t *data_handler, 
+        axis2_env_t **env); 
 	
-	axis2_byte_t * (AXIS2_CALL *get_input_stream)(axis2_data_handler_t *data_handler, axis2_env_t
**env); 
+	axis2_byte_t* (AXIS2_CALL *
+    get_input_stream)(axis2_data_handler_t *data_handler, 
+        axis2_env_t **env); 
 
     axis2_status_t (AXIS2_CALL *
-    write_to)(axis2_data_handler_t *data_handler, axis2_env_t **env, 
-                axis2_byte_t** output_stream, int *output_stream_size);
+    read_from)(axis2_data_handler_t *data_handler, 
+        axis2_env_t **env, 
+        axis2_byte_t** output_stream, 
+        int *output_stream_size);
 
-	/** Deallocate memory
-     * @return status code
-     */
-    axis2_status_t (AXIS2_CALL *free) (axis2_data_handler_t *data_handler, axis2_env_t **env);
+    axis2_status_t (AXIS2_CALL *
+    set_binary_data)(axis2_data_handler_t *data_handler, 
+        axis2_env_t **env, 
+        axis2_byte_t* input_stream, 
+        int input_stream_len);
+
+    axis2_status_t (AXIS2_CALL *
+    write_to)(axis2_data_handler_t *data_handler, 
+        axis2_env_t **env);
+
+    axis2_status_t ( AXIS2_CALL *
+    set_file_name )(
+        axis2_data_handler_t *data_handler, 
+        axis2_env_t **env, 
+        axis2_char_t* file_name);
+    
+    axis2_status_t (AXIS2_CALL *
+    free) (axis2_data_handler_t *data_handler, 
+        axis2_env_t **env);
 };
 
 /** 
@@ -108,8 +129,17 @@
 #define AXIS2_DATA_HANDLER_GET_INPUT_STREAM(data_handler, env) \
     ((data_handler)->ops->get_input_stream (data_handler, env))
 
-#define AXIS2_DATA_HANDLER_WRITE_TO(data_handler, env, output_stream, output_stream_size)
\
-    ((data_handler)->ops->write_to (data_handler, env, output_stream, output_stream_size))
+#define AXIS2_DATA_HANDLER_READ_FROM(data_handler, env, output_stream, output_stream_size)
\
+    ((data_handler)->ops->read_from (data_handler, env, output_stream, output_stream_size))
+
+#define AXIS2_DATA_HANDLER_SET_BINARY_DATA(data_handler, env, input_stream, input_stream_size)
\
+    ((data_handler)->ops->set_binary_data (data_handler, env, input_stream, input_stream_size))
+
+#define AXIS2_DATA_HANDLER_WRITE_TO(data_handler, env) \
+    ((data_handler)->ops->write_to (data_handler, env))
+
+#define AXIS2_DATA_HANDLER_SET_FILE_NAME(data_handler, env, file_name) \
+    ((data_handler)->ops->set_file_name (data_handler, env, file_name))
 
 /*************************** End of function macros ***************************/
 

Modified: webservices/axis2/trunk/c/include/axis2_http_transport.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_http_transport.h?rev=398083&r1=398082&r2=398083&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_http_transport.h (original)
+++ webservices/axis2/trunk/c/include/axis2_http_transport.h Fri Apr 28 21:25:59 2006
@@ -125,6 +125,12 @@
     #define AXIS2_HTTP_HEADER_CONTENT_TYPE "Content-Type"
     
     /**
+     * HEADER_CONTENT_TYPE
+     */
+    #define AXIS2_HTTP_HEADER_CONTENT_TYPE_MIME_BOUNDARY "boundary"
+    
+    /**
+    /**
      * HEADER_CONTENT_TRANSFER_ENCODING
      */
     #define AXIS2_HTTP_HEADER_CONTENT_TRANSFER_ENCODING \

Modified: webservices/axis2/trunk/c/include/axis2_soap.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_soap.h?rev=398083&r1=398082&r2=398083&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_soap.h (original)
+++ webservices/axis2/trunk/c/include/axis2_soap.h Fri Apr 28 21:25:59 2006
@@ -161,6 +161,11 @@
 
 #define AXIS2_SOAP_FAULT_CODE_RECEIVER ""
 
+/* MTOM related  */
+
+#define AXIS2_XOP_NAMESPACE_URI "http://www.w3.org/2004/08/xop/include"
+
+#define AXIS2_XOP_INCLUDE "Include"
 /** @} */
 
 #ifdef __cplusplus

Modified: webservices/axis2/trunk/c/include/axis2_soap_builder.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_soap_builder.h?rev=398083&r1=398082&r2=398083&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_soap_builder.h (original)
+++ webservices/axis2/trunk/c/include/axis2_soap_builder.h Fri Apr 28 21:25:59 2006
@@ -89,6 +89,11 @@
                                            axis2_env_t **env,
                                            axis2_om_node_t *om_node,
                                            axis2_bool_t is_soap_element);
+        axis2_status_t (AXIS2_CALL *
+        set_mime_body_parts)
+                                    (axis2_soap_builder_t *builder, 
+                                     axis2_env_t **env,
+                                     axis2_hash_t *map); 
 };
                                                       
 
@@ -148,6 +153,9 @@
         
 #define AXIS2_SOAP_BUILDER_PROCESS_NAMESPACE_DATA(builder, env, om_node, is_soap_element)
\
         ((builder)->ops->process_namespace_data(builder, env, om_node, is_soap_element))
+        
+#define AXIS2_SOAP_BUILDER_SET_MIME_BODY_PARTS(builder, env, map) \
+        ((builder)->ops->set_mime_body_parts(builder, env, map))
         
 /** @} */
 #ifdef __cplusplus

Modified: webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c?rev=398083&r1=398082&r2=398083&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c Fri Apr 28
21:25:59 2006
@@ -32,6 +32,8 @@
 #include <axis2_http_header.h>
 #include <axis2_property.h>
 
+#define AXIS2_MIME_BOUNDARY_BYTE 45
+
 /***************************** Function headers *******************************/
 
 AXIS2_DECLARE(axis2_status_t)
@@ -97,6 +99,9 @@
 AXIS2_DECLARE(axis2_soap_envelope_t*)
 axis2_http_transport_utils_create_soap_msg(axis2_env_t **env, 
                         axis2_msg_ctx_t *msg_ctx, axis2_char_t *soap_ns_uri);
+AXIS2_DECLARE(axis2_char_t*)
+axis2_http_transport_utils_get_value_from_content_type(axis2_env_t **env, 
+						axis2_char_t *content_type, axis2_char_t *key);
 /***************************** End of function headers ************************/
 
 AXIS2_DECLARE(axis2_status_t ) 
@@ -121,6 +126,7 @@
 	axis2_soap_body_t *soap_body = NULL;
     axis2_property_t *property = NULL;
     axis2_status_t status = AXIS2_FAILURE;
+    axis2_hash_t *binary_data_map = NULL;
 	
     AXIS2_PARAM_CHECK((*env)->error, msg_ctx, AXIS2_FAILURE);
 	AXIS2_PARAM_CHECK((*env)->error, in_stream, AXIS2_FAILURE);
@@ -182,6 +188,343 @@
 			}
 		}
 	}
+    
+    if (NULL != strstr(content_type, AXIS2_HTTP_HEADER_ACCEPT_MULTIPART_RELATED))
+    {
+        /* get mime boundry */
+        axis2_char_t *mime_boundary = 
+            axis2_http_transport_utils_get_value_from_content_type(env, 
+                content_type, AXIS2_HTTP_HEADER_CONTENT_TYPE_MIME_BOUNDARY);
+
+        if (mime_boundary)
+        {
+            axis2_char_t *buffer = NULL;
+            int size = 1024;
+            int len = 0;
+            axis2_char_t *root_mime = NULL;
+            int root_mime_len = 0;
+            axis2_char_t *soap_body_str = NULL;
+            int soap_body_len = 0;
+            axis2_char_t *body_mime = NULL;
+            int body_mime_len = 0;
+            axis2_char_t *mime_binary = NULL;
+            int mime_binary_len = 0;
+            axis2_char_t *pos = NULL;
+            
+            buffer = AXIS2_MALLOC((*env)->allocator, sizeof(axis2_char_t) * (size + 1));
+           
+            do 
+            {    
+                len = axis2_http_transport_utils_on_data_request(buffer, size, (void*)&callback_ctx);
+                if (len > 0)
+                {
+                    axis2_char_t *temp_root_mime = root_mime;
+                    root_mime = AXIS2_MALLOC((*env)->allocator, 
+                        sizeof(char) * (root_mime_len + len + 1));
+                    if (root_mime)
+                    {
+                        if (temp_root_mime)
+                        {
+                            memcpy(root_mime, temp_root_mime, root_mime_len);
+                            AXIS2_FREE((*env)->allocator, temp_root_mime);
+                            temp_root_mime = NULL;
+                        }
+                        
+                        memcpy(root_mime + root_mime_len, buffer, len);
+                        root_mime_len += len;
+                        root_mime[root_mime_len] = '\0';
+
+                        pos = AXIS2_STRSTR(root_mime, "\r\n\r\n");
+                        if (pos)
+                        {
+                            if (root_mime_len > (pos - root_mime + 4))
+                            {
+                                soap_body_len = root_mime_len - (pos - root_mime + 4);
+                                soap_body_str = AXIS2_MALLOC((*env)->allocator,
+                                                sizeof(char) * (soap_body_len + 1));
+                                memcpy(soap_body_str, pos + 4, soap_body_len);
+                                soap_body_str[soap_body_len] = '\0';
+                                *pos = '\0';
+                            }
+                        }
+                    }
+                }
+                
+            } while(!pos && len > 0);
+
+            pos = NULL;
+            len = 0;
+
+            do 
+            {
+                if (soap_body_str)
+                {
+                    pos = AXIS2_STRSTR(soap_body_str, mime_boundary);
+                }
+                
+                if (pos)
+                {
+                    pos -= 2;
+                    body_mime_len = soap_body_len - (pos - soap_body_str);
+                    body_mime = AXIS2_MALLOC((*env)->allocator,
+                                    sizeof(char) * (body_mime_len + 1));
+                    memcpy(body_mime, pos, body_mime_len);
+                    body_mime[body_mime_len] = '\0';
+                    
+                    *(pos)  = '\0';
+                    soap_body_len = (pos - soap_body_str);
+                }
+                else
+                {
+                    len = axis2_http_transport_utils_on_data_request(buffer, size, (void*)&callback_ctx);
+                    if (len > 0)
+                    {
+                        axis2_char_t *temp_soap_body = soap_body_str;
+                        soap_body_str = AXIS2_MALLOC((*env)->allocator, 
+                            sizeof(char) * (soap_body_len + len + 1));
+                        if (soap_body_str)
+                        {
+                            if (temp_soap_body)
+                            {
+                                memcpy(soap_body_str, temp_soap_body, soap_body_len);
+                                AXIS2_FREE((*env)->allocator, temp_soap_body);
+                                temp_soap_body = NULL;
+                            }
+                            
+                            memcpy(soap_body_str + soap_body_len, buffer, len);
+                            soap_body_len += len;
+                            soap_body_str[soap_body_len] = '\0';
+                        }
+                     }
+                 }
+            } while(!pos && len > 0);
+            
+            pos = NULL;
+            len = 0;
+
+            do 
+            {
+                if (body_mime)
+                {
+                    pos = AXIS2_STRSTR(body_mime, "\r\n\r\n");
+                }
+                
+                if (pos)
+                {
+                    if (body_mime_len > (pos - body_mime + 4))
+                    {
+                        mime_binary_len = body_mime_len - (pos - body_mime + 4);
+                        mime_binary = AXIS2_MALLOC((*env)->allocator,
+                                        sizeof(char) * (mime_binary_len + 1));
+                        memcpy(mime_binary, pos + 4, mime_binary_len);
+                        mime_binary[mime_binary_len] = '\0';
+                        *pos = '\0';
+                    }
+                }
+                else
+                {
+                    len = axis2_http_transport_utils_on_data_request(buffer, size, (void*)&callback_ctx);
+                    if (len > 0)
+                    {
+                        axis2_char_t *temp_body_mime = body_mime;
+                        body_mime = AXIS2_MALLOC((*env)->allocator, 
+                            sizeof(char) * (body_mime_len + len + 1));
+                        if (body_mime)
+                        {
+                            if (temp_body_mime)
+                            {
+                                memcpy(body_mime, temp_body_mime, body_mime_len);
+                                AXIS2_FREE((*env)->allocator, temp_body_mime);
+                                temp_body_mime = NULL;
+                            }
+                            
+                            memcpy(body_mime + body_mime_len, buffer, len);
+                            body_mime_len += len;
+                            body_mime[body_mime_len] = '\0';
+                        }
+                     }
+                }
+            } while(!pos && len > 0);
+
+
+            /* TODO: need to address the ultiple attachment case */
+            pos = NULL;
+            len = 0;
+            do 
+            {
+                axis2_char_t *old_pos = NULL;
+                if (mime_binary)
+                {
+                    old_pos = mime_binary;
+                    axis2_char_t *temp_pos = NULL;
+                    do
+                    {
+                        
+                        pos = memchr(old_pos, AXIS2_MIME_BOUNDARY_BYTE, 
+                            (mime_binary_len - (old_pos - mime_binary)));
+                        if (!pos)
+                            break;
+                        else
+                        {
+                            old_pos = pos + 1;
+                            /*printf("pos %c\n", *pos);
+                            printf("pos + 1 %c\n", *(pos + 1));*/
+                            if (old_pos - mime_binary > mime_binary_len)
+                            {
+                                pos = NULL;
+                                break;
+                            }
+                            temp_pos = AXIS2_STRSTR(pos + 1, mime_boundary);
+                        }
+                    } while ( *(pos + 1) != AXIS2_MIME_BOUNDARY_BYTE || temp_pos != pos +
2);
+
+                    if ( pos && *(pos + 1) == AXIS2_MIME_BOUNDARY_BYTE &&
temp_pos == pos + 2)
+                    {
+                        printf("\nMIME end found\n");
+                        printf ("mime_binary_len %d\n", mime_binary_len);
+                        mime_binary_len = pos - mime_binary;
+                        printf ("mime_binary_len %d\n", mime_binary_len);
+                    }
+                    else
+                        pos = NULL;
+                }
+
+                if (pos)
+                {
+                    /*if (*(pos + 1) == AXIS2_MIME_BOUNDARY_BYTE)
+                    {
+                        axis2_char_t *temp_pos = NULL;
+                        temp_pos = AXIS2_STRSTR(pos + 1, mime_boundary);
+                        
+                        if (temp_pos)
+                            printf("temp_pos + 1 %c\n", *(temp_pos + 1));
+                        
+                        if (temp_pos == pos + 2 )
+                        {
+                            printf("\nMIME end found\n");
+                            printf ("mime_binary_len %d\n", mime_binary_len);
+                            mime_binary_len = pos - mime_binary;
+                            printf ("mime_binary_len %d\n", mime_binary_len);
+                        }
+                        else
+                        {
+                            pos = NULL;
+                        }
+                    }
+                    else
+                    {
+                        pos = NULL;
+                    }*/
+                    
+                    /*if (body_mime_len > (pos - body_mime + 4))
+                    {
+                        mime_binary_len = body_mime_len - (pos - body_mime + 4);
+                        mime_binary = AXIS2_MALLOC((*env)->allocator,
+                                        sizeof(char) * (mime_binary_len + 1));
+                        memcpy(mime_binary, pos + 4, mime_binary_len);
+                        mime_binary[mime_binary_len] = '\0';
+                        *pos = '\0';
+                    }*/
+                }
+                
+                if (!pos)
+                {
+                    len = axis2_http_transport_utils_on_data_request(buffer, size, (void*)&callback_ctx);
+                    if (len > 0)
+                    {
+                        axis2_char_t *temp_mime_binary = mime_binary;
+                        mime_binary = AXIS2_MALLOC((*env)->allocator, 
+                            sizeof(char) * (mime_binary_len + len + 1));
+                        if (mime_binary)
+                        {
+                            if (temp_mime_binary)
+                            {
+                                memcpy(mime_binary, temp_mime_binary, mime_binary_len);
+                                AXIS2_FREE((*env)->allocator, temp_mime_binary);
+                                temp_mime_binary = NULL;
+                            }
+                            
+                            memcpy(mime_binary + mime_binary_len, buffer, len);
+                            mime_binary_len += len;
+                            mime_binary[mime_binary_len] = '\0';
+                        }
+                     }
+                }
+            
+            } while(!pos && len > 0);
+
+            printf("mime_boundary %s\n", mime_boundary);
+            printf("\nroot_mime %s\n", root_mime);
+            printf("body_mime %s\n", body_mime);
+            printf("\nsoap_body %s..............\n soap_body_len %d \n", soap_body_str, soap_body_len);
+            if (soap_body_str) 
+            {
+                /* create a basic stream with soap string to pull SOAP */
+                axis2_stream_t *stream = axis2_stream_create_basic(env);
+                if (stream)
+                {
+                    AXIS2_STREAM_WRITE(stream, env, soap_body_str, soap_body_len);
+                    callback_ctx.in_stream = stream;
+                    callback_ctx.chunked_stream = NULL;
+                    callback_ctx.content_length = soap_body_len;
+                    callback_ctx.unread_len = soap_body_len;
+                }
+                
+                /* data handler hash map */
+                binary_data_map = axis2_hash_make(env);
+                if (binary_data_map)
+                {
+                    /* get MIME ID */
+                    axis2_char_t *id = NULL;
+                    id = AXIS2_STRSTR(body_mime, "content-id");
+                    if (id)
+                    {
+                        id += AXIS2_STRLEN("content-id");
+                        while (id && *id && *id != ':')
+                            id++;
+                        if (id)
+                        {
+                            while (id && *id && *id != '<')
+                                id++;
+                            id++;
+                            if (id)
+                            {
+                                axis2_char_t *pos = NULL;
+                                pos = AXIS2_STRSTR(id, ">");
+                                if (pos)
+                                {
+                                    axis2_char_t *mime_id = NULL;
+                                    int mime_id_len = 0;
+                                    mime_id_len = pos - id;
+                                    mime_id = AXIS2_MALLOC((*env)->allocator, 
+                                        sizeof(axis2_char_t) * mime_id_len + 1);
+                                    if (mime_id)
+                                    {
+                                        axis2_data_handler_t *data_handler = NULL;
+                                        memcpy(mime_id, id, mime_id_len);
+                                        mime_id[mime_id_len] = '\0';
+                                        data_handler = axis2_data_handler_create(env, NULL,
NULL);
+                                        AXIS2_DATA_HANDLER_SET_BINARY_DATA(data_handler,
env,
+                                            mime_binary, mime_binary_len);              
                         
+                                        axis2_hash_set(binary_data_map, mime_id,
+                                            AXIS2_HASH_KEY_STRING, data_handler);       
                                
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+                
+                
+            }
+        }
+    }
+    
+
+    /*TODO for MTOM:create a basic stream
+    set callback_ctx.in_stream to this basic stream
+    make callback_ctx.chunked_stream null but keep the referance */
+
 	AXIS2_MSG_CTX_SET_WSA_ACTION(msg_ctx, env, soap_action_header);
 	AXIS2_MSG_CTX_SET_SOAP_ACTION(msg_ctx, env, soap_action_header);
 	AXIS2_MSG_CTX_SET_TO(msg_ctx, env, axis2_endpoint_ref_create(env, 
@@ -212,6 +555,7 @@
 		xml_reader = NULL;
 		return AXIS2_FAILURE;
 	}
+
 	if(NULL != strstr(content_type, AXIS2_HTTP_HEADER_ACCEPT_APPL_SOAP))
 	{
 		is_soap11 = AXIS2_FALSE;
@@ -226,6 +570,7 @@
 			xml_reader = NULL;
 			return AXIS2_FAILURE;
 		}
+
 		soap_envelope = AXIS2_SOAP_BUILDER_GET_SOAP_ENVELOPE(soap_builder,
 					env);
 		if(NULL == soap_envelope)
@@ -288,6 +633,13 @@
         }
 		 		
 	}
+    
+    if (binary_data_map)
+    {
+        AXIS2_SOAP_BUILDER_SET_MIME_BODY_PARTS(soap_builder, env, 
+            binary_data_map);
+    }
+        
 	/* xml_char_set = AXIS2_OM_DOCUMENT_GET_CHARSET_ENC(
 	 *					AXIS2_OM_STAX_BUILDER_GET_DOCUMENT(env om_builder),
 	 *					env);
@@ -886,6 +1238,7 @@
                 ((axis2_callback_info_t*)ctx)->unread_len -= len;
             }            
         }
+        printf ("\n\n***************************\nbuffer %s\nlen %d\n\n", buffer, len);
         return len;
     }
 	return 0;	
@@ -1042,3 +1395,46 @@
      */
     return NULL;
 }
+
+
+AXIS2_DECLARE(axis2_char_t*)
+axis2_http_transport_utils_get_value_from_content_type(axis2_env_t **env, 
+						axis2_char_t *content_type, axis2_char_t *key)
+{
+	axis2_char_t *tmp = NULL;
+	axis2_char_t *tmp_content_type = NULL;
+	axis2_char_t *tmp2 = NULL;
+	
+	AXIS2_ENV_CHECK(env, NULL);
+	AXIS2_PARAM_CHECK((*env)->error, content_type, NULL);
+    AXIS2_PARAM_CHECK((*env)->error, key, NULL);
+	
+	tmp_content_type = AXIS2_STRDUP(content_type, env);
+	if(NULL == tmp_content_type)
+	{
+		return NULL;
+	}
+	tmp = strstr(tmp_content_type, key);
+	if(NULL == tmp)
+	{
+        AXIS2_FREE((*env)->allocator, tmp_content_type);
+		return NULL;
+	}
+
+	tmp = strchr(tmp, '=');
+	tmp2 = strchr(tmp, ';');
+	
+    if(NULL != tmp2)
+	{
+		*tmp2 = '\0';
+	}
+	if(NULL == tmp)
+	{
+        AXIS2_FREE((*env)->allocator, tmp_content_type);
+		return NULL;
+	}
+	tmp2 =  AXIS2_STRDUP(tmp + 1, env);
+	AXIS2_FREE((*env)->allocator, tmp_content_type);
+	return tmp2;
+}
+

Modified: webservices/axis2/trunk/c/modules/xml/attachments/data_handler.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/attachments/data_handler.c?rev=398083&r1=398082&r2=398083&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/attachments/data_handler.c (original)
+++ webservices/axis2/trunk/c/modules/xml/attachments/data_handler.c Fri Apr 28 21:25:59 2006
@@ -22,6 +22,8 @@
 	axis2_data_handler_t data_handler;
 	axis2_char_t* mime_type;
     axis2_char_t* file_name;
+    axis2_byte_t* buffer;
+    int buffer_len;
 } axis2_data_handler_impl_t;
 
 
@@ -40,9 +42,20 @@
 axis2_data_handler_get_input_stream (axis2_data_handler_t *data_handler, axis2_env_t **env);

 
 axis2_status_t AXIS2_CALL
-axis2_data_handler_write_to(axis2_data_handler_t *data_handler, axis2_env_t **env, 
+axis2_data_handler_read_from(axis2_data_handler_t *data_handler, axis2_env_t **env, 
                                 axis2_byte_t** output_stream, int *output_stream_size);
 
+axis2_status_t AXIS2_CALL
+axis2_data_handler_set_binary_data(axis2_data_handler_t *data_handler, axis2_env_t **env,

+                                axis2_byte_t* input_stream, int input_stream_len);
+
+axis2_status_t AXIS2_CALL
+axis2_data_handler_write_to(axis2_data_handler_t *data_handler, axis2_env_t **env);
+
+axis2_status_t AXIS2_CALL
+axis2_data_handler_set_file_name(axis2_data_handler_t *data_handler, axis2_env_t **env, 
+                                axis2_char_t* file_name);
+
 /************************** End of Function headers ************************/
 
 AXIS2_DECLARE(axis2_data_handler_t *)
@@ -63,6 +76,8 @@
     data_handler_impl->data_handler.ops = NULL;
     data_handler_impl->mime_type = NULL;
     data_handler_impl->file_name = NULL;
+    data_handler_impl->buffer = NULL;
+    data_handler_impl->buffer_len = 0;
 
     if (mime_type)
     {
@@ -97,7 +112,10 @@
 	data_handler_impl->data_handler.ops->free =  axis2_data_handler_free;
     data_handler_impl->data_handler.ops->get_content_type = axis2_data_handler_get_content_type;
     data_handler_impl->data_handler.ops->get_input_stream = axis2_data_handler_get_input_stream;
+    data_handler_impl->data_handler.ops->read_from = axis2_data_handler_read_from;
     data_handler_impl->data_handler.ops->write_to = axis2_data_handler_write_to;
+    data_handler_impl->data_handler.ops->set_binary_data = axis2_data_handler_set_binary_data;
+    data_handler_impl->data_handler.ops->set_file_name = axis2_data_handler_set_file_name;
 	return &(data_handler_impl->data_handler);
 }
 
@@ -143,7 +161,7 @@
 }
 
 axis2_status_t AXIS2_CALL
-axis2_data_handler_write_to(axis2_data_handler_t *data_handler, axis2_env_t **env, 
+axis2_data_handler_read_from(axis2_data_handler_t *data_handler, axis2_env_t **env, 
 							axis2_byte_t** output_stream, int *output_stream_size)
 {
     axis2_data_handler_impl_t *data_handler_impl = NULL;
@@ -256,3 +274,83 @@
 	
     return AXIS2_SUCCESS;
 }
+
+axis2_status_t AXIS2_CALL
+axis2_data_handler_set_binary_data(axis2_data_handler_t *data_handler, axis2_env_t **env,

+                                axis2_byte_t* input_stream, int input_stream_len)
+{
+    axis2_data_handler_impl_t *data_handler_impl = NULL;
+    
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    data_handler_impl = AXIS2_INTF_TO_IMPL(data_handler);
+    
+    data_handler_impl->buffer = input_stream;
+    data_handler_impl->buffer_len = input_stream_len;
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_data_handler_write_to(axis2_data_handler_t *data_handler, axis2_env_t **env)
+{
+    axis2_data_handler_impl_t *data_handler_impl = NULL;
+    
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    data_handler_impl = AXIS2_INTF_TO_IMPL(data_handler);
+    
+    if (data_handler_impl->file_name)
+    {
+        FILE *f = NULL;
+        axis2_byte_t *byte_stream = NULL;
+        axis2_byte_t *temp_byte_stream = NULL;
+        axis2_byte_t *read_stream = NULL;
+        int byte_stream_size = 0;
+        int temp_byte_stream_size = 0;
+        int read_stream_size = 0;
+        int count = 0;
+        
+        f = fopen(data_handler_impl->file_name, "wb");
+        if (!f)
+            return AXIS2_FAILURE;
+            
+        count = fwrite(data_handler_impl->buffer, 1, data_handler_impl->buffer_len,
f);
+        
+        if (ferror(f) != 0)
+        {
+            /*TODO : need to set the correct error code */
+            return AXIS2_FAILURE;
+        }
+        fclose(f);
+    }
+
+    return AXIS2_SUCCESS;        
+}
+
+axis2_status_t AXIS2_CALL
+axis2_data_handler_set_file_name(axis2_data_handler_t *data_handler, axis2_env_t **env, 
+                                axis2_char_t* file_name)
+{
+    axis2_data_handler_impl_t *data_handler_impl = NULL;
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    
+    data_handler_impl = AXIS2_INTF_TO_IMPL(data_handler);
+    
+    if(data_handler_impl->file_name)
+    {
+        AXIS2_FREE((*env)->allocator, data_handler_impl->file_name);
+        data_handler_impl->file_name = NULL;
+    }
+    
+    if (file_name)
+    {
+        data_handler_impl->file_name = AXIS2_STRDUP(file_name, env);
+        if (!(data_handler_impl->file_name))
+        {
+            axis2_data_handler_free(&(data_handler_impl->data_handler), env);
+            AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+            return AXIS2_FAILURE;
+        }
+    }
+    
+    return AXIS2_SUCCESS;
+}
+

Modified: webservices/axis2/trunk/c/modules/xml/attachments/mime_body_part.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/attachments/mime_body_part.c?rev=398083&r1=398082&r2=398083&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/attachments/mime_body_part.c (original)
+++ webservices/axis2/trunk/c/modules/xml/attachments/mime_body_part.c Fri Apr 28 21:25:59
2006
@@ -193,7 +193,7 @@
     */
     if (mime_body_part_impl->data_handler)
     {
-        status = AXIS2_DATA_HANDLER_WRITE_TO(mime_body_part_impl->data_handler, env,
+        status = AXIS2_DATA_HANDLER_READ_FROM(mime_body_part_impl->data_handler, env,
                     &data_handler_stream, &data_handler_stream_size);
         if (status == AXIS2_FAILURE)
             return AXIS2_FAILURE;

Modified: webservices/axis2/trunk/c/modules/xml/soap/soap_builder.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/xml/soap/soap_builder.c?rev=398083&r1=398082&r2=398083&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/xml/soap/soap_builder.c (original)
+++ webservices/axis2/trunk/c/modules/xml/soap/soap_builder.c Fri Apr 28 21:25:59 2006
@@ -62,6 +62,8 @@
     int last_node_status;
     
     axis2_bool_t  done;
+
+    axis2_hash_t *mime_body_parts;
     
 }axis2_soap_builder_impl_t;
 
@@ -161,7 +163,11 @@
 int AXIS2_CALL
 axis2_soap_builder_get_soap_version (axis2_soap_builder_t *builder, 
                              axis2_env_t **env);                                        
                                                                          
-
+axis2_status_t AXIS2_CALL 
+axis2_soap_builder_set_mime_body_parts
+                            (axis2_soap_builder_t *builder, 
+                             axis2_env_t **env,
+                             axis2_hash_t *map); 
 /***************** function implementations ***********************************/
 
 AXIS2_DECLARE(axis2_soap_builder_t *)
@@ -199,6 +205,7 @@
     builder_impl->envelope_ns = NULL;
     builder_impl->soap_envelope = NULL;
     builder_impl->soap_message = NULL;
+    builder_impl->mime_body_parts = NULL;
 
     builder_impl->soap_builder.ops = (axis2_soap_builder_ops_t*)
             AXIS2_MALLOC((*env)->allocator, sizeof(axis2_soap_builder_ops_t));
@@ -229,6 +236,8 @@
             axis2_soap_builder_get_soap_version;
     builder_impl->soap_builder.ops->process_namespace_data =
             axis2_soap_builder_process_namespace_data;
+    builder_impl->soap_builder.ops->set_mime_body_parts =
+            axis2_soap_builder_set_mime_body_parts;
     
     status = axis2_soap_builder_identify_soap_version(&(builder_impl->soap_builder),
env, soap_version);
     if(status == AXIS2_FAILURE)
@@ -476,7 +485,55 @@
     ele_localname = AXIS2_OM_ELEMENT_GET_LOCALNAME(om_element, env);
     if(!ele_localname)
         return AXIS2_FAILURE;
-    
+   
+    /* start: handle MTOM stuff */
+    if (AXIS2_STRCMP(ele_localname, AXIS2_XOP_INCLUDE) == 0)
+    {
+        axis2_om_namespace_t *ns = NULL;
+        ns = AXIS2_OM_ELEMENT_GET_NAMESPACE(om_element, env, om_element_node);
+        if (ns)
+        {
+            axis2_char_t *uri = AXIS2_OM_NAMESPACE_GET_URI(ns, env);
+            if (uri)
+            {
+                if (AXIS2_STRCMP(uri, AXIS2_XOP_NAMESPACE_URI) == 0)
+                {
+                    axis2_qname_t *qname = NULL;
+                    qname = axis2_qname_create(env, "href", NULL, NULL);
+                    if (qname)
+                    {
+                        axis2_char_t *id = NULL;
+                        id = AXIS2_OM_ELEMENT_GET_ATTRIBUTE_VALUE(om_element, env, qname);
                       
+                        if (id)
+                        {
+                            axis2_char_t *pos = NULL;
+                            pos = AXIS2_STRSTR(id, "cid:");
+                            if (pos)
+                            {
+                                axis2_data_handler_t *data_handler = NULL;
+                                id += 4;
+                                if (builder_impl->mime_body_parts)
+                                {
+                                    data_handler = (axis2_data_handler_t *)axis2_hash_get(
+                                        builder_impl->mime_body_parts, 
+                                        (void*)id, AXIS2_HASH_KEY_STRING);
+                                    if (data_handler)
+                                    {
+                                        axis2_om_text_t *data_text = NULL;
+                                        axis2_om_node_t *data_om_node = NULL;
+                                        data_text = axis2_om_text_create_with_data_handler(
+                                            env, om_element_node, data_handler, &data_om_node);
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+    /* end: handle MTOM stuff */
+   
     if(parent)
     {
         /** a parent node exist , so not soap envelope element */
@@ -876,6 +933,17 @@
     AXIS2_ENV_CHECK(env, AXIS2_FALSE);
      builder_impl = AXIS2_INTF_TO_IMPL(builder);
     return builder_impl->soap_version ;
+}
+
+axis2_status_t AXIS2_CALL 
+axis2_soap_builder_set_mime_body_parts
+                            (axis2_soap_builder_t *builder, 
+                             axis2_env_t **env,
+                             axis2_hash_t *map)
+{
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_INTF_TO_IMPL(builder)->mime_body_parts = map;
+    return AXIS2_SUCCESS;
 }
 
 static axis2_status_t

Modified: webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c?rev=398083&r1=398082&r2=398083&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c (original)
+++ webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c Fri Apr 28 21:25:59 2006
@@ -86,7 +86,7 @@
     
     /* Set end point reference of mtom service */
     address = "http://localhost:9090/axis2/services/mtomSample";
-    wsa_action = "http://localhost:9090/axis2/services/mtom/mtomString";
+    wsa_action = "http://localhost:9090/axis2/services/mtom/mtomSample";
     if (argc > 1 )
         address = argv[1];
     if (AXIS2_STRCMP(address, "-h") == 0)
@@ -149,7 +149,7 @@
     svc = AXIS2_CONF_GET_SVC(conf, &env, "mtom");
     if (svc)
     {
-        op = AXIS2_SVC_GET_OP_WITH_NAME(svc, &env, "mtomString");
+        op = AXIS2_SVC_GET_OP_WITH_NAME(svc, &env, "mtomSample");
         if (op)
         {
             AXIS2_OP_SET_MSG_EXCHANGE_PATTERN(op, &env, AXIS2_MEP_URI_OUT_IN);
@@ -164,7 +164,7 @@
         axis2_qname_t *op_qname = NULL;
         axis2_qname_t *svc_qname = axis2_qname_create(&env, "mtom", NULL, NULL);
         svc = axis2_svc_create_with_qname(&env, svc_qname);
-        op_qname = axis2_qname_create(&env, "mtomString", NULL, NULL);
+        op_qname = axis2_qname_create(&env, "mtomSample", NULL, NULL);
         op = axis2_op_create_with_qname(&env, op_qname);
         AXIS2_OP_SET_MSG_EXCHANGE_PATTERN(op, &env, AXIS2_MEP_URI_OUT_IN);
         AXIS2_SVC_ADD_OP(svc, &env, op);

Modified: webservices/axis2/trunk/c/samples/configure.ac
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/samples/configure.ac?rev=398083&r1=398082&r2=398083&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/configure.ac (original)
+++ webservices/axis2/trunk/c/samples/configure.ac Fri Apr 28 21:25:59 2006
@@ -67,6 +67,7 @@
     server/math/Makefile \
     server/notify/Makefile \
     server/sg_math/Makefile \
+    server/mtom/Makefile \
     client/Makefile \
     client/echo/Makefile \
     client/math/Makefile \

Modified: webservices/axis2/trunk/c/samples/server/Makefile.am
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/samples/server/Makefile.am?rev=398083&r1=398082&r2=398083&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/server/Makefile.am (original)
+++ webservices/axis2/trunk/c/samples/server/Makefile.am Fri Apr 28 21:25:59 2006
@@ -1,5 +1,5 @@
 samplesdir=$(prefix)/samples/server
-SUBDIRS = echo math notify sg_math
+SUBDIRS = echo math notify sg_math mtom
 EXTRA_DIST = axis2.xml
 samples_DATA= axis2.log  axis2.xml  Makefile.am Makefile.in
 

Modified: webservices/axis2/trunk/c/test/xml/om/test_om.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/test/xml/om/test_om.c?rev=398083&r1=398082&r2=398083&view=diff
==============================================================================
--- webservices/axis2/trunk/c/test/xml/om/test_om.c (original)
+++ webservices/axis2/trunk/c/test/xml/om/test_om.c Fri Apr 28 21:25:59 2006
@@ -42,7 +42,17 @@
 
 int read_input(char *buffer,int size,void* ctx)
 {
-   return fread(buffer, sizeof(char),size,f);
+   int len = 0;
+   char* pos = NULL;
+   len = fread(buffer, sizeof(char),size,f);
+   if (buffer)
+       pos = strstr(buffer, "---");
+   if (pos)
+   {
+        len = pos - buffer;
+        *pos = '\0';
+   }
+   return len;
 }
 
 int

Modified: webservices/axis2/trunk/c/test/xml/soap/test_soap.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/test/xml/soap/test_soap.c?rev=398083&r1=398082&r2=398083&view=diff
==============================================================================
--- webservices/axis2/trunk/c/test/xml/soap/test_soap.c (original)
+++ webservices/axis2/trunk/c/test/xml/soap/test_soap.c Fri Apr 28 21:25:59 2006
@@ -24,11 +24,26 @@
 #include <axis2_soap_fault_role.h>
 
 FILE *f = NULL;
+int read_soap(char *buffer,int size,void* ctx)
+{
+   int len = 0;
+   char* pos = NULL;
+   len = fread(buffer, sizeof(char),size,f);
+   if (buffer)
+       pos = strstr(buffer, "---");
+   if (pos)
+   {
+        len = pos - buffer;
+        *pos = '\0';
+   }
+   printf("buffer = %s\n", buffer);
+   return len;
+}
 
-int read_soap(char *buffer, int size, void *ctx)
+/*int read_soap(char *buffer, int size, void *ctx)
 {
     return fread(buffer, sizeof(char), size, f); 
-}
+}*/
 
 int close_soap(void *ctx)
 {
@@ -384,10 +399,10 @@
     env = axis2_env_create_with_error_log(allocator, error,  log);
     
     axis2_error_init(); 
-    build_soap_programatically(&env);   
+    /*build_soap_programatically(&env);   */
     build_soap(&env, filename,uri); 
-    create_soap_fault(&env); 
-	test_soap_fault_value(&env); 
+    /*create_soap_fault(&env); 
+	test_soap_fault_value(&env); */
     axis2_env_free(env); 
     axis2_allocator_free(allocator);
     return 0;        



Mime
View raw message