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 [3/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...

Modified: webservices/axis2/trunk/c/include/axis2_http_transport_utils.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_http_transport_utils.h?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_http_transport_utils.h (original)
+++ webservices/axis2/trunk/c/include/axis2_http_transport_utils.h Tue Jul 22 01:43:36 2008
@@ -1,390 +1,398 @@
-
-/*
- * Licensedo to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef AXIS2_HTTP_TRANSPORT_UTILS_H
-#define AXIS2_HTTP_TRANSPORT_UTILS_H
-
-/**
- * @ingroup axis2_core_transport_http
- * @{
- */
-
-/**
-  * @file axis2_http_transport_utils.h
-  * @brief axis2 HTTP Transport Utility functions
-  * This file includes functions that handles soap and rest request
-  * that comes to the engine via HTTP protocol.
-  */
-
-#include <axis2_const.h>
-#include <axis2_defines.h>
-#include <axutil_env.h>
-#include <axiom_stax_builder.h>
-#include <axis2_msg_ctx.h>
-#include <axis2_conf_ctx.h>
-#include <axutil_hash.h>
-#include <axiom_element.h>
-#include <axutil_stream.h>
-#include <axiom_soap_envelope.h>
-#include <axutil_http_chunked_stream.h>
-#include <axis2_http_out_transport_info.h>
-#include <axutil_url.h>
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-	
-	typedef enum axis2_http_method_types
-	{
-		AXIS2_HTTP_METHOD_GET = 0,
-		AXIS2_HTTP_METHOD_POST,
-		AXIS2_HTTP_METHOD_HEAD,
-		AXIS2_HTTP_METHOD_PUT,
-		AXIS2_HTTP_METHOD_DELETE
-	}axis2_http_method_types_t;
-
-	
-	typedef struct axis2_http_transport_in
-	{
-		/** HTTP Content type */
-		axis2_char_t *content_type;
-		/** HTTP Content length */
-		int content_length;
-		/** Input message context */
-		axis2_msg_ctx_t *msg_ctx;
-		
-		/** soap action */
-		axis2_char_t *soap_action;
-		
-		/** complete request uri */
-		axis2_char_t *request_uri;
-		
-		/** Input stream */
-		axutil_stream_t *in_stream;
-		
-		/** remote request ip  corresponds to CGI header REMOTE_ADDR */
-		axis2_char_t *remote_ip;
-		
-		/** server port */
-		axis2_char_t *svr_port;
-		
-		/** HTTP transfer encoding header value */
-		axis2_char_t *transfer_encoding;
-		
-		/** HTTP Accept header */
-		axis2_char_t *accept_header;
-		
-		/** HTTP Accept language header */
-		axis2_char_t *accept_language_header;
-		
-		/** HTTP accept charset header */
-		axis2_char_t *accept_charset_header;
-		/** H&TTP METHOD  Should be one of AXIS2_HTTP_METHOD_GET | AXIS2_HTTP_METHOD_POST |"
-		AXIS2_HTTP_METHOD_HEAD | AXIS2_HTTP_METHOD_PUT | AXIS2_HTTP_METHOD_DELETE" */
-		int request_method;
-		/** out transport */
-		axis2_http_out_transport_info_t *out_transport_info;
-		/** this is for serving services html */
-		axis2_char_t *request_url_prefix;
-
-	}axis2_http_transport_in_t;
-
-	typedef struct axis2_http_transport_out
-	{
-		/** HTTP Status code string */
-		axis2_char_t *http_status_code_name;
-		/** HTTP Status code value */
-		int http_status_code;
-		/** Out message context */
-		axis2_msg_ctx_t *msg_ctx;
-		/** Response data */
-		void *response_data;
-		/** HTTP content type */
-		axis2_char_t *content_type;
-		/** Response data length */
-		int response_data_length;
-		/** content language */
-		axis2_char_t *content_language;
-		/** output headers list */
-		axutil_array_list_t *output_headers;
-		
-	}axis2_http_transport_out_t;
-
-
-	/** 
-	 * Initialize the axis2_http_tranport_in_t. Before using this structure users should 
-	 * initialize it using this method.
-	 * @param in a pointer to a axis2_http_tranport_in_t 
-	 * @param env, environments 
-	 */
-	AXIS2_EXTERN axis2_status_t AXIS2_CALL
-	axis2_http_transport_utils_transport_in_init(axis2_http_transport_in_t *in, 
-												const axutil_env_t *env);
-
-	/** 
-	 * Uninitialize the axis2_http_tranport_in_t. Before using this structure users should 
-	 * initialize it using this method.
-	 * @param in a pointer to a axis2_http_tranport_in_t 
-	 * @param env, environments 
-	 */
-	AXIS2_EXTERN axis2_status_t AXIS2_CALL
-	axis2_http_transport_utils_transport_in_uninit(axis2_http_transport_in_t *request, 
-												   const axutil_env_t *env);
-
-	/** 
-	 * Initialize the axis2_http_tranport_out_t. Before using this structure users should 
-	 * initialize it using this method.
-	 * @param out a pointer to a axis2_http_tranport_out_t 
-	 * @param env, environments 
-	 */
-	AXIS2_EXTERN axis2_status_t AXIS2_CALL
-	axis2_http_transport_utils_transport_out_init(axis2_http_transport_out_t *out, 
-												const axutil_env_t *env);
-
-
-	AXIS2_EXTERN axis2_status_t AXIS2_CALL
-	axis2_http_transport_utils_transport_out_uninit(axis2_http_transport_out_t *response, 
-												const axutil_env_t *env);
-	/**
-	* This methods provides the HTTP request handling functionality using axis2 for server side 
-	* HTTP modules.
-	* @param env, environments 
-	* @param conf_ctx, Instance of axis2_conf_ctx_t
-	* @param request, populated instance of axis2_http_transport_in_t struct
-	* @param response, an instance of axis2_http_transport_out_t struct
-	* @returns AXIS2_SUCCESS on success, AXIS2_FAILURE Otherwise
-	*/
-	AXIS2_EXTERN axis2_status_t AXIS2_CALL
-	axis2_http_transport_utils_process_request(
-		const axutil_env_t *env,
-		axis2_conf_ctx_t *conf_ctx,
-		axis2_http_transport_in_t *request,
-		axis2_http_transport_out_t *response);
-
-
-
-    /**
-    * This function handles the HTTP POST request that comes to the axis2 engine.
-	* The request can be either a SOAP request OR a REST request. 
-    * @param env, axutil_env_t instance
-    * @param msg_ctx, Input message context. (an instance of axis2_msg_ctx_t struct.) 
-    * @param in_stream, This is the input message content represented as an axutil_stream instance.
-	*  A callback function will be used to read as required from the stream with in the engine.
-    * @param out_stream, This is the output stream. The outgoing message contents is represented as
-	*                 an instance of axutil_stream
-    * @param content_type, HTTP content type. This value should not be null.
-    * @param content_length, HTTP Content length value.
-    * @param soap_action_header, SOAPAction header value. This is only required in case of SOAP 1.1.
-	*         For SOAP 1.2 , the action header will be within the ContentType header and
-	*         this method is able to obtain the extract the action header value from content type.
-    * @param request_uri, This is the HTTP request uri. Should not be null.
-    * @returns AXIS2_SUCCESS on success, AXIS2_FAILURE Otherwise
-    */
-    AXIS2_EXTERN axis2_status_t AXIS2_CALL
-    axis2_http_transport_utils_process_http_post_request(
-        const axutil_env_t * env,
-        axis2_msg_ctx_t * msg_ctx,
-        axutil_stream_t * in_stream,
-        axutil_stream_t * out_stream,
-        const axis2_char_t * content_type,
-        const int content_length,
-        axutil_string_t * soap_action_header,
-        const axis2_char_t * request_uri);
-
-
-    /**
-    * This method handles the HTTP put request. Parameters are similar to that of post_request
-	* method.
-    * @param env, environment
-    * @param msg_ctx, in message context.
-    * @param in_stream, input stream
-    * @param out_stream, output stream.
-    * @param content_type, HTTP ContentType header value
-    * @param content_length, HTTP Content length value
-    * @param soap_action_header, SOAP Action header value
-    * @param request_uri, request uri
-    * @returns AXIS2_SUCCESS on success, AXIS2_FAILURE Otherwise
-    */
-    AXIS2_EXTERN axis2_status_t AXIS2_CALL
-    axis2_http_transport_utils_process_http_put_request(
-        const axutil_env_t * env,
-        axis2_msg_ctx_t * msg_ctx,
-        axutil_stream_t * in_stream,
-        axutil_stream_t * out_stream,
-        const axis2_char_t * content_type,
-        const int content_length,
-        axutil_string_t * soap_action_header,
-        const axis2_char_t * request_uri);
-
-    AXIS2_EXTERN axis2_bool_t AXIS2_CALL
-    axis2_http_transport_utils_process_http_get_request(
-        const axutil_env_t * env,
-        axis2_msg_ctx_t * msg_ctx,
-        axutil_stream_t * in_stream,
-        axutil_stream_t * out_stream,
-        const axis2_char_t * content_type,
-        axutil_string_t * soap_action_header,
-        const axis2_char_t * request_uri,
-        axis2_conf_ctx_t * conf_ctx,
-        axutil_hash_t * request_params);
-
-    AXIS2_EXTERN axis2_bool_t AXIS2_CALL
-
-    axis2_http_transport_utils_process_http_head_request(
-        const axutil_env_t * env,
-        axis2_msg_ctx_t * msg_ctx,
-        axutil_stream_t * in_stream,
-        axutil_stream_t * out_stream,
-        const axis2_char_t * content_type,
-        axutil_string_t * soap_action_header,
-        const axis2_char_t * request_uri,
-        axis2_conf_ctx_t * conf_ctx,
-        axutil_hash_t * request_params);
-
-    AXIS2_EXTERN axis2_bool_t AXIS2_CALL
-
-    axis2_http_transport_utils_process_http_delete_request(
-        const axutil_env_t * env,
-        axis2_msg_ctx_t * msg_ctx,
-        axutil_stream_t * in_stream,
-        axutil_stream_t * out_stream,
-        const axis2_char_t * content_type,
-        axutil_string_t * soap_action_header,
-        const axis2_char_t * request_uri,
-        axis2_conf_ctx_t * conf_ctx,
-        axutil_hash_t * request_params);
-
-    AXIS2_EXTERN axiom_stax_builder_t *AXIS2_CALL
-
-    axis2_http_transport_utils_select_builder_for_mime(
-        const axutil_env_t * env,
-        axis2_char_t * request_uri,
-        axis2_msg_ctx_t * msg_ctx,
-        axutil_stream_t * in_stream,
-        axis2_char_t * content_type);
-
-    AXIS2_EXTERN axis2_bool_t AXIS2_CALL
-
-    axis2_http_transport_utils_do_write_mtom(
-        const axutil_env_t * env,
-        axis2_msg_ctx_t * msg_ctx);
-
-    AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
-
-    axis2_http_transport_utils_get_request_params(
-        const axutil_env_t * env,
-        axis2_char_t * request_uri);
-
-    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-    axis2_http_transport_utils_get_not_found(
-        const axutil_env_t * env,
-        axis2_conf_ctx_t * conf_ctx);
-
-    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-    axis2_http_transport_utils_get_not_implemented(
-        const axutil_env_t * env,
-        axis2_conf_ctx_t * conf_ctx);
-
-    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-    axis2_http_transport_utils_get_method_not_allowed(
-        const axutil_env_t * env,
-        axis2_conf_ctx_t * conf_ctx);
-
-    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-    axis2_http_transport_utils_get_not_acceptable(
-        const axutil_env_t * env,
-        axis2_conf_ctx_t * conf_ctx);
-
-    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-    axis2_http_transport_utils_get_bad_request(
-        const axutil_env_t * env,
-        axis2_conf_ctx_t * conf_ctx);
-
-    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-    axis2_http_transport_utils_get_request_timeout(
-        const axutil_env_t * env,
-        axis2_conf_ctx_t * conf_ctx);
-
-    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-    axis2_http_transport_utils_get_conflict(
-        const axutil_env_t * env,
-        axis2_conf_ctx_t * conf_ctx);
-
-    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-    axis2_http_transport_utils_get_gone(
-        const axutil_env_t * env,
-        axis2_conf_ctx_t * conf_ctx);
-
-    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-    axis2_http_transport_utils_get_precondition_failed(
-        const axutil_env_t * env,
-        axis2_conf_ctx_t * conf_ctx);
-
-    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-    axis2_http_transport_utils_get_request_entity_too_large(
-        const axutil_env_t * env,
-        axis2_conf_ctx_t * conf_ctx);
-
-    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-    axis2_http_transport_utils_get_service_unavailable(
-        const axutil_env_t * env,
-        axis2_conf_ctx_t * conf_ctx);
-
-    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-    axis2_http_transport_utils_get_internal_server_error(
-        const axutil_env_t * env,
-        axis2_conf_ctx_t * conf_ctx);
-
-    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-
-    axis2_http_transport_utils_get_services_html(
-        const axutil_env_t * env,
-        axis2_conf_ctx_t * conf_ctx);
-
-    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-
-    axis2_http_transport_utils_get_services_static_wsdl(
-        const axutil_env_t * env,
-        axis2_conf_ctx_t * conf_ctx,
-        axis2_char_t * request_url);
-
-    AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
-
-    axis2_http_transport_utils_get_request_params(
-        const axutil_env_t * env,
-        axis2_char_t * request_uri);
-
-    AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL
-
-    axis2_http_transport_utils_create_soap_msg(
-        const axutil_env_t * env,
-        axis2_msg_ctx_t * msg_ctx,
-        const axis2_char_t * soap_ns_uri);
-
-	AXIS2_EXTERN axutil_array_list_t* AXIS2_CALL
-	axis2_http_transport_utils_process_accept_headers(
-		const axutil_env_t *env,
-		axis2_char_t *accept_value);
-
-    /** @} */
-#ifdef __cplusplus
-}
-#endif
-
-#endif       /* AXIS2_HTTP_TRANSPORT_UTILS_H */
+/*
+ * Licensedo to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AXIS2_HTTP_TRANSPORT_UTILS_H
+#define AXIS2_HTTP_TRANSPORT_UTILS_H
+
+#define AXIS2_MTOM_OUTPUT_BUFFER_SIZE 1024
+
+/**
+ * @ingroup axis2_core_transport_http
+ * @{
+ */
+
+/**
+  * @file axis2_http_transport_utils.h
+  * @brief axis2 HTTP Transport Utility functions
+  * This file includes functions that handles soap and rest request
+  * that comes to the engine via HTTP protocol.
+  */
+
+#include <axis2_const.h>
+#include <axis2_defines.h>
+#include <axutil_env.h>
+#include <axiom_stax_builder.h>
+#include <axis2_msg_ctx.h>
+#include <axis2_conf_ctx.h>
+#include <axutil_hash.h>
+#include <axiom_element.h>
+#include <axutil_stream.h>
+#include <axiom_soap_envelope.h>
+#include <axutil_http_chunked_stream.h>
+#include <axis2_http_out_transport_info.h>
+#include <axutil_url.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+	
+	typedef enum axis2_http_method_types
+	{
+		AXIS2_HTTP_METHOD_GET = 0,
+		AXIS2_HTTP_METHOD_POST,
+		AXIS2_HTTP_METHOD_HEAD,
+		AXIS2_HTTP_METHOD_PUT,
+		AXIS2_HTTP_METHOD_DELETE
+	}axis2_http_method_types_t;
+
+	
+	typedef struct axis2_http_transport_in
+	{
+		/** HTTP Content type */
+		axis2_char_t *content_type;
+		/** HTTP Content length */
+		int content_length;
+		/** Input message context */
+		axis2_msg_ctx_t *msg_ctx;
+		
+		/** soap action */
+		axis2_char_t *soap_action;
+		
+		/** complete request uri */
+		axis2_char_t *request_uri;
+		
+		/** Input stream */
+		axutil_stream_t *in_stream;
+		
+		/** remote request ip  corresponds to CGI header REMOTE_ADDR */
+		axis2_char_t *remote_ip;
+		
+		/** server port */
+		axis2_char_t *svr_port;
+		
+		/** HTTP transfer encoding header value */
+		axis2_char_t *transfer_encoding;
+		
+		/** HTTP Accept header */
+		axis2_char_t *accept_header;
+		
+		/** HTTP Accept language header */
+		axis2_char_t *accept_language_header;
+		
+		/** HTTP accept charset header */
+		axis2_char_t *accept_charset_header;
+		/** H&TTP METHOD  Should be one of AXIS2_HTTP_METHOD_GET | AXIS2_HTTP_METHOD_POST |"
+		AXIS2_HTTP_METHOD_HEAD | AXIS2_HTTP_METHOD_PUT | AXIS2_HTTP_METHOD_DELETE" */
+		int request_method;
+		/** out transport */
+		axis2_http_out_transport_info_t *out_transport_info;
+		/** this is for serving services html */
+		axis2_char_t *request_url_prefix;
+
+	}axis2_http_transport_in_t;
+
+	typedef struct axis2_http_transport_out
+	{
+		/** HTTP Status code string */
+		axis2_char_t *http_status_code_name;
+		/** HTTP Status code value */
+		int http_status_code;
+		/** Out message context */
+		axis2_msg_ctx_t *msg_ctx;
+		/** Response data */
+		void *response_data;
+		/** HTTP content type */
+		axis2_char_t *content_type;
+		/** Response data length */
+		int response_data_length;
+		/** content language */
+		axis2_char_t *content_language;
+		/** output headers list */
+		axutil_array_list_t *output_headers;
+		
+	}axis2_http_transport_out_t;
+
+
+	/** 
+	 * Initialize the axis2_http_tranport_in_t. Before using this structure users should 
+	 * initialize it using this method.
+	 * @param in a pointer to a axis2_http_tranport_in_t 
+	 * @param env, environments 
+	 */
+	AXIS2_EXTERN axis2_status_t AXIS2_CALL
+	axis2_http_transport_utils_transport_in_init(axis2_http_transport_in_t *in, 
+												const axutil_env_t *env);
+
+	/** 
+	 * Uninitialize the axis2_http_tranport_in_t. Before using this structure users should 
+	 * initialize it using this method.
+	 * @param in a pointer to a axis2_http_tranport_in_t 
+	 * @param env, environments 
+	 */
+	AXIS2_EXTERN axis2_status_t AXIS2_CALL
+	axis2_http_transport_utils_transport_in_uninit(axis2_http_transport_in_t *request, 
+												   const axutil_env_t *env);
+
+	/** 
+	 * Initialize the axis2_http_tranport_out_t. Before using this structure users should 
+	 * initialize it using this method.
+	 * @param out a pointer to a axis2_http_tranport_out_t 
+	 * @param env, environments 
+	 */
+	AXIS2_EXTERN axis2_status_t AXIS2_CALL
+	axis2_http_transport_utils_transport_out_init(axis2_http_transport_out_t *out, 
+												const axutil_env_t *env);
+
+
+	AXIS2_EXTERN axis2_status_t AXIS2_CALL
+	axis2_http_transport_utils_transport_out_uninit(axis2_http_transport_out_t *response, 
+												const axutil_env_t *env);
+	/**
+	* This methods provides the HTTP request handling functionality using axis2 for server side 
+	* HTTP modules.
+	* @param env, environments 
+	* @param conf_ctx, Instance of axis2_conf_ctx_t
+	* @param request, populated instance of axis2_http_transport_in_t struct
+	* @param response, an instance of axis2_http_transport_out_t struct
+	* @returns AXIS2_SUCCESS on success, AXIS2_FAILURE Otherwise
+	*/
+	AXIS2_EXTERN axis2_status_t AXIS2_CALL
+	axis2_http_transport_utils_process_request(
+		const axutil_env_t *env,
+		axis2_conf_ctx_t *conf_ctx,
+		axis2_http_transport_in_t *request,
+		axis2_http_transport_out_t *response);
+
+
+
+    /**
+    * This function handles the HTTP POST request that comes to the axis2 engine.
+	* The request can be either a SOAP request OR a REST request. 
+    * @param env, axutil_env_t instance
+    * @param msg_ctx, Input message context. (an instance of axis2_msg_ctx_t struct.) 
+    * @param in_stream, This is the input message content represented as an axutil_stream instance.
+	*  A callback function will be used to read as required from the stream with in the engine.
+    * @param out_stream, This is the output stream. The outgoing message contents is represented as
+	*                 an instance of axutil_stream
+    * @param content_type, HTTP content type. This value should not be null.
+    * @param content_length, HTTP Content length value.
+    * @param soap_action_header, SOAPAction header value. This is only required in case of SOAP 1.1.
+	*         For SOAP 1.2 , the action header will be within the ContentType header and
+	*         this method is able to obtain the extract the action header value from content type.
+    * @param request_uri, This is the HTTP request uri. Should not be null.
+    * @returns AXIS2_SUCCESS on success, AXIS2_FAILURE Otherwise
+    */
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    axis2_http_transport_utils_process_http_post_request(
+        const axutil_env_t * env,
+        axis2_msg_ctx_t * msg_ctx,
+        axutil_stream_t * in_stream,
+        axutil_stream_t * out_stream,
+        const axis2_char_t * content_type,
+        const int content_length,
+        axutil_string_t * soap_action_header,
+        const axis2_char_t * request_uri);
+
+
+    /**
+    * This method handles the HTTP put request. Parameters are similar to that of post_request
+	* method.
+    * @param env, environment
+    * @param msg_ctx, in message context.
+    * @param in_stream, input stream
+    * @param out_stream, output stream.
+    * @param content_type, HTTP ContentType header value
+    * @param content_length, HTTP Content length value
+    * @param soap_action_header, SOAP Action header value
+    * @param request_uri, request uri
+    * @returns AXIS2_SUCCESS on success, AXIS2_FAILURE Otherwise
+    */
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    axis2_http_transport_utils_process_http_put_request(
+        const axutil_env_t * env,
+        axis2_msg_ctx_t * msg_ctx,
+        axutil_stream_t * in_stream,
+        axutil_stream_t * out_stream,
+        const axis2_char_t * content_type,
+        const int content_length,
+        axutil_string_t * soap_action_header,
+        const axis2_char_t * request_uri);
+
+    AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+    axis2_http_transport_utils_process_http_get_request(
+        const axutil_env_t * env,
+        axis2_msg_ctx_t * msg_ctx,
+        axutil_stream_t * in_stream,
+        axutil_stream_t * out_stream,
+        const axis2_char_t * content_type,
+        axutil_string_t * soap_action_header,
+        const axis2_char_t * request_uri,
+        axis2_conf_ctx_t * conf_ctx,
+        axutil_hash_t * request_params);
+
+    AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+
+    axis2_http_transport_utils_process_http_head_request(
+        const axutil_env_t * env,
+        axis2_msg_ctx_t * msg_ctx,
+        axutil_stream_t * in_stream,
+        axutil_stream_t * out_stream,
+        const axis2_char_t * content_type,
+        axutil_string_t * soap_action_header,
+        const axis2_char_t * request_uri,
+        axis2_conf_ctx_t * conf_ctx,
+        axutil_hash_t * request_params);
+
+    AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+
+    axis2_http_transport_utils_process_http_delete_request(
+        const axutil_env_t * env,
+        axis2_msg_ctx_t * msg_ctx,
+        axutil_stream_t * in_stream,
+        axutil_stream_t * out_stream,
+        const axis2_char_t * content_type,
+        axutil_string_t * soap_action_header,
+        const axis2_char_t * request_uri,
+        axis2_conf_ctx_t * conf_ctx,
+        axutil_hash_t * request_params);
+
+    AXIS2_EXTERN axiom_stax_builder_t *AXIS2_CALL
+
+    axis2_http_transport_utils_select_builder_for_mime(
+        const axutil_env_t * env,
+        axis2_char_t * request_uri,
+        axis2_msg_ctx_t * msg_ctx,
+        axutil_stream_t * in_stream,
+        axis2_char_t * content_type);
+
+    AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+
+    axis2_http_transport_utils_do_write_mtom(
+        const axutil_env_t * env,
+        axis2_msg_ctx_t * msg_ctx);
+
+    AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+
+    axis2_http_transport_utils_get_request_params(
+        const axutil_env_t * env,
+        axis2_char_t * request_uri);
+
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    axis2_http_transport_utils_get_not_found(
+        const axutil_env_t * env,
+        axis2_conf_ctx_t * conf_ctx);
+
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    axis2_http_transport_utils_get_not_implemented(
+        const axutil_env_t * env,
+        axis2_conf_ctx_t * conf_ctx);
+
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    axis2_http_transport_utils_get_method_not_allowed(
+        const axutil_env_t * env,
+        axis2_conf_ctx_t * conf_ctx);
+
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    axis2_http_transport_utils_get_not_acceptable(
+        const axutil_env_t * env,
+        axis2_conf_ctx_t * conf_ctx);
+
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    axis2_http_transport_utils_get_bad_request(
+        const axutil_env_t * env,
+        axis2_conf_ctx_t * conf_ctx);
+
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    axis2_http_transport_utils_get_request_timeout(
+        const axutil_env_t * env,
+        axis2_conf_ctx_t * conf_ctx);
+
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    axis2_http_transport_utils_get_conflict(
+        const axutil_env_t * env,
+        axis2_conf_ctx_t * conf_ctx);
+
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    axis2_http_transport_utils_get_gone(
+        const axutil_env_t * env,
+        axis2_conf_ctx_t * conf_ctx);
+
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    axis2_http_transport_utils_get_precondition_failed(
+        const axutil_env_t * env,
+        axis2_conf_ctx_t * conf_ctx);
+
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    axis2_http_transport_utils_get_request_entity_too_large(
+        const axutil_env_t * env,
+        axis2_conf_ctx_t * conf_ctx);
+
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    axis2_http_transport_utils_get_service_unavailable(
+        const axutil_env_t * env,
+        axis2_conf_ctx_t * conf_ctx);
+
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+    axis2_http_transport_utils_get_internal_server_error(
+        const axutil_env_t * env,
+        axis2_conf_ctx_t * conf_ctx);
+
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+
+    axis2_http_transport_utils_get_services_html(
+        const axutil_env_t * env,
+        axis2_conf_ctx_t * conf_ctx);
+
+    AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+
+    axis2_http_transport_utils_get_services_static_wsdl(
+        const axutil_env_t * env,
+        axis2_conf_ctx_t * conf_ctx,
+        axis2_char_t * request_url);
+
+    AXIS2_EXTERN axutil_hash_t *AXIS2_CALL
+
+    axis2_http_transport_utils_get_request_params(
+        const axutil_env_t * env,
+        axis2_char_t * request_uri);
+
+    AXIS2_EXTERN axiom_soap_envelope_t *AXIS2_CALL
+
+    axis2_http_transport_utils_create_soap_msg(
+        const axutil_env_t * env,
+        axis2_msg_ctx_t * msg_ctx,
+        const axis2_char_t * soap_ns_uri);
+
+	AXIS2_EXTERN axutil_array_list_t* AXIS2_CALL
+	axis2_http_transport_utils_process_accept_headers(
+		const axutil_env_t *env,
+		axis2_char_t *accept_value);
+
+    AXIS2_EXTERN axis2_status_t AXIS2_CALL
+    axis2_http_transport_utils_send_mtom_message(
+        axutil_http_chunked_stream_t * chunked_stream,
+        const axutil_env_t * env,
+        axutil_array_list_t *mime_parts);
+
+
+    /** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif       /* AXIS2_HTTP_TRANSPORT_UTILS_H */

Modified: webservices/axis2/trunk/c/include/axis2_msg_ctx.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/include/axis2_msg_ctx.h?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_msg_ctx.h (original)
+++ webservices/axis2/trunk/c/include/axis2_msg_ctx.h Tue Jul 22 01:43:36 2008
@@ -2060,7 +2060,22 @@
         const axutil_env_t * env,
         axutil_array_list_t * output_headers);
 
-    /** @} */
+
+
+    AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+    axis2_msg_ctx_get_mime_parts(
+        axis2_msg_ctx_t * msg_ctx,
+        const axutil_env_t * env);
+
+
+    AXIS2_EXTERN void AXIS2_CALL
+    axis2_msg_ctx_set_mime_parts(
+        axis2_msg_ctx_t * msg_ctx,
+        const axutil_env_t * env,
+        axutil_array_list_t *mime_parts);
+
+
+/** @} */
 
 #ifdef __cplusplus
 }

Modified: webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c (original)
+++ webservices/axis2/trunk/c/samples/client/mtom/mtom_client.c Tue Jul 22 01:43:36 2008
@@ -234,13 +234,19 @@
         axiom_text_t *axiom_text = (axiom_text_t*)axiom_node_get_data_element(res_om_node, env);
         data_handler = axiom_text_get_data_handler(axiom_text, env);
 
-        axiom_data_handler_set_file_name(data_handler, env, (axis2_char_t *)to_save_name);
-        axiom_data_handler_write_to(data_handler, env);
-    }else if(axiom_node_get_node_type(res_om_node, env) == AXIOM_ELEMENT)
-    {
+        /*axiom_data_handler_set_file_name(data_handler, env, (axis2_char_t *)to_save_name);*/
+        if(axiom_data_handler_get_cached(data_handler, env)) 
+        {
+            printf("Attachment is cached.\n");    
+        }   
+        else
+        {
+            axiom_data_handler_set_file_name(data_handler, env, "test");
+            axiom_data_handler_write_to(data_handler, env);
+        }
+    }else if(axiom_node_get_node_type(res_om_node, env) == AXIOM_ELEMENT){
         res_om_ele = axiom_node_get_data_element(res_om_node, env);
-        printf("Base64 String received \n\n\n %s \n\n", 
-               axiom_element_get_text(res_om_ele, env, res_om_node));
+        printf("Base64 String received \n\n\n %s \n\n", axiom_element_get_text(res_om_ele, env, res_om_node));
     }
 
     return 0;

Modified: webservices/axis2/trunk/c/samples/client/mtom/resources/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/client/mtom/resources/Makefile.am?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/client/mtom/resources/Makefile.am (original)
+++ webservices/axis2/trunk/c/samples/client/mtom/resources/Makefile.am Tue Jul 22 01:43:36 2008
@@ -1,4 +1,3 @@
 samplesdir=$(prefix)/bin/samples/resources
 samples_DATA=axis2.jpg 
-EXTRA_DIST=axis2.jpg
-
+EXTRA_DIST=axis2.jpg 

Modified: webservices/axis2/trunk/c/samples/configure.ac
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/configure.ac?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/configure.ac (original)
+++ webservices/axis2/trunk/c/samples/configure.ac Tue Jul 22 01:43:36 2008
@@ -136,7 +136,7 @@
     client/amqp/Makefile \
     client/amqp/echo/Makefile \
     user_guide/Makefile \
-    user_guide/clients/Makefile \
+    user_guide/clients/Makefile
     ])
     
 AC_OUTPUT

Modified: webservices/axis2/trunk/c/samples/server/axis2.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/server/axis2.xml?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/server/axis2.xml (original)
+++ webservices/axis2/trunk/c/samples/server/axis2.xml Tue Jul 22 01:43:36 2008
@@ -6,9 +6,9 @@
     <!--parameter name="enableMTOM" locked="false">true</parameter-->
 
     <!-- Set the suitable size for optimum memory usage when sending large attachments -->
-    <!--parameter name="MTOMChunkBufferSize" locked="false">10</parameter-->
-    <!--parameter name="MTOMMaxChunkBuffers" locked="false">1000</parameter-->
-    
+    <!--parameter name="MTOMBufferSize" locked="false">10</parameter-->
+    <!--parameter name="MTOMMaxBuffers" locked="false">1000</parameter-->
+    <!--parameter name="attachmentDIR" locked="false">/path/to/the/attachment/caching/dir/</parameter-->    
     <!-- Enable REST -->
     <parameter name="enableREST" locked="false">true</parameter>
 

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

Modified: webservices/axis2/trunk/c/samples/server/mtom/mtom.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/samples/server/mtom/mtom.c?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/samples/server/mtom/mtom.c (original)
+++ webservices/axis2/trunk/c/samples/server/mtom/mtom.c Tue Jul 22 01:43:36 2008
@@ -100,7 +100,7 @@
                     axiom_text_t *bin_text = (axiom_text_t *)
                         axiom_node_get_data_element(binary_node, env);
                     data_handler = axiom_text_get_data_handler(bin_text, env);
-                    if (data_handler)
+                    if (data_handler && !axiom_data_handler_get_cached(data_handler, env))
                     {
                         axiom_data_handler_t *data_handler_res = NULL;
                         axis2_byte_t *input_buff = NULL;
@@ -119,14 +119,34 @@
                         
                         buff = AXIS2_MALLOC(env->allocator, sizeof(axis2_byte_t)*buff_len);
 
+            			if (!buff)
+			            {
+			                AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI,
+					        "malloc failed, not enough memory");
+			                return NULL;
+			            }
 
                         memcpy(buff, input_buff, buff_len);
 
                         axiom_data_handler_set_binary_data(data_handler_res, env, buff, buff_len);
-						axiom_data_handler_set_content_type(data_handler_res, env,"image/jpeg");
+
                         axis2_msg_ctx_set_doing_mtom (msg_ctx, env, AXIS2_TRUE);
                         ret_node = build_response2(env, data_handler_res);
                     }
+                    else if(data_handler && axiom_data_handler_get_cached(data_handler, env))
+                    {
+                        axiom_data_handler_t *data_handler_res = NULL;
+                        axis2_char_t *file_name = NULL;
+
+                        file_name = axiom_data_handler_get_file_name(data_handler, env);
+
+
+                        data_handler_res = axiom_data_handler_create(env, file_name, NULL);
+
+                        axis2_msg_ctx_set_doing_mtom (msg_ctx, env, AXIS2_TRUE);
+                        ret_node = build_response2(env, data_handler_res);
+                    }
+
                     else if (axiom_node_get_node_type(binary_node, env) == AXIOM_TEXT) /* attachment has come by value, as non-optimized binary */
                     {
                         int plain_binary_len = 0;

Modified: webservices/axis2/trunk/c/src/core/context/msg_ctx.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/context/msg_ctx.c?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/context/msg_ctx.c (original)
+++ webservices/axis2/trunk/c/src/core/context/msg_ctx.c Tue Jul 22 01:43:36 2008
@@ -216,6 +216,8 @@
     axis2_bool_t required_auth_is_http;
     axis2_char_t *auth_type;
     axis2_bool_t no_content;
+
+    axutil_array_list_t *mime_parts;
 };
 
 AXIS2_EXTERN axis2_msg_ctx_t *AXIS2_CALL
@@ -297,6 +299,8 @@
     msg_ctx->no_content = AXIS2_FALSE;
     msg_ctx->status_code = 0;
     msg_ctx->options = NULL;
+    msg_ctx->mime_parts = NULL;
+
     msg_ctx->base = axis2_ctx_create(env);
     if (!(msg_ctx->base))
     {
@@ -2761,3 +2765,25 @@
 {
     return msg_ctx->auth_type;
 }
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_msg_ctx_get_mime_parts(
+    axis2_msg_ctx_t * msg_ctx,
+    const axutil_env_t * env)
+{
+    return msg_ctx->mime_parts;
+}
+
+AXIS2_EXTERN void AXIS2_CALL
+axis2_msg_ctx_set_mime_parts(
+    axis2_msg_ctx_t * msg_ctx,
+    const axutil_env_t * env,
+    axutil_array_list_t *mime_parts)
+{
+    if(msg_ctx->mime_parts)
+    {
+        axutil_array_list_free(mime_parts, env);
+        msg_ctx->mime_parts = NULL;        
+    }
+    msg_ctx->mime_parts = mime_parts;
+}

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

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

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

Modified: webservices/axis2/trunk/c/src/core/transport/http/common/http_simple_response.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/common/http_simple_response.c?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/common/http_simple_response.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/common/http_simple_response.c Tue Jul 22 01:43:36 2008
@@ -20,6 +20,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <axutil_types.h>
+#include <axiom_mime_part.h>
 
 #define AXIS2_HTTP_SIMPLE_RESPONSE_READ_SIZE 2048
 
@@ -28,6 +29,7 @@
     axis2_http_status_line_t *status_line;
     axutil_array_list_t *header_group;
     axutil_stream_t *stream;
+    axutil_array_list_t *mime_parts;
 };
 
 
@@ -94,6 +96,7 @@
     simple_response->status_line = NULL;
     simple_response->header_group = NULL;
     simple_response->stream = NULL;
+    simple_response->mime_parts = NULL;
 
     return simple_response;
 }
@@ -128,6 +131,23 @@
         axutil_array_list_free(simple_response->header_group, env);
     }
 
+    if (simple_response->mime_parts)
+    {
+        int i = 0;
+        for (i = 0; i < axutil_array_list_size(simple_response->mime_parts, env); i++)
+        {
+            axiom_mime_part_t *mime_part = NULL;
+            mime_part = (axiom_mime_part_t *)
+                axutil_array_list_get(simple_response->mime_parts, env, i);
+            if (mime_part)
+            {
+                axiom_mime_part_free(mime_part, env);
+            }
+        }
+        axutil_array_list_free(simple_response->mime_parts, env);
+    }
+
+
     AXIS2_FREE(env->allocator, simple_response);
     /* 
      * Stream is not freed
@@ -229,6 +249,25 @@
                                                    env);
 }
 
+axis2_status_t AXIS2_CALL
+axis2_http_simple_response_set_http_version(
+    axis2_http_simple_response_t * simple_response,
+    const axutil_env_t * env,
+    axis2_char_t *http_version)
+{
+    if (!(simple_response->status_line))
+    {
+        AXIS2_LOG_ERROR (env->log, AXIS2_LOG_SI, 
+                         "axis2 simple response , status line is not available");
+     
+        return AXIS2_FAILURE;
+    }
+    axis2_http_status_line_set_http_version(simple_response->status_line,
+                                                   env, http_version);
+    return AXIS2_SUCCESS;
+}
+
+
 axis2_char_t *AXIS2_CALL
 axis2_http_simple_response_get_status_line(
     axis2_http_simple_response_t * simple_response,
@@ -600,6 +639,24 @@
 }
 
 
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_http_simple_response_get_mime_parts(
+    axis2_http_simple_response_t * simple_response,
+    const axutil_env_t * env)
+{
+
+    return simple_response->mime_parts;
+
+}
 
+void AXIS2_EXTERN AXIS2_CALL
+axis2_http_simple_response_set_mime_parts(
+    axis2_http_simple_response_t * simple_response,
+    const axutil_env_t * env,
+    axutil_array_list_t *mime_parts)
+{
 
+    simple_response->mime_parts = mime_parts;
+
+}
 

Modified: webservices/axis2/trunk/c/src/core/transport/http/common/http_status_line.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/common/http_status_line.c?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/common/http_status_line.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/common/http_status_line.c Tue Jul 22 01:43:36 2008
@@ -177,6 +177,7 @@
 
 }
 
+
 AXIS2_EXTERN axis2_char_t *AXIS2_CALL
 axis2_http_status_line_get_http_version(
     const axis2_http_status_line_t * status_line,
@@ -185,6 +186,22 @@
     return status_line->http_version;
 }
 
+AXIS2_EXTERN void AXIS2_CALL
+axis2_http_status_line_set_http_version(
+    axis2_http_status_line_t * status_line,
+    const axutil_env_t * env,
+    axis2_char_t *http_version)
+{
+    if(status_line->http_version)
+    {
+        AXIS2_FREE(env->allocator, status_line->http_version);
+        status_line->http_version = NULL;
+    }
+
+    status_line->http_version = (axis2_char_t *) axutil_strdup(env, http_version);
+
+}
+
 AXIS2_EXTERN axis2_char_t *AXIS2_CALL
 axis2_http_status_line_get_reason_phrase(
     const axis2_http_status_line_t * status_line,

Modified: webservices/axis2/trunk/c/src/core/transport/http/common/http_worker.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/common/http_worker.c?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/common/http_worker.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/common/http_worker.c Tue Jul 22 01:43:36 2008
@@ -164,6 +164,11 @@
     axis2_char_t *url_ext_form = NULL;
     const axis2_char_t *content_type = NULL;
 
+    axis2_msg_ctx_t *out_msg_ctx = NULL;
+    axis2_msg_ctx_t *in_msg_ctx = NULL;
+    axis2_msg_ctx_t **msg_ctx_map = NULL;
+
+
     AXIS2_PARAM_CHECK(env->error, svr_conn, AXIS2_FALSE);
     AXIS2_PARAM_CHECK(env->error, simple_request, AXIS2_FALSE);
 
@@ -517,8 +522,6 @@
         is_put = AXIS2_TRUE;
     }
 
-
-        
     request_uri = axis2_http_request_line_get_uri (request_line, env);
     request_params = 
         axis2_http_transport_utils_get_request_params(env,
@@ -1318,8 +1321,8 @@
     op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
     if (op_ctx)
     {
-        axis2_msg_ctx_t *out_msg_ctx = NULL;
-        axis2_msg_ctx_t **msg_ctx_map = NULL;
+        /*axis2_msg_ctx_t *out_msg_ctx = NULL;
+        axis2_msg_ctx_t **msg_ctx_map = NULL;*/
         axis2_char_t *language_str = NULL;
 
         msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
@@ -1598,12 +1601,12 @@
             {
                 if (do_rest)
                 {
-                    axis2_msg_ctx_t *out_msg_ctx = NULL;
+                    /*axis2_msg_ctx_t *out_msg_ctx = NULL;
                     axis2_msg_ctx_t *in_msg_ctx = NULL;
-                    axis2_msg_ctx_t **msg_ctx_map = NULL;
+                    axis2_msg_ctx_t **msg_ctx_map = NULL;*/
 
-                    msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
-                    out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];
+                    /*msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
+                    out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];*/
                     in_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN];
                     if (in_msg_ctx)
                     {
@@ -1732,9 +1735,9 @@
                 /* If response is not written */
                 if (do_rest)
                 {
-                    axis2_msg_ctx_t *out_msg_ctx = NULL;
+                    /*axis2_msg_ctx_t *out_msg_ctx = NULL;
                     axis2_msg_ctx_t *in_msg_ctx = NULL;
-                    axis2_msg_ctx_t **msg_ctx_map = NULL;
+                    axis2_msg_ctx_t **msg_ctx_map = NULL;*/
 
                     msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
                     out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];
@@ -1905,12 +1908,48 @@
                 int stream_len = 0;
                 stream_len = axutil_stream_get_len(out_stream, env);
 
-                axis2_http_worker_set_response_headers(http_worker, env, svr_conn,
+                /*axis2_http_worker_set_response_headers(http_worker, env, svr_conn,
                                                        simple_request, response,
-                                                       stream_len);
+                                                       stream_len);*/
    
                 /* This is where it actually write to the wire in the http back channel
                  * append case. */ 
+                if(out_msg_ctx)
+                {
+                    axutil_array_list_t *mime_parts = NULL;
+                    mime_parts = axis2_msg_ctx_get_mime_parts(out_msg_ctx, env);
+                    /* If mime_parts is there then that means we send MTOM. So
+                     * in order to send MTOM we are enabling HTTP1.1 and cunk transfer
+                     * encoding */
+
+                    if(mime_parts)
+                    {
+                        axis2_http_header_t *transfer_enc_header = NULL;                        
+
+                        axis2_http_simple_response_set_mime_parts(response, env, mime_parts);  
+
+                        axis2_http_simple_response_set_http_version(response, env, 
+                            AXIS2_HTTP_HEADER_PROTOCOL_11);
+ 
+                        transfer_enc_header = axis2_http_header_create(env,
+                                         AXIS2_HTTP_HEADER_TRANSFER_ENCODING,
+                                         AXIS2_HTTP_HEADER_TRANSFER_ENCODING_CHUNKED);
+
+                        axis2_http_simple_response_set_header(response, env,
+                                                  transfer_enc_header);
+
+                        /* In the chunking case content-lenght is zero */
+                        axis2_http_worker_set_response_headers(http_worker, env, svr_conn,
+                                                       simple_request, response,
+                                                       0);
+                    }
+                    else
+                    {
+                        axis2_http_worker_set_response_headers(http_worker, env, svr_conn,
+                                                       simple_request, response,
+                                                       stream_len);
+                    }
+                }
                 status = axis2_simple_http_svr_conn_write_response(svr_conn, 
                                                                    env, 
                                                                    response);
@@ -1925,15 +1964,15 @@
     } 
     if (op_ctx)
     {
-        axis2_msg_ctx_t *out_msg_ctx = NULL;
+        /*axis2_msg_ctx_t *out_msg_ctx = NULL;
         axis2_msg_ctx_t *in_msg_ctx = NULL;
-        axis2_msg_ctx_t **msg_ctx_map = NULL;
+        axis2_msg_ctx_t **msg_ctx_map = NULL;*/
         axis2_char_t *msg_id = NULL;
         axis2_conf_ctx_t *conf_ctx = NULL;
-        msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
+        /*msg_ctx_map = axis2_op_ctx_get_msg_ctx_map(op_ctx, env);
 
         out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];
-        in_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN];
+        in_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN];*/
 
         if (out_msg_ctx)
         {
@@ -2050,34 +2089,39 @@
                                                           AXIS2_FALSE);
             }
         }
-        if (AXIS2_FALSE ==
-            axis2_http_simple_request_contains_header(simple_request, env,
-                                                      AXIS2_HTTP_HEADER_TRANSFER_ENCODING))
+
+        if(!axis2_http_simple_response_contains_header(simple_response, env, 
+            AXIS2_HTTP_HEADER_TRANSFER_ENCODING))
         {
-            if (0 != content_length)
+            if (AXIS2_FALSE ==
+                axis2_http_simple_request_contains_header(simple_request, env,
+                                                      AXIS2_HTTP_HEADER_TRANSFER_ENCODING))
             {
-                axis2_char_t content_len_str[10];
-                axis2_http_header_t *content_len_hdr = NULL;
+                if (0 != content_length)
+                {
+                    axis2_char_t content_len_str[10];
+                    axis2_http_header_t *content_len_hdr = NULL;
 
-                sprintf(content_len_str, "%d", content_length);
-                content_len_hdr =
-                    axis2_http_header_create(env,
+                    sprintf(content_len_str, "%d", content_length);
+                    content_len_hdr =
+                        axis2_http_header_create(env,
                                              AXIS2_HTTP_HEADER_CONTENT_LENGTH,
                                              content_len_str);
-                axis2_http_simple_response_set_header(simple_response, env,
+                    axis2_http_simple_response_set_header(simple_response, env,
                                                       content_len_hdr);
+                }
             }
-        }
-        else
-        {
+            else
+            {
             /* Having Transfer encoding Header */
-            axis2_http_header_t *transfer_enc_header =
-                axis2_http_header_create(env,
+                axis2_http_header_t *transfer_enc_header =
+                    axis2_http_header_create(env,
                                          AXIS2_HTTP_HEADER_TRANSFER_ENCODING,
                                          AXIS2_HTTP_HEADER_TRANSFER_ENCODING_CHUNKED);
 
-            axis2_http_simple_response_set_header(simple_response, env,
+                axis2_http_simple_response_set_header(simple_response, env,
                                                   transfer_enc_header);
+            }
         }
     }
     return AXIS2_SUCCESS;

Modified: webservices/axis2/trunk/c/src/core/transport/http/common/simple_http_svr_conn.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/common/simple_http_svr_conn.c?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/common/simple_http_svr_conn.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/common/simple_http_svr_conn.c Tue Jul 22 01:43:36 2008
@@ -22,6 +22,8 @@
 #include <axutil_http_chunked_stream.h>
 #include <platforms/axutil_platform_auto_sense.h>
 #include <string.h>
+#include <axis2_http_simple_response.h>
+#include <axis2_http_transport_utils.h>
 
 struct axis2_simple_http_svr_conn
 {
@@ -373,13 +375,14 @@
         response_body[body_size] = AXIS2_ESC_NULL;
     }
 
-    if (body_size <= 0)
+    if (body_size <= 0 && !binary_content)
     {
         axis2_http_response_writer_free(response_writer, env);
         return AXIS2_SUCCESS;
     }
 
-    if (AXIS2_FALSE == chuked_encoding)
+    /* This sending a normal SOAP response without chunk transfer encoding */
+    if (AXIS2_FALSE == chuked_encoding && !binary_content)
     {
         axis2_status_t write_stat = AXIS2_FAILURE;
         if (AXIS2_FALSE == binary_content)
@@ -404,16 +407,48 @@
             return AXIS2_FAILURE;
         }
     }
-    else
+    
+    /* In the MTOM case we enable chunking inorder to send the attachment */
+    
+    else if(binary_content)
     {
         axutil_http_chunked_stream_t *chunked_stream = NULL;
-        int left = body_size;
+        axis2_status_t write_stat = AXIS2_FAILURE;
+        axutil_array_list_t *mime_parts = NULL;
+        
         chunked_stream = axutil_http_chunked_stream_create(env,
                                                           svr_conn->stream);
+        
+        mime_parts = axis2_http_simple_response_get_mime_parts(response, env);
+
+        if(mime_parts)
+        {            
+            write_stat = axis2_http_transport_utils_send_mtom_message(
+                    chunked_stream, env, mime_parts);
+            axutil_http_chunked_stream_free(chunked_stream, env);
+            chunked_stream = NULL;
+                    
+            if(write_stat == AXIS2_FAILURE)
+            {
+                return write_stat;
+            }
+        }    
+        else
+        {
+            return AXIS2_FAILURE;
+        }
+    } 
+    
+    /* Sending a normal SOAP response enabling htpp chunking */
+    else 
+    {    
+        axutil_http_chunked_stream_t *chunked_stream = NULL;
+        int left = body_size;
+        chunked_stream = axutil_http_chunked_stream_create(env, svr_conn->stream);
         while (left > 0)
         {
             left -= axutil_http_chunked_stream_write(chunked_stream, env,
-                                                    response_body, body_size);
+                response_body, body_size);
         }
         axutil_http_chunked_stream_write_last_chunk(chunked_stream, env);
         axutil_http_chunked_stream_free(chunked_stream, env);
@@ -464,3 +499,5 @@
 {
     return axutil_network_handler_get_peer_ip(env, svr_conn->socket);
 }
+
+

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

Modified: webservices/axis2/trunk/c/src/core/transport/http/sender/http_client.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/sender/http_client.c?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/sender/http_client.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/sender/http_client.c Tue Jul 22 01:43:36 2008
@@ -26,6 +26,8 @@
 #include <axis2_http_status_line.h>
 #include <axutil_http_chunked_stream.h>
 #include <platforms/axutil_platform_auto_sense.h>
+#include <axiom_mime_part.h>
+#include <axis2_http_transport_utils.h>
 
 #ifdef AXIS2_SSL_ENABLED
 #include "ssl/ssl_stream.h"
@@ -48,6 +50,10 @@
     axis2_char_t *key_file;
     axis2_char_t *req_body;
     int req_body_size;
+    
+    /* These are for mtom case */
+    axutil_array_list_t *mime_parts;
+    axis2_bool_t doing_mtom;
 };
 
 AXIS2_EXTERN axis2_http_client_t *AXIS2_CALL
@@ -85,6 +91,8 @@
     http_client->key_file = NULL;
     http_client->req_body = NULL;
     http_client->req_body_size = 0;
+    http_client->mime_parts = NULL;
+    http_client->doing_mtom = AXIS2_FALSE;
 
     return http_client;
 }
@@ -112,6 +120,25 @@
     {
         AXIS2_FREE(env->allocator, http_client->req_body);
     }
+    
+    /* There is no other appropriate place to free the mime_part list when a 
+     * particular client send requests. */
+    
+    if (http_client->mime_parts)
+    {
+        int i = 0;
+        for (i = 0; i < axutil_array_list_size(http_client->mime_parts, env); i++)
+        {
+            axiom_mime_part_t *mime_part = NULL;
+            mime_part = (axiom_mime_part_t *)
+                axutil_array_list_get(http_client->mime_parts, env, i);
+            if (mime_part)
+            {
+                axiom_mime_part_free(mime_part, env);
+            }
+        }
+        axutil_array_list_free(http_client->mime_parts, env);
+    }
 
     AXIS2_FREE(env->allocator, http_client);
     return;
@@ -129,6 +156,12 @@
     return;
 }
 
+/*This is the main method which writes to the socket in the case of a client 
+ * sends an http_request. Previously this mrthod does not distinguish between a 
+ * mtom request and non mtom request. Because what finally it had was the 
+ * complete buffer with the request. But now MTOM invocations are done 
+ * differently so this method should distinguish those invocations*/
+
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 axis2_http_client_send(
     axis2_http_client_t * client,
@@ -146,7 +179,10 @@
     axis2_char_t *host = NULL;
     unsigned int port = 0; 
 
-    if (!client->req_body)
+    /* In the MTOM case request body is not set. Instead mime_parts
+       array_list is there */
+
+    if (!client->req_body && !(client->doing_mtom))
     {
         client->req_body_size = axis2_http_simple_request_get_body_bytes(request, env, 
                 &client->req_body);
@@ -339,6 +375,8 @@
         host_port_str = NULL;
 
     }
+    
+    /* Here first we send the http header part */ 
 
     wire_format = axutil_stracat(env, str_request_line, str_header);
     AXIS2_FREE(env->allocator, str_header);
@@ -348,27 +386,64 @@
     written = axutil_stream_write(client->data_stream, env, wire_format, axutil_strlen(wire_format));
     AXIS2_FREE(env->allocator, wire_format);
     wire_format = NULL;
+
+    /* Then we write the two new line charaters before the http body*/
+
     written = axutil_stream_write(client->data_stream, env, AXIS2_HTTP_CRLF, 2);
-    if (client->req_body_size > 0 && client->req_body)
+    
+    /* When sending MTOM it is bit different. We keep the attachment + other
+       mime headers in an array_list and send them one by one */
+
+    if(client->doing_mtom)
+    {
+        axis2_status_t status = AXIS2_SUCCESS;
+        axutil_http_chunked_stream_t *chunked_stream = NULL;
+        
+        /* For MTOM we automatically enabled chunking */
+        chunked_stream = axutil_http_chunked_stream_create(env, 
+                client->data_stream);
+    
+        /* This method will write the Attachment + data to the wire */
+
+        status = axis2_http_transport_utils_send_mtom_message(chunked_stream, env, 
+                client->mime_parts);      
+
+        axutil_http_chunked_stream_free(chunked_stream, env);
+        chunked_stream = NULL;
+          
+    }
+    /* Non MTOM case */
+    else if (client->req_body_size > 0 && client->req_body)
     {
+        int len = 0;
+        written = 0;
+
+        /* Keep on writing data in a loop until we finised 
+           with all the data in the buffer */
+
         if (!chunking_enabled)
         {
             status = AXIS2_SUCCESS;
             while (written < client->req_body_size)
             {
-                written = axutil_stream_write(client->data_stream, env, client->req_body, 
-                    client->req_body_size);
-                if (-1 == written)
+                len = 0;
+                len = axutil_stream_write(client->data_stream, env,
+                                              client->req_body + written,
+                                              client->req_body_size - written);
+                if (-1 == len)
                 {
                     status = AXIS2_FAILURE;
                     break;
                 }
+                else
+                {
+                    written += len;
+                }
             }
         }
         else
         {
-
-            /* Sending HTTP request via chunking */
+            /* Not MTOM but chunking is enabled */
             axutil_http_chunked_stream_t *chunked_stream = NULL;
             chunked_stream = axutil_http_chunked_stream_create(env, client->data_stream);
             status = AXIS2_SUCCESS;
@@ -392,6 +467,7 @@
 
             if (AXIS2_SUCCESS == status)
             {
+                /* Writing the trailing null charactor */
                 axutil_http_chunked_stream_write_last_chunk(chunked_stream, env);
             }
 
@@ -812,3 +888,41 @@
 {
     return client->key_file;
 }
+
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_http_client_set_mime_parts(
+    axis2_http_client_t * client,
+    const axutil_env_t * env,
+    axutil_array_list_t *mime_parts)
+{
+    client->mime_parts = mime_parts;
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL
+axis2_http_client_get_mime_parts(
+    const axis2_http_client_t * client,
+    const axutil_env_t * env)
+{
+    return client->mime_parts;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+axis2_http_client_set_doing_mtom(
+    axis2_http_client_t * client,
+    const axutil_env_t * env,
+    axis2_bool_t doing_mtom)
+{
+    client->doing_mtom = doing_mtom;
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXTERN axis2_bool_t AXIS2_CALL
+axis2_http_client_get_doing_mtom(
+    const axis2_http_client_t * client,
+    const axutil_env_t * env)
+{
+    return client->doing_mtom;
+}
+

Modified: webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/sender/http_sender.c Tue Jul 22 01:43:36 2008
@@ -484,8 +484,28 @@
 
         if (doing_mtom)
         {
-            axiom_output_flush (sender->om_output, env, &output_stream,
-                                &output_stream_size);
+            axis2_status_t mtom_status = AXIS2_FAILURE;
+            axutil_array_list_t *mime_parts = NULL;
+
+            /* Here we put all the attachment related stuff in a array_list
+               After this method we have the message in parts */
+
+            mtom_status = axiom_output_flush (sender->om_output, env);
+            if(mtom_status == AXIS2_FAILURE)
+            {
+                return mtom_status;
+            }
+            /* HTTP client should distinguish an MTOM invocation because the way
+               of sending the message in MTOM case is different */
+            axis2_http_client_set_doing_mtom(sender->client, env, doing_mtom);
+
+            /* HTTP client will keep this mime_parts, which it will send in chunks at
+               th end */
+            mime_parts = axiom_output_get_mime_parts(sender->om_output, env);
+            if(mime_parts)
+            {
+                axis2_http_client_set_mime_parts(sender->client, env, mime_parts);    
+            }
         }
         else
         {
@@ -801,17 +821,11 @@
         header = NULL;
     }
 
-    if (doing_mtom)
-    {
-        axutil_stream_t *stream = axis2_http_simple_request_get_body (request,
-                                                                      env);
-        if (stream)
-        {
-            axutil_stream_write (stream, env, output_stream,
-                                 output_stream_size);
-        }
-    }
-    else
+    /* If this is a normal invocation the buffer has the full SOAP message
+       which needs to be send. In the MTOM case instead of this buffer 
+       it has the mime_parts array_list */
+
+    if(!doing_mtom)
     {
         axis2_http_simple_request_set_body_string (request,
                                                    env, buffer, buffer_size);

Modified: webservices/axis2/trunk/c/src/core/transport/http/sender/http_transport_sender.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/sender/http_transport_sender.c?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/sender/http_transport_sender.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/sender/http_transport_sender.c Tue Jul 22 01:43:36 2008
@@ -29,6 +29,7 @@
 #include <axiom_soap_body.h>
 #include <axutil_types.h>
 #include <axiom_soap_fault_detail.h>
+#include <axis2_msg_ctx.h>
 
 #ifdef AXIS2_LIBCURL_ENABLED
 #include "libcurl/axis2_libcurl.h"
@@ -180,7 +181,6 @@
     axis2_bool_t do_mtom;
     axutil_property_t *property = NULL;
     axiom_node_t *data_out = NULL;
-    axis2_byte_t *output_stream = NULL;
     int buffer_size = 0;
     axis2_status_t status = AXIS2_SUCCESS;
     axis2_conf_ctx_t *conf_ctx = NULL;
@@ -229,7 +229,6 @@
     }
 
     do_mtom = axis2_http_transport_utils_do_write_mtom(env, msg_ctx);
-    axis2_msg_ctx_set_doing_mtom(msg_ctx, env, do_mtom);
 
     transport_url = axis2_msg_ctx_get_transport_url(msg_ctx, env);
     if (transport_url)
@@ -291,6 +290,9 @@
     /* setting SOAP version for OM_OUTPUT.  */
     axiom_output_set_soap11(om_output, env,
                             axis2_msg_ctx_get_is_soap_11(msg_ctx, env));
+    
+    /* This is the case where normal client send the requet using a http_client*/
+    
     if (epr)
     {
         if (axutil_strcmp
@@ -525,18 +527,34 @@
                                               AXIS2_FALSE);
                 if (do_mtom)
                 {
+                    axis2_status_t mtom_status = AXIS2_FAILURE;
                     axis2_char_t *content_type = NULL;
-                    axiom_output_flush(om_output, env, &output_stream,
-                                       &buffer_size);
+                    axutil_array_list_t *mime_parts = NULL;
+                   
+                    /*Create the attachment related data and put them to an
+                     *arra_list */
+                    mtom_status = axiom_output_flush(om_output, env);
+                    if(mtom_status == AXIS2_SUCCESS)
+                    {
+                        mime_parts = axiom_output_get_mime_parts(om_output, env);
+                        if(!mime_parts)
+                        {
+                            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, 
+                            "Unable to create the mime_part list from om_output");
+                            return AXIS2_FAILURE;
+                        }
+                        else
+                        {
+                            axis2_msg_ctx_set_mime_parts(msg_ctx, env, mime_parts);
+                        }
+                    }
+                    /*om_out put has the details of content_type */
                     content_type =
                         (axis2_char_t *)
                         axiom_output_get_content_type(om_output, env);
                     AXIS2_HTTP_OUT_TRANSPORT_INFO_SET_CONTENT_TYPE(out_info,
                                                                    env,
                                                                    content_type);
-                    buffer = output_stream;
-                    axutil_stream_write(out_stream, env, buffer, buffer_size);
-                    AXIS2_FREE(env->allocator, buffer);
                 }
                 else
                 {
@@ -754,13 +772,23 @@
         return AXIS2_FAILURE;
     }
 
-    AXIS2_HTTP_SENDER_SET_CHUNKED(sender, env,
-                                  AXIS2_INTF_TO_IMPL(transport_sender)->
-                                  chunked);
+    /* For the MTOM case we should on chunking. And for chunking to work the
+     * protocol should be http 1.1*/
+
+    if(axis2_msg_ctx_get_doing_mtom(msg_ctx, env))
+    {
+        AXIS2_HTTP_SENDER_SET_CHUNKED(sender, env, AXIS2_TRUE);
+        AXIS2_HTTP_SENDER_SET_HTTP_VERSION(sender, env, AXIS2_HTTP_HEADER_PROTOCOL_11);        
+    }
+    else
+    {
+        AXIS2_HTTP_SENDER_SET_CHUNKED(sender, env,
+            AXIS2_INTF_TO_IMPL(transport_sender)->chunked);
+        AXIS2_HTTP_SENDER_SET_HTTP_VERSION(sender, env,
+            AXIS2_INTF_TO_IMPL(transport_sender)->http_version);
+    }
     AXIS2_HTTP_SENDER_SET_OM_OUTPUT(sender, env, om_output);
-    AXIOM_SENDER_SET_HTTP_VERSION(sender, env,
-                                  AXIS2_INTF_TO_IMPL(transport_sender)->
-                                  http_version);
+
 #ifdef AXIS2_LIBCURL_ENABLED
     AXIS2_LOG_DEBUG (env->log, AXIS2_LOG_SI, "using axis2 libcurl http sender.");
     status =

Modified: webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c?rev=678680&r1=678679&r2=678680&view=diff
==============================================================================
--- webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c (original)
+++ webservices/axis2/trunk/c/src/core/transport/http/server/apache2/apache2_worker.c Tue Jul 22 01:43:36 2008
@@ -34,9 +34,27 @@
 #include <axiom_soap.h>
 #include <axutil_class_loader.h>
 #include <axutil_string_util.h>
+#include <axiom_mime_part.h>
 
 #define READ_SIZE  2048
 
+static axis2_status_t apache2_worker_send_mtom_message(
+    request_rec *request,
+    const axutil_env_t * env,
+    axutil_array_list_t *mime_parts);
+
+static axis2_status_t 
+axis2_http_transport_utils_send_attachment(
+    const axutil_env_t * env,
+    request_rec *request,
+    FILE *fp,
+    axis2_byte_t *buffer,
+    int buffer_size);
+
+static void apache2_worker_destroy_mime_parts(
+    axutil_array_list_t *mime_parts,
+    const axutil_env_t *env);
+
 struct axis2_apache2_worker
 {
     axis2_conf_ctx_t *conf_ctx;
@@ -173,6 +191,8 @@
     axis2_char_t *accept_charset_header_value = NULL;
     axis2_char_t *accept_language_header_value = NULL;
     axis2_char_t *content_language_header_value = NULL;
+    axis2_bool_t do_mtom = AXIS2_FALSE;
+    axutil_array_list_t *mime_parts = NULL;
 
     AXIS2_ENV_CHECK(env, AXIS2_CRITICAL_FAILURE);
     AXIS2_PARAM_CHECK(env->error, request, AXIS2_CRITICAL_FAILURE);
@@ -214,6 +234,18 @@
         content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_PLAIN;
     }
     request->content_type = content_type;
+
+    out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf
+                                            (apache2_worker->conf_ctx, env),
+                                            env, AXIS2_TRANSPORT_ENUM_HTTP);
+    in_desc =
+        axis2_conf_get_transport_in(axis2_conf_ctx_get_conf
+                                    (apache2_worker->conf_ctx, env), env,
+                                    AXIS2_TRANSPORT_ENUM_HTTP);
+
+    msg_ctx = axis2_msg_ctx_create(env, conf_ctx, in_desc, out_desc);
+    axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);
+
     if (request->read_chunked == AXIS2_TRUE && 0 == content_length)
     {
         content_length = -1;
@@ -229,17 +261,6 @@
     AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "Client HTTP version %s",
                     http_version);
 
-    out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf
-                                            (apache2_worker->conf_ctx, env),
-                                            env, AXIS2_TRANSPORT_ENUM_HTTP);
-    in_desc =
-        axis2_conf_get_transport_in(axis2_conf_ctx_get_conf
-                                    (apache2_worker->conf_ctx, env), env,
-                                    AXIS2_TRANSPORT_ENUM_HTTP);
-
-    msg_ctx = axis2_msg_ctx_create(env, conf_ctx, in_desc, out_desc);
-    axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE);
-
     peer_ip = request->connection->remote_ip;
     
     if (peer_ip)
@@ -1159,6 +1180,18 @@
         out_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_OUT];
         in_msg_ctx = msg_ctx_map[AXIS2_WSDL_MESSAGE_LABEL_IN];
 
+        /* In mtom case we send the attachment differently */
+
+        do_mtom = axis2_msg_ctx_get_doing_mtom(out_msg_ctx, env);
+        if(do_mtom)
+        {
+            mime_parts = axis2_msg_ctx_get_mime_parts(out_msg_ctx, env);
+            if(!mime_parts)
+            {
+                return AXIS2_FAILURE;
+            }
+        }
+
         if (out_msg_ctx)
         {
             axis2_msg_ctx_free(out_msg_ctx, env);
@@ -1189,7 +1222,27 @@
         }
 
     }                           /* Done freeing message contexts */
-    if (body_string)
+
+    /* We send the message in parts when doing MTOM */
+
+    if(do_mtom)
+    {
+        axis2_status_t mtom_status = AXIS2_FAILURE;
+        mtom_status = apache2_worker_send_mtom_message(request, env, mime_parts);
+        if(mtom_status == AXIS2_SUCCESS)
+        {
+            send_status = DONE;
+        }
+        else
+        {
+            send_status = DECLINED;
+        }
+
+        apache2_worker_destroy_mime_parts(mime_parts, env);
+        mime_parts = NULL;
+    }
+
+    else if (body_string)
     {
         ap_rwrite(body_string, body_string_len, request);
         body_string = NULL;
@@ -1252,3 +1305,177 @@
     axutil_stream_free(tmp_stream, env);
     return buffer;
 }
+
+
+static axis2_status_t apache2_worker_send_mtom_message(
+    request_rec *request,
+    const axutil_env_t * env,
+    axutil_array_list_t *mime_parts)
+{
+    int i = 0;
+    axiom_mime_part_t *mime_part = NULL;
+    axis2_status_t status = AXIS2_SUCCESS;
+    /*int written = 0;*/
+    int len = 0;    
+
+    if(mime_parts)
+    {
+        for(i = 0; i < axutil_array_list_size
+                (mime_parts, env); i++)
+        {
+            mime_part = (axiom_mime_part_t *)axutil_array_list_get(
+                mime_parts, env, i);
+            if((mime_part->type) == AXIOM_MIME_PART_BUFFER)
+            {
+                len = 0;
+                len = ap_rwrite(mime_part->part, mime_part->part_size, request);
+                ap_rflush(request);
+                if(len == -1)
+                {
+                    status = AXIS2_FAILURE;
+                    break;
+                }
+            }
+            else if((mime_part->type) == AXIOM_MIME_PART_FILE)
+            {
+                FILE *f = NULL;
+                axis2_byte_t *output_buffer = NULL;                
+                int output_buffer_size = 0;
+
+                f = fopen(mime_part->file_name, "rb");
+                if (!f)
+                {
+                    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+                        "Error opening file %s for reading",
+                    mime_part->file_name);
+                    return AXIS2_FAILURE;
+                }
+                if(mime_part->part_size > AXIS2_MTOM_OUTPUT_BUFFER_SIZE)
+                {
+                    output_buffer_size = AXIS2_MTOM_OUTPUT_BUFFER_SIZE;
+                }
+                else
+                {
+                    output_buffer_size = mime_part->part_size;
+                }
+               
+                output_buffer =  AXIS2_MALLOC(env->allocator, 
+                    (output_buffer_size + 1) * sizeof(axis2_char_t));
+ 
+ 
+                status = axis2_http_transport_utils_send_attachment(env, request, 
+                    f, output_buffer, output_buffer_size);
+                if(status == AXIS2_FAILURE)
+                {
+                    return status;
+                }
+            }
+            else
+            {
+                return AXIS2_FAILURE;
+            }
+            if(status == AXIS2_FAILURE)
+            {
+                break;
+            }
+        }
+        return status;
+    }    
+    else
+    {
+        return AXIS2_FAILURE;
+    }    
+}
+
+
+static axis2_status_t
+axis2_http_transport_utils_send_attachment(
+    const axutil_env_t * env,
+    request_rec *request,
+    FILE *fp,
+    axis2_byte_t *buffer,
+    int buffer_size)
+{
+
+    int count = 0;     
+    int len = 0;
+    /*int written = 0;*/
+    axis2_status_t status = AXIS2_SUCCESS;   
+ 
+    do
+    {
+        count = (int)fread(buffer, 1, buffer_size + 1, fp);
+        if (ferror(fp))
+        {
+            AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+                "Error in reading file containg the attachment");
+            if (buffer)
+            {
+                AXIS2_FREE(env->allocator, buffer);
+                buffer = NULL;
+            }
+            fclose(fp);
+            return AXIS2_FAILURE;
+        }
+
+        if(count > 0)
+        {
+            len = 0;
+            len = ap_rwrite(buffer, count, request);
+            ap_rflush(request);
+            if(len == -1)
+            {
+                status = AXIS2_FAILURE;
+                break;
+            }
+        }
+        else
+        {
+            if (buffer)
+            {
+                AXIS2_FREE(env->allocator, buffer);
+                buffer = NULL;
+            }
+            fclose(fp);
+            return AXIS2_FAILURE;
+        }   
+        memset(buffer, 0, buffer_size);    
+        if(status == AXIS2_FAILURE)
+        {
+            if (buffer)
+            {
+                AXIS2_FREE(env->allocator, buffer);
+                buffer = NULL;
+            }
+            fclose(fp);
+            return AXIS2_FAILURE;
+        } 
+    }
+    while(!feof(fp));
+    
+    fclose(fp);
+    AXIS2_FREE(env->allocator, buffer);
+    buffer = NULL;    
+    return AXIS2_SUCCESS;    
+}
+
+static void apache2_worker_destroy_mime_parts(
+    axutil_array_list_t *mime_parts,
+    const axutil_env_t *env)
+{
+    if (mime_parts)
+    {
+        int i = 0;
+        for (i = 0; i < axutil_array_list_size(mime_parts, env); i++)
+        {
+            axiom_mime_part_t *mime_part = NULL;
+            mime_part = (axiom_mime_part_t *)
+                axutil_array_list_get(mime_parts, env, i);
+            if (mime_part)
+            {
+                axiom_mime_part_free(mime_part, env);
+            }
+        }
+        axutil_array_list_free(mime_parts, env);
+    }
+}

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