ws-axis-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r391562 - in /webservices/axis2/trunk/c: include/ modules/core/transport/http/ modules/core/transport/http/sender/ modules/core/transport/http/server/apache2/
Date Wed, 05 Apr 2006 08:48:53 GMT
Author: sahan
Date: Wed Apr  5 01:48:51 2006
New Revision: 391562

URL: http://svn.apache.org/viewcvs?rev=391562&view=rev
Log:
REST thru POST works on server side. Client side code is in place. Didn't test

Added:
    webservices/axis2/trunk/c/include/axis2_rest_sender.h
    webservices/axis2/trunk/c/modules/core/transport/http/sender/rest_sender.c
Modified:
    webservices/axis2/trunk/c/include/axis2_soap_body.h
    webservices/axis2/trunk/c/modules/core/transport/http/http_transport_utils.c
    webservices/axis2/trunk/c/modules/core/transport/http/sender/Makefile.am
    webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c
    webservices/axis2/trunk/c/modules/core/transport/http/server/apache2/mod_axis2.c

Added: webservices/axis2/trunk/c/include/axis2_rest_sender.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_rest_sender.h?rev=391562&view=auto
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_rest_sender.h (added)
+++ webservices/axis2/trunk/c/include/axis2_rest_sender.h Wed Apr  5 01:48:51 2006
@@ -0,0 +1,126 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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_REST_SENDER_H
+#define AXIS2_REST_SENDER_H
+
+/**
+ * @file axis2_rest_sender.h
+ * @brief axis2 REST sender
+ */
+
+#include <axis2.h>
+#include <axis2_defines.h>
+#include <axis2_env.h>
+#include <axis2_msg_ctx.h>
+#include <axis2_om_output.h>
+#include <axis2_http_simple_response.h>
+#include <axis2_soap_envelope.h>
+
+
+#ifdef __cplusplus
+extern "C" 
+{
+#endif
+/** 
+  * @ingroup axis2_core_transport_http
+  * @{
+  */
+
+typedef struct axis2_rest_sender_ops axis2_rest_sender_ops_t;
+typedef struct axis2_rest_sender axis2_rest_sender_t;
+    
+    
+/** 
+ * @brief REST sender ops struct
+ * Encapsulator struct for ops of axis2_rest_sender
+ */
+AXIS2_DECLARE_DATA struct axis2_rest_sender_ops
+{
+	axis2_status_t (AXIS2_CALL *send) 
+                                (axis2_rest_sender_t *sender, 
+                                axis2_env_t **env, axis2_msg_ctx_t *msg_ctx,
+								axis2_om_node_t *out, 
+								axis2_char_t *str_url);
+	
+	axis2_status_t (AXIS2_CALL *set_chunked) 
+                                (axis2_rest_sender_t *sender, 
+                                axis2_env_t **env, axis2_bool_t chunked);
+	
+	axis2_status_t (AXIS2_CALL *set_om_output)
+                                (axis2_rest_sender_t *sender, 
+                                axis2_env_t **env, axis2_om_output_t *om_output);
+	
+	axis2_status_t (AXIS2_CALL *set_http_version)
+								(axis2_rest_sender_t *sender, 
+								axis2_env_t **env, axis2_char_t *version);
+	
+	axis2_status_t (AXIS2_CALL *free) 
+                                (axis2_rest_sender_t *sender, 
+                                axis2_env_t **env);
+};
+
+    
+axis2_status_t AXIS2_CALL 
+axis2_rest_sender_get_header_info 
+								(axis2_rest_sender_t *sender, 
+                                axis2_env_t **env, axis2_msg_ctx_t *msg_ctx, 
+								axis2_http_simple_response_t *response);
+
+axis2_status_t AXIS2_CALL
+axis2_rest_sender_process_response 
+								(axis2_rest_sender_t *sender, 
+                                axis2_env_t **env, axis2_msg_ctx_t *msg_ctx, 
+								axis2_http_simple_response_t *response);
+
+axis2_status_t AXIS2_CALL
+axis2_rest_sender_get_timeout_values 
+								(axis2_rest_sender_t *sender, 
+                                axis2_env_t **env, axis2_msg_ctx_t *msg_ctx);
+
+/**
+ * @brief REST sender struct
+ * Axis2 REST sender
+ */
+AXIS2_DECLARE_DATA struct axis2_rest_sender
+{
+	axis2_rest_sender_ops_t *ops;
+};
+
+
+AXIS2_DECLARE(axis2_rest_sender_t *) 
+axis2_rest_sender_create(axis2_env_t **env);
+
+/********************* Start of function macros	***************************/
+
+#define AXIS2_REST_SENDER_SEND(sender, env, msg_ctx, output, url)\
+                        ((sender)->ops->send (sender, env, msg_ctx,output, url))
+#define AXIS2_REST_SENDER_SET_CHUNKED(sender, env, chunked) \
+                        ((sender)->ops->set_chunked(sender, env, chunked))
+#define AXIS2_REST_SENDER_SET_OM_OUTPUT(sender, env, om_output) \
+                        ((sender)->ops->set_om_output (sender, env, om_output))
+#define AXIS2_REST_SENDER_SET_HTTP_VERSION(sender, env, version)\
+                        ((sender)->ops->set_http_version (sender, env, version))
+#define AXIS2_REST_SENDER_FREE(sender, env) \
+                        ((sender)->ops->free(sender, env))
+
+/************************* End of function macros *****************************/
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+#endif /* AXIS2_REST_SENDER_H */

Modified: webservices/axis2/trunk/c/include/axis2_soap_body.h
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/include/axis2_soap_body.h?rev=391562&r1=391561&r2=391562&view=diff
==============================================================================
--- webservices/axis2/trunk/c/include/axis2_soap_body.h (original)
+++ webservices/axis2/trunk/c/include/axis2_soap_body.h Wed Apr  5 01:48:51 2006
@@ -184,7 +184,7 @@
         ((body)->ops->build( body, env))
 
 #define AXIS2_SOAP_BODY_ADD_CHILD( body, env, child) \
-        ((body)->ops->add_child( body, env, child);
+        ((body)->ops->add_child( body, env, child));
 /** @} */
 #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=391562&r1=391561&r2=391562&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 Wed Apr 
5 01:48:51 2006
@@ -240,8 +240,7 @@
 	else if(NULL != strstr(content_type, AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML))
 	{
 		is_soap11 = AXIS2_TRUE;
-		/*if(NULL != soap_action_header && AXIS2_STRLEN(soap_action_header)
-					> 0)*/
+		if(NULL != soap_action_header)
 		{
 			soap_builder = axis2_soap_builder_create(env, om_builder, 
 						AXIS2_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI);
@@ -265,15 +264,28 @@
 				return AXIS2_FAILURE;
 			}
 		}
-		/* REST support
-		 * else
-		 * {
-		 *		envelope = AXIS2_SOAP_ENVELOPE_GET_DEFAULT_SOAP_ENVELOPE(
-		 *			env);
-		 *		AXIS2_SOAP_BODY_ADD_CHILD(AXIS2_SOAP_ENVELOPE_GET_BODY(
-		 *			envelope, env), AXIS2_OM_STAX_BUILDER_GET_DOCUMENT(
-		 *			om_builder, env));
-		 */			
+        else
+        {
+            /* REST support */
+            axis2_param_t *rest_param = AXIS2_MSG_CTX_GET_PARAMETER(msg_ctx, env
+                        , AXIS2_ENABLE_REST);
+            if(NULL != rest_param && 0 == AXIS2_STRCMP(AXIS2_VALUE_TRUE, 
+                        AXIS2_PARAM_GET_VALUE(rest_param, env)))
+            {
+                /* TODO we have to check for NULLs */
+                axis2_soap_body_t *def_body = NULL;
+                axis2_om_document_t *om_doc = NULL;
+                axis2_om_node_t *root_node = NULL;
+                soap_envelope = axis2_soap_envelope_create_default_soap_envelope
+                            (env, AXIS2_SOAP11);
+                def_body = AXIS2_SOAP_ENVELOPE_GET_BODY(soap_envelope, env);
+                om_doc = AXIS2_OM_STAX_BUILDER_GET_DOCUMENT(om_builder, env);
+                root_node = AXIS2_OM_DOCUMENT_BUILD_ALL(om_doc, env);
+                AXIS2_SOAP_BODY_ADD_CHILD(def_body, env, root_node);
+                AXIS2_MSG_CTX_SET_DOING_REST(msg_ctx, env, AXIS2_TRUE);
+            }
+        }
+		 		
 	}
 	/* xml_char_set = AXIS2_OM_DOCUMENT_GET_CHARSET_ENC(
 	 *					AXIS2_OM_STAX_BUILDER_GET_DOCUMENT(env om_builder),

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/Makefile.am
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/sender/Makefile.am?rev=391562&r1=391561&r2=391562&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/Makefile.am (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/Makefile.am Wed Apr  5 01:48:51
2006
@@ -2,6 +2,7 @@
 lib_LTLIBRARIES = libaxis2_http_sender.la
 libaxis2_http_sender_la_SOURCES = http_transport_sender.c\
                                   soap_over_http_sender.c\
+                                  rest_sender.c\
                                   http_client.c
 
 INCLUDES = -I$(top_builddir)/include \

Modified: webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c?rev=391562&r1=391561&r2=391562&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/http_transport_sender.c Wed
Apr  5 01:48:51 2006
@@ -24,6 +24,8 @@
 #include <axis2_http_out_transport_info.h>
 #include <axis2_http_transport.h>
 #include <axis2_soap_over_http_sender.h>
+#include <axis2_soap_body.h>
+#include <axis2_rest_sender.h>
 #include <axis2_types.h>
 
 
@@ -159,12 +161,10 @@
 	axis2_soap_envelope_t *soap_data_out = NULL;
 	axis2_bool_t do_mtom;
     axis2_property_t *property = NULL;
+    axis2_om_node_t *data_out = NULL;
 	
 	AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
 	AXIS2_PARAM_CHECK((*env)->error, msg_ctx, AXIS2_FAILURE);
-
-	xml_writer = axis2_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0);
-	om_output = axis2_om_output_create(env, xml_writer);
 	
 	property = AXIS2_MSG_CTX_GET_PROPERTY(msg_ctx, env, 
 							AXIS2_CHARACTER_SET_ENCODING, AXIS2_FALSE);
@@ -203,9 +203,9 @@
 	do_mtom = axis2_http_transport_utils_do_write_mtom(env,
 							msg_ctx);
 	AXIS2_MSG_CTX_SET_DOING_MTOM(msg_ctx, env, do_mtom);
-	AXIS2_MSG_CTX_SET_DOING_REST(msg_ctx, 
+	/*AXIS2_MSG_CTX_SET_DOING_REST(msg_ctx, 
 							env, axis2_http_transport_utils_is_doing_rest(env, 
-							msg_ctx));
+							msg_ctx));*/
 	property = (axis2_property_t*)AXIS2_MSG_CTX_GET_PROPERTY(msg_ctx, env, 
 							AXIS2_TRANSPORT_URL, AXIS2_FALSE);
     if(property)
@@ -230,30 +230,29 @@
 		}
 	}
 	
-	/*if(AXIS2_TRUE == AXIS2_MSG_CTX_IS_DOING_REST(msg_ctx, env))
-	 *{
-	 *	data_out = AXIS2_SOAP_BODY_GET_FIRST_ELEMENT(AXIS2_SOAP_ENVELOPE_GET_BODY(
-							AXIS2_MSG_CTX_GET_ENVELOPE(msg_ctx, env), env),env);
-	 *}
-	 * else
-	 */
-	{
-		soap_data_out = AXIS2_MSG_CTX_GET_SOAP_ENVELOPE(msg_ctx, env);
-		if(NULL == soap_data_out)
-		{
-			char error_msg[1024];
-			AXIS2_ERROR_SET((*env)->error, 
-						AXIS2_ERROR_NULL_SOAP_ENVELOPE_IN_MSG_CTX, 
-						AXIS2_FAILURE);
-			sprintf(error_msg, "%s in %s:%d", AXIS2_ERROR_GET_MESSAGE(
-						(*env)->error), __FILE__, __LINE__);
-			AXIS2_LOG(env, error_msg, AXIS2_LOG_LEVEL_CRITICAL);
-			AXIS2_OM_OUTPUT_FREE(om_output, env);
-			om_output = NULL;
-			xml_writer = NULL;
-			return AXIS2_FAILURE;
-		}
-	}
+    soap_data_out = AXIS2_MSG_CTX_GET_SOAP_ENVELOPE(msg_ctx, env);
+    if(NULL == soap_data_out)
+    {
+        AXIS2_ERROR_SET((*env)->error, 
+                    AXIS2_ERROR_NULL_SOAP_ENVELOPE_IN_MSG_CTX, 
+                    AXIS2_FAILURE);
+        AXIS2_LOG_ERROR((*env)->log, AXIS2_LOG_SI, "%s", 
+                        AXIS2_ERROR_GET_MESSAGE((*env)->error));
+        return AXIS2_FAILURE;
+    }
+    xml_writer = axis2_xml_writer_create_for_memory(env, NULL, 
+                    AXIS2_TRUE, 0);
+    if(NULL == xml_writer)
+    {
+        return AXIS2_FAILURE;
+    }
+    om_output = axis2_om_output_create(env, xml_writer);
+    if(NULL == om_output)
+    {
+        AXIS2_XML_WRITER_FREE(xml_writer, env);
+        xml_writer = NULL;
+        return AXIS2_FAILURE;
+    }
 	if(NULL != epr)
 	{
 		axis2_http_transport_sender_write_message(transport_sender, env, msg_ctx
@@ -292,6 +291,9 @@
 			{
 				AXIS2_ERROR_SET((*env)->error, 
 							AXIS2_ERROR_OUT_TRNSPORT_INFO_NULL, AXIS2_FAILURE);
+                AXIS2_OM_OUTPUT_FREE(om_output, env);
+                om_output = NULL;
+                xml_writer = NULL;
 				return AXIS2_FAILURE;
 			}
 			is_soap11 = AXIS2_MSG_CTX_GET_IS_SOAP_11(msg_ctx, env);
@@ -315,9 +317,50 @@
 			/* AXIS2_OM_OUTPUT_SET_DO_OPTIMIZE(om_output, env, 
 			 *				AXIS2_MSG_CTX_GET_IS_DOING_MTOM(msg_ctx, env);
 			 */
-			AXIS2_SOAP_ENVELOPE_SERIALIZE (soap_data_out, env, om_output, 
-						AXIS2_FALSE);
-			buffer = AXIS2_XML_WRITER_GET_XML(xml_writer, env);
+            if(AXIS2_TRUE == AXIS2_MSG_CTX_GET_DOING_REST(msg_ctx, env))
+            {
+                axis2_om_node_t *body_node = NULL;
+                axis2_soap_body_t *soap_body = AXIS2_SOAP_ENVELOPE_GET_BODY(
+                                soap_data_out, env);
+                
+                if(NULL == soap_body)
+                {
+                    AXIS2_ERROR_SET((*env)->error, 
+                                AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL, 
+                                AXIS2_FAILURE);
+                    AXIS2_LOG_ERROR((*env)->log, AXIS2_LOG_SI, "%s", 
+                                AXIS2_ERROR_GET_MESSAGE((*env)->error));
+                    AXIS2_OM_OUTPUT_FREE(om_output, env);
+                    om_output = NULL;
+                    xml_writer = NULL;
+                    return AXIS2_FAILURE;
+                }
+                body_node = AXIS2_SOAP_BODY_GET_BASE_NODE(soap_body,env);
+                if(NULL == body_node)
+                {
+                    AXIS2_OM_OUTPUT_FREE(om_output, env);
+                    om_output = NULL;
+                    xml_writer = NULL;
+                    return AXIS2_FAILURE;
+                }
+                data_out = AXIS2_OM_NODE_GET_FIRST_CHILD(body_node, env);
+                if(NULL == data_out || AXIS2_OM_NODE_GET_NODE_TYPE(data_out,env)
+                                != AXIS2_OM_ELEMENT)
+                {
+                    AXIS2_OM_OUTPUT_FREE(om_output, env);
+                    om_output = NULL;
+                    xml_writer = NULL;
+                    return AXIS2_FAILURE;
+                }
+                AXIS2_OM_NODE_SERIALIZE(data_out, env, om_output);
+                buffer = AXIS2_XML_WRITER_GET_XML(xml_writer, env);
+            }
+            else
+            {
+                AXIS2_SOAP_ENVELOPE_SERIALIZE (soap_data_out, env, om_output, 
+                            AXIS2_FALSE);
+                buffer = AXIS2_XML_WRITER_GET_XML(xml_writer, env);
+            }
 			AXIS2_STREAM_WRITE(out_stream, env, buffer, AXIS2_STRLEN(buffer));				
 			AXIS2_FREE((*env)->allocator, buffer);
 	
@@ -500,35 +543,62 @@
 	{
 		soap_action = "";
 	}
-	/*
-	 * TODO : when REST comes
-	 * if(AXIS2_TRUE == AXIS2_MSG_CTX_IS_DOING_REST(msg_ctx, env)
-	 * {
-	 * 		axis2_rest_sender_t *sender = axis2_rest_sender_create(env)
-	 *		AXIS2_REST_SENDER_SET_FORMAT(sender, env,
-	 *					AXIS2_INTF_TO_IMPL(transport_sender)->format);
-	 *		AXIS2_REST_SENDER_SEND(sender, env, msg_ctx, data_out, url, 
-	 *					soap_action);
-	 *	}
-	 */
-	sender = axis2_soap_over_http_sender_create(env);
-	
-	if(NULL == sender)
-	{
-		return AXIS2_FAILURE;
-	}
-	AXIS2_SOAP_OVER_HTTP_SENDER_SET_CHUNKED(sender, env, 
-						AXIS2_INTF_TO_IMPL(transport_sender)->chunked);
-	AXIS2_SOAP_OVER_HTTP_SENDER_SET_OM_OUTPUT(sender, env, om_output);
-	AXIS2_SOAP_OVER_SENDER_SET_HTTP_VERSION(sender, env, 
-						AXIS2_INTF_TO_IMPL(transport_sender)->http_version);
-	status = AXIS2_SOAP_OVER_HTTP_SENDER_SEND(sender, env, msg_ctx, out, url,
-						soap_action);
-	/*
-	 * TODO check for errors
-	 */
-    AXIS2_SOAP_OVER_HTTP_SENDER_FREE(sender, env);
-    sender = NULL;
+	if(AXIS2_TRUE == AXIS2_MSG_CTX_GET_DOING_REST(msg_ctx, env))
+    {
+        axis2_om_node_t *data_out = NULL;
+        axis2_om_node_t *body_node = NULL;
+        axis2_soap_body_t *soap_body = AXIS2_SOAP_ENVELOPE_GET_BODY(out, env);
+        axis2_rest_sender_t *sender = NULL;
+        
+        if(NULL == soap_body)
+        {
+            AXIS2_ERROR_SET((*env)->error, 
+                        AXIS2_ERROR_SOAP_ENVELOPE_OR_SOAP_BODY_NULL, 
+                        AXIS2_FAILURE);
+            AXIS2_LOG_ERROR((*env)->log, AXIS2_LOG_SI, "%s", 
+                        AXIS2_ERROR_GET_MESSAGE((*env)->error));
+            return AXIS2_FAILURE;
+        }
+        body_node = AXIS2_SOAP_BODY_GET_BASE_NODE(soap_body,env);
+        if(NULL == body_node)
+        {
+            return AXIS2_FAILURE;
+        }
+        data_out = AXIS2_OM_NODE_GET_FIRST_CHILD(body_node, env);
+        if(NULL == data_out || AXIS2_OM_NODE_GET_NODE_TYPE(data_out, env)
+                        != AXIS2_OM_ELEMENT)
+        {
+            return AXIS2_FAILURE;
+        }
+	    sender = axis2_rest_sender_create(env);
+        AXIS2_REST_SENDER_SET_CHUNKED(sender, env, 
+                            AXIS2_INTF_TO_IMPL(transport_sender)->chunked);
+        AXIS2_REST_SENDER_SET_OM_OUTPUT(sender, env, om_output);
+        AXIS2_REST_SENDER_SET_HTTP_VERSION(sender, env, 
+                            AXIS2_INTF_TO_IMPL(transport_sender)->http_version);
+        status = AXIS2_REST_SENDER_SEND(sender, env, msg_ctx, data_out, url);
+    }
+	else
+    {
+        sender = axis2_soap_over_http_sender_create(env);
+        
+        if(NULL == sender)
+        {
+            return AXIS2_FAILURE;
+        }
+        AXIS2_SOAP_OVER_HTTP_SENDER_SET_CHUNKED(sender, env, 
+                            AXIS2_INTF_TO_IMPL(transport_sender)->chunked);
+        AXIS2_SOAP_OVER_HTTP_SENDER_SET_OM_OUTPUT(sender, env, om_output);
+        AXIS2_SOAP_OVER_SENDER_SET_HTTP_VERSION(sender, env, 
+                            AXIS2_INTF_TO_IMPL(transport_sender)->http_version);
+        status = AXIS2_SOAP_OVER_HTTP_SENDER_SEND(sender, env, msg_ctx, out, url
+                            , soap_action);
+        /*
+         * TODO check for errors
+         */
+        AXIS2_SOAP_OVER_HTTP_SENDER_FREE(sender, env);
+        sender = NULL;
+    }
 	return status;
 }
 

Added: webservices/axis2/trunk/c/modules/core/transport/http/sender/rest_sender.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/sender/rest_sender.c?rev=391562&view=auto
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/sender/rest_sender.c (added)
+++ webservices/axis2/trunk/c/modules/core/transport/http/sender/rest_sender.c Wed Apr  5
01:48:51 2006
@@ -0,0 +1,528 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+ 
+#include <axis2_rest_sender.h>
+#include <axis2_string.h>
+#include <axis2_http_transport.h>
+#include <string.h>
+#include <axis2_om_output.h>
+#include <axis2_op_ctx.h>
+#include <axis2_ctx.h>
+#include <axis2_http_client.h>
+#include <axis2_xml_writer.h>
+#include <axis2_property.h>
+#include <axis2_types.h>
+
+/** 
+ * @brief REST sender struct impl
+ *	Axis2 REST sender impl  
+ */
+typedef struct axis2_rest_sender_impl 
+						axis2_rest_sender_impl_t;  
+  
+struct axis2_rest_sender_impl
+{
+	axis2_rest_sender_t sender;
+	axis2_char_t *http_version;
+	axis2_bool_t chunked;
+	int so_timeout;
+	int connection_timeout;
+	axis2_om_output_t *om_output;
+	axis2_http_client_t *client;
+};
+
+#define AXIS2_INTF_TO_IMPL(sender) \
+	                    ((axis2_rest_sender_impl_t *)(sender))
+
+/***************************** Function headers *******************************/
+axis2_status_t AXIS2_CALL 
+axis2_rest_sender_get_header_info(axis2_rest_sender_t *sender, 
+						axis2_env_t **env, axis2_msg_ctx_t *msg_ctx,
+						axis2_http_simple_response_t *response);
+
+axis2_status_t AXIS2_CALL
+axis2_rest_sender_process_response(axis2_rest_sender_t *sender, 
+						axis2_env_t **env, axis2_msg_ctx_t *msg_ctx, 
+						axis2_http_simple_response_t *response);
+
+axis2_status_t AXIS2_CALL
+axis2_rest_sender_get_timeout_values(axis2_rest_sender_t *sender, 
+						axis2_env_t **env, axis2_msg_ctx_t *msg_ctx);
+
+axis2_status_t AXIS2_CALL 
+axis2_rest_sender_send(axis2_rest_sender_t *sender, 
+						axis2_env_t **env, axis2_msg_ctx_t *msg_ctx,
+						axis2_om_node_t *out, axis2_char_t *str_url);
+
+axis2_status_t AXIS2_CALL 
+axis2_rest_sender_set_chunked(axis2_rest_sender_t *sender, 
+						axis2_env_t **env, axis2_bool_t chunked);
+
+axis2_status_t AXIS2_CALL 
+axis2_rest_sender_set_om_output(axis2_rest_sender_t *sender, 
+						axis2_env_t **env, axis2_om_output_t *om_output);
+						
+axis2_status_t AXIS2_CALL
+axis2_rest_sender_set_http_version(axis2_rest_sender_t *sender, 
+									axis2_env_t **env, axis2_char_t *version);
+
+axis2_status_t AXIS2_CALL 
+axis2_rest_sender_free(axis2_rest_sender_t *sender, 
+						axis2_env_t **env);
+/***************************** End of function headers ************************/
+
+axis2_rest_sender_t * AXIS2_CALL 
+axis2_rest_sender_create(axis2_env_t **env)
+{
+    axis2_rest_sender_impl_t *sender_impl = NULL;
+    AXIS2_ENV_CHECK(env, NULL);
+
+    sender_impl =  (axis2_rest_sender_impl_t *)AXIS2_MALLOC 
+                        ((*env)->allocator, sizeof(
+                        axis2_rest_sender_impl_t));
+	
+    if(NULL == sender_impl)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+	
+    sender_impl->http_version = AXIS2_HTTP_HEADER_PROTOCOL_11;
+    sender_impl->so_timeout = AXIS2_HTTP_DEFAULT_SO_TIMEOUT;
+    sender_impl->connection_timeout = AXIS2_HTTP_DEFAULT_CONNECTION_TIMEOUT;
+	sender_impl->om_output = NULL;
+	sender_impl->chunked = AXIS2_FALSE;
+	sender_impl->client = NULL;
+    
+    sender_impl->sender.ops = AXIS2_MALLOC((*env)->allocator,
+                        sizeof(axis2_rest_sender_ops_t));
+    if(NULL == sender_impl->sender.ops)
+	{
+		axis2_rest_sender_free((axis2_rest_sender_t*)
+						sender_impl, env);
+        AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+        return NULL;
+	}
+    
+    sender_impl->sender.ops->send =
+                        axis2_rest_sender_send;
+    sender_impl->sender.ops->set_chunked =
+                        axis2_rest_sender_set_chunked;
+    sender_impl->sender.ops->set_om_output =
+                        axis2_rest_sender_set_om_output;
+	sender_impl->sender.ops->set_http_version =
+						axis2_rest_sender_set_http_version;
+    sender_impl->sender.ops->free =
+                        axis2_rest_sender_free;
+	return &(sender_impl->sender);
+}
+
+axis2_status_t AXIS2_CALL 
+axis2_rest_sender_free (axis2_rest_sender_t *sender, 
+                        axis2_env_t **env)
+{
+    axis2_rest_sender_impl_t *sender_impl = NULL;
+	AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    
+    sender_impl = AXIS2_INTF_TO_IMPL(sender);
+    if(NULL != sender_impl->http_version)
+    {
+        AXIS2_FREE((*env)->allocator, sender_impl->http_version);
+        sender_impl->http_version= NULL;
+    }    
+    if(NULL != sender->ops)
+        AXIS2_FREE((*env)->allocator, sender->ops);
+    
+    /* Do not free this here since it will be required in later processing
+     * of the response soap message
+     */
+    sender_impl->client = NULL;
+	AXIS2_FREE((*env)->allocator, sender_impl);
+	return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_rest_sender_send(axis2_rest_sender_t *sender, 
+						axis2_env_t **env, axis2_msg_ctx_t *msg_ctx,
+						axis2_om_node_t *out, axis2_char_t *str_url)
+{
+	axis2_http_simple_request_t *request = NULL;
+	axis2_http_request_line_t *request_line = NULL;
+	axis2_url_t *url = NULL;
+	axis2_rest_sender_impl_t *sender_impl = NULL;
+	axis2_xml_writer_t *xml_writer = NULL;
+	axis2_char_t *buffer = NULL;
+	axis2_char_t *char_set_enc = NULL;
+	int status_code = -1;
+	axis2_http_header_t *http_header = NULL;
+	axis2_http_simple_response_t *response = NULL;
+	axis2_char_t *content_type = NULL;
+    axis2_property_t *property = NULL;
+		
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, msg_ctx, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, out, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, str_url, AXIS2_FAILURE);
+	
+	url = axis2_url_parse_string(env, str_url);
+	sender_impl = AXIS2_INTF_TO_IMPL(sender);
+	if(NULL == url)
+	{
+		return AXIS2_FAILURE;
+	}
+    
+    if (sender_impl->client)
+    {
+        AXIS2_HTTP_CLIENT_FREE(sender_impl->client, env);
+        sender_impl->client = NULL;
+    }
+    
+	sender_impl->client = axis2_http_client_create(env, url);
+	if(NULL == sender_impl->client)
+	{
+		return AXIS2_FAILURE;
+	}
+    /* We put the client into msg_ctx so that we can free it once the processing
+     * is done at client side
+     */
+    property = axis2_property_create(env);
+    AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_REQUEST);
+    AXIS2_PROPERTY_SET_FREE_FUNC(property, env, 
+                        axis2_http_client_free_void_arg);
+    AXIS2_PROPERTY_SET_VALUE(property, env, sender_impl->client);
+    AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, AXIS2_HTTP_CLIENT,
+                    property, AXIS2_TRUE);
+
+	if(NULL == sender_impl->om_output)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NULL_OM_OUTPUT, 
+						AXIS2_FAILURE);
+		return AXIS2_FAILURE;
+	}
+	xml_writer = AXIS2_OM_OUTPUT_GET_XML_WRITER(sender_impl->om_output, env);
+	
+	property = AXIS2_MSG_CTX_GET_PROPERTY(msg_ctx, env, 
+							AXIS2_CHARACTER_SET_ENCODING, AXIS2_FALSE);
+    if(property)
+    {
+        char_set_enc = AXIS2_PROPERTY_GET_VALUE(property, env);
+        property = NULL;
+    }
+	if(NULL == char_set_enc)
+	{
+		char_set_enc = AXIS2_DEFAULT_CHAR_SET_ENCODING;
+	}
+	/* AXIS2_OM_OUTPUT_SET_DO_OPTIMIZE(om_output, env, 
+	 *				AXIS2_MSG_CTX_GET_IS_DOING_MTOM(msg_ctx, env);
+	 */
+	AXIS2_OM_NODE_SERIALIZE (out, env, sender_impl->om_output);
+	buffer = AXIS2_XML_WRITER_GET_XML(xml_writer, env);
+
+    if(NULL == buffer)
+    {
+        AXIS2_LOG_ERROR((*env)->log, AXIS2_LOG_SI, "NULL xml returned"
+                        "from xml writer");
+        return AXIS2_FAILURE;
+    }
+	
+	request_line = axis2_http_request_line_create(env, "POST", 
+						AXIS2_URL_GET_PATH(url, env), 
+						sender_impl->http_version);
+	request = axis2_http_simple_request_create(env, request_line, NULL, 0, 
+						NULL);
+	
+	http_header = axis2_http_header_create(env, AXIS2_HTTP_HEADER_USER_AGENT, 
+						"Axis2/C");
+	AXIS2_HTTP_SIMPLE_REQUEST_ADD_HEADER(request, env, http_header);
+	if(AXIS2_FALSE == sender_impl->chunked)
+	{
+		axis2_char_t tmp_buf[10];
+		sprintf(tmp_buf, "%d", strlen(buffer));
+		http_header = axis2_http_header_create(env, 
+						AXIS2_HTTP_HEADER_CONTENT_LENGTH, tmp_buf);
+		AXIS2_HTTP_SIMPLE_REQUEST_ADD_HEADER(request, env, http_header);
+	}
+	else
+	{
+		http_header = axis2_http_header_create(env, 
+						AXIS2_HTTP_HEADER_TRANSFER_ENCODING, 
+						AXIS2_HTTP_HEADER_TRANSFER_ENCODING_CHUNKED);
+		AXIS2_HTTP_SIMPLE_REQUEST_ADD_HEADER(request, env, http_header);
+	}
+	/* TODO we need to set the content type with soap action header for soap12*/
+    content_type = AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML;
+	http_header = axis2_http_header_create(env, AXIS2_HTTP_HEADER_CONTENT_TYPE, 
+						content_type);
+	AXIS2_HTTP_SIMPLE_REQUEST_ADD_HEADER(request, env, http_header);
+	if(0 == AXIS2_STRCMP(sender_impl->http_version, 
+		AXIS2_HTTP_HEADER_PROTOCOL_11))
+	{
+		http_header = axis2_http_header_create(env, 
+						AXIS2_HTTP_HEADER_HOST, 
+						AXIS2_URL_GET_SERVER(url, env));
+		AXIS2_HTTP_SIMPLE_REQUEST_ADD_HEADER(request, env, http_header);
+	}
+	AXIS2_HTTP_SIMPLE_REQUEST_SET_BODY_STRING(request, env, buffer);
+	axis2_rest_sender_get_timeout_values(sender, env, msg_ctx);
+	AXIS2_HTTP_CLIENT_SET_TIMEOUT(sender_impl->client, env, 
+						sender_impl->so_timeout);
+	
+	status_code = AXIS2_HTTP_CLIENT_SEND(sender_impl->client, env, request);
+    
+    AXIS2_FREE((*env)->allocator, buffer);
+    buffer = NULL;
+	AXIS2_HTTP_SIMPLE_REQUEST_FREE(request, env);
+	request = NULL;
+	
+	status_code = AXIS2_HTTP_CLIENT_RECIEVE_HEADER(sender_impl->client, env);
+    
+    if(status_code < 0)
+	{
+		return AXIS2_FAILURE;
+	}
+    response = AXIS2_HTTP_CLIENT_GET_RESPONSE(sender_impl->client, env);
+    if(AXIS2_HTTP_RESPONSE_OK_CODE_VAL == status_code || 
+                        AXIS2_HTTP_RESPONSE_ACK_CODE_VAL == status_code)
+    {
+        return axis2_rest_sender_process_response(sender, env, 
+                        msg_ctx, response);
+    }
+    else if(AXIS2_HTTP_RESPONSE_INTERNAL_SERVER_ERROR_CODE_VAL == status_code)
+    {
+        axis2_http_header_t *tmp_header = NULL;
+        axis2_char_t *tmp_header_val = NULL;
+        tmp_header = AXIS2_HTTP_SIMPLE_RESPONSE_GET_FIRST_HEADER(response, env,
+                        AXIS2_HTTP_HEADER_CONTENT_TYPE);
+        if(NULL != tmp_header)
+        {
+            tmp_header_val = AXIS2_HTTP_HEADER_GET_VALUE(tmp_header, env);
+        }
+        if(NULL != tmp_header_val && (AXIS2_STRSTR(tmp_header_val, 
+                        AXIS2_HTTP_HEADER_ACCEPT_APPL_SOAP) || AXIS2_STRSTR(
+                        tmp_header_val, AXIS2_HTTP_HEADER_ACCEPT_TEXT_XML)))
+        {
+            return axis2_rest_sender_process_response(sender, env, 
+                        msg_ctx, response);
+        }
+    }
+    AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_HTTP_CLIENT_TRANSPORT_ERROR, 
+                        AXIS2_FAILURE);
+    return AXIS2_FAILURE;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_rest_sender_set_chunked(axis2_rest_sender_t *sender, 
+						axis2_env_t **env, axis2_bool_t chunked)
+{
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_INTF_TO_IMPL(sender)->chunked = chunked;
+	return AXIS2_SUCCESS;	
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_rest_sender_set_om_output(axis2_rest_sender_t *sender, 
+						axis2_env_t **env, axis2_om_output_t *om_output)
+{
+    AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_INTF_TO_IMPL(sender)->om_output = om_output;
+	return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t AXIS2_CALL 
+axis2_rest_sender_get_header_info(axis2_rest_sender_t *sender, 
+						axis2_env_t **env, axis2_msg_ctx_t *msg_ctx, 
+						axis2_http_simple_response_t *response)
+{
+	axis2_array_list_t *headers = NULL;
+	axis2_char_t *charset = NULL;
+	axis2_rest_sender_impl_t *sender_impl = NULL;
+	int i = 0;
+	axis2_bool_t response_chunked = AXIS2_FALSE;
+	int *content_length = NULL;
+    axis2_property_t *property = NULL;
+	
+	AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, msg_ctx, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, response, AXIS2_FAILURE);
+	
+	sender_impl = AXIS2_INTF_TO_IMPL(sender);
+	
+	/*
+	 * TODO MTOM support (MIME header)
+	 */
+	headers = AXIS2_HTTP_SIMPLE_RESPONSE_GET_HEADERS(response, env);
+	if(headers == NULL)
+	{
+		return AXIS2_SUCCESS;
+	}
+	for(i = 0; i < AXIS2_ARRAY_LIST_SIZE(headers, env); i++)
+	{
+		axis2_http_header_t *header = AXIS2_ARRAY_LIST_GET(headers, env, i);
+		axis2_char_t *name = AXIS2_HTTP_HEADER_GET_NAME((axis2_http_header_t *)
+						header, env);
+		if(NULL != name)
+		{
+			if(0 == AXIS2_STRCMP(name, AXIS2_HTTP_HEADER_TRANSFER_ENCODING) && 
+						0 == AXIS2_STRCMP(AXIS2_HTTP_HEADER_GET_VALUE(header
+						, env), AXIS2_HTTP_HEADER_TRANSFER_ENCODING_CHUNKED))
+			{
+                axis2_char_t *transfer_encoding = NULL;
+
+                transfer_encoding = 
+                    AXIS2_STRDUP(AXIS2_HTTP_HEADER_TRANSFER_ENCODING_CHUNKED, 
+                    env);
+                property = axis2_property_create(env);
+                AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_REQUEST);
+                AXIS2_PROPERTY_SET_VALUE(property, env, transfer_encoding);
+				AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, 
+						AXIS2_HTTP_HEADER_TRANSFER_ENCODING, 
+						property,
+						AXIS2_FALSE);
+				response_chunked = AXIS2_TRUE;
+			}
+			if(0 != AXIS2_STRCMP(name, AXIS2_HTTP_HEADER_CONTENT_TYPE))
+			{
+				axis2_char_t *tmp_charset = NULL;
+				axis2_char_t *content_type = AXIS2_HTTP_HEADER_GET_VALUE(header, 
+						env);
+				tmp_charset = strstr(content_type, AXIS2_HTTP_CHAR_SET_ENCODING);
+				if(NULL != charset)
+				{
+					charset = AXIS2_STRDUP(tmp_charset, env);
+					break;
+				}
+			}
+		}
+	}
+	if(NULL != charset)
+	{
+		axis2_ctx_t *axis_ctx = AXIS2_OP_CTX_GET_BASE(AXIS2_MSG_CTX_GET_OP_CTX(
+						msg_ctx, env), env);
+		if(NULL != axis_ctx)
+		{
+            property = axis2_property_create(env);
+            AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_REQUEST);
+            AXIS2_PROPERTY_SET_VALUE(property, env, charset); 
+			AXIS2_CTX_SET_PROPERTY(axis_ctx, env, AXIS2_CHARACTER_SET_ENCODING, 
+						property, AXIS2_FALSE);
+		}
+	}
+	if(AXIS2_FALSE == response_chunked)
+	{
+		int tmp_len = 0;
+		content_length = AXIS2_MALLOC((*env)->allocator, sizeof(int));
+		if(NULL == content_length)
+		{
+			return AXIS2_FAILURE;
+		}
+		tmp_len = AXIS2_HTTP_SIMPLE_RESPONSE_GET_CONTENT_LENGTH(response, env);
+		memcpy(content_length, &tmp_len, sizeof(int));
+        property = axis2_property_create(env);
+        AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_REQUEST);
+        AXIS2_PROPERTY_SET_VALUE(property, env, content_length);
+		AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, 
+						AXIS2_HTTP_HEADER_CONTENT_LENGTH, property, 
+						AXIS2_FALSE);
+	}
+	return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_rest_sender_process_response(axis2_rest_sender_t *sender, 
+                                axis2_env_t **env, axis2_msg_ctx_t *msg_ctx, 
+								axis2_http_simple_response_t *response)
+{
+    axis2_stream_t *in_stream = NULL;
+    axis2_property_t *property = NULL;
+	
+	AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+    AXIS2_PARAM_CHECK((*env)->error, msg_ctx, AXIS2_FAILURE);
+	AXIS2_PARAM_CHECK((*env)->error, response, AXIS2_FAILURE);
+	
+	in_stream = AXIS2_HTTP_SIMPLE_RESPONSE_GET_BODY(response, env);
+	if(NULL == in_stream)
+	{
+		AXIS2_ERROR_SET((*env)->error, AXIS2_ERROR_NULL_STREAM_IN_RESPONSE_BODY, 
+								AXIS2_FAILURE);
+		return AXIS2_FAILURE;
+	}
+	
+	axis2_rest_sender_get_header_info(sender, env, msg_ctx, response);
+	/*axis_ctx = AXIS2_OP_CTX_GET_BASE(AXIS2_MSG_CTX_GET_OP_CTX(msg_ctx, env), 
+						env);*/
+    property = axis2_property_create(env);
+    AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_REQUEST);
+    AXIS2_PROPERTY_SET_FREE_FUNC(property, env, axis2_stream_free_void_arg);
+    AXIS2_PROPERTY_SET_VALUE(property, env, in_stream);
+	/*AXIS2_CTX_SET_PROPERTY(axis_ctx, env, AXIS2_TRANSPORT_IN, property, 
+						AXIS2_FALSE);*/
+	AXIS2_MSG_CTX_SET_PROPERTY(msg_ctx, env, AXIS2_TRANSPORT_IN, property, 
+						AXIS2_FALSE);
+	return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_rest_sender_get_timeout_values(axis2_rest_sender_t *sender, 
+                                axis2_env_t **env, axis2_msg_ctx_t *msg_ctx)
+{
+    axis2_char_t *so_str = NULL;
+	axis2_char_t *connection_str = NULL;
+    axis2_param_t *tmp_param = NULL;
+
+	AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+	
+	
+    tmp_param = AXIS2_MSG_CTX_GET_PARAMETER(msg_ctx, 
+						env, AXIS2_HTTP_SO_TIMEOUT);
+	
+    if(NULL != tmp_param)
+    {
+        so_str = (axis2_char_t*)AXIS2_PARAM_GET_VALUE(tmp_param, env);
+        if(NULL != so_str)
+        {
+            AXIS2_INTF_TO_IMPL(sender)->so_timeout = AXIS2_ATOI(so_str);
+        }
+    }
+    tmp_param = AXIS2_MSG_CTX_GET_PARAMETER(msg_ctx, env, 
+                        AXIS2_HTTP_CONNECTION_TIMEOUT);
+    if(NULL != tmp_param)
+    {
+        connection_str = (axis2_char_t*)AXIS2_PARAM_GET_VALUE(tmp_param, env);
+        if(NULL != connection_str)
+        {
+            AXIS2_INTF_TO_IMPL(sender)->connection_timeout = 
+                        AXIS2_ATOI(connection_str);
+        }
+    }
+	return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_rest_sender_set_http_version(axis2_rest_sender_t *sender, 
+									axis2_env_t **env, axis2_char_t *version)
+{
+	AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+	AXIS2_INTF_TO_IMPL(sender)->http_version =  AXIS2_STRDUP(version, env);
+	if(NULL == AXIS2_INTF_TO_IMPL(sender)->http_version)
+	{
+		return AXIS2_FAILURE;
+	}
+	return AXIS2_SUCCESS;
+}

Modified: webservices/axis2/trunk/c/modules/core/transport/http/server/apache2/mod_axis2.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/modules/core/transport/http/server/apache2/mod_axis2.c?rev=391562&r1=391561&r2=391562&view=diff
==============================================================================
--- webservices/axis2/trunk/c/modules/core/transport/http/server/apache2/mod_axis2.c (original)
+++ webservices/axis2/trunk/c/modules/core/transport/http/server/apache2/mod_axis2.c Wed Apr
 5 01:48:51 2006
@@ -194,7 +194,6 @@
                         "log init failed\n");
         status = AXIS2_FAILURE;
     }
-    axis2_logger->level = conf->log_level;
     thread_pool = axis2_thread_pool_init(allocator);
     if(NULL == thread_pool)
     {
@@ -210,8 +209,13 @@
                         "axis2_environment init failed\n");
         status = AXIS2_FAILURE;
     }
-    AXIS2_LOG_INFO(axis2_env->log, "Starting log with log level %d", 
+    if(NULL != axis2_logger)
+    {
+        
+        axis2_logger->level = conf->log_level;
+        AXIS2_LOG_INFO(axis2_env->log, "Starting log with log level %d", 
                         conf->log_level);
+    }
     axis2_worker = axis2_apache2_worker_create(&axis2_env, 
                         conf->axis2_repo_path);
     if(NULL == axis2_worker)



Mime
View raw message