You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by sa...@apache.org on 2007/04/15 13:42:09 UTC
svn commit: r528966 - in /webservices/axis2/trunk/c/src: mod_addr/ mod_log/
modules/mod_addr/ modules/mod_log/
Author: samisa
Date: Sun Apr 15 04:42:08 2007
New Revision: 528966
URL: http://svn.apache.org/viewvc?view=rev&rev=528966
Log:
Moving mod_addr and mod_log to modules
Added:
webservices/axis2/trunk/c/src/modules/mod_addr/
webservices/axis2/trunk/c/src/modules/mod_addr/Makefile.am
webservices/axis2/trunk/c/src/modules/mod_addr/addr_in_handler.c
webservices/axis2/trunk/c/src/modules/mod_addr/addr_out_handler.c
webservices/axis2/trunk/c/src/modules/mod_addr/mod_addr.c
webservices/axis2/trunk/c/src/modules/mod_addr/module.xml
webservices/axis2/trunk/c/src/modules/mod_log/
webservices/axis2/trunk/c/src/modules/mod_log/Makefile.am
webservices/axis2/trunk/c/src/modules/mod_log/log_in_handler.c
webservices/axis2/trunk/c/src/modules/mod_log/log_out_handler.c
webservices/axis2/trunk/c/src/modules/mod_log/mod_log.c
webservices/axis2/trunk/c/src/modules/mod_log/mod_log.h
webservices/axis2/trunk/c/src/modules/mod_log/module.xml
Removed:
webservices/axis2/trunk/c/src/mod_addr/
webservices/axis2/trunk/c/src/mod_log/
Added: webservices/axis2/trunk/c/src/modules/mod_addr/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/modules/mod_addr/Makefile.am?view=auto&rev=528966
==============================================================================
--- webservices/axis2/trunk/c/src/modules/mod_addr/Makefile.am (added)
+++ webservices/axis2/trunk/c/src/modules/mod_addr/Makefile.am Sun Apr 15 04:42:08 2007
@@ -0,0 +1,33 @@
+prglibdir=$(prefix)/modules/addressing
+prglib_LTLIBRARIES = libaxis2_mod_addr.la
+prglib_DATA= module.xml
+EXTRA_DIST = module.xml
+libaxis2_mod_addr_la_SOURCES = addr_in_handler.c \
+ addr_out_handler.c \
+ mod_addr.c
+
+libaxis2_mod_addr_la_LIBADD = $(top_builddir)/src/core/engine/libaxis2_engine.la \
+ $(top_builddir)/axiom/src/om/libaxis2_axiom.la \
+ $(top_builddir)/util/src/libaxutil.la
+
+lib_LTLIBRARIES = libaxis2.la
+libaxis2_la_SOURCES = addr_in_handler.c \
+ addr_out_handler.c \
+ mod_addr.c
+
+libaxis2_la_LIBADD = $(top_builddir)/src/core/engine/libaxis2_engine.la \
+ $(top_builddir)/axiom/src/om/libaxis2_axiom.la \
+ $(top_builddir)/src/core/transport/http/util/libaxis2_http_util.la \
+ $(top_builddir)/src/core/transport/http/common/libaxis2_http_common.la \
+ $(top_builddir)/axiom/src/parser/${WRAPPER_DIR}/libaxis2_parser.la
+
+
+
+INCLUDES = -I$(top_builddir)/include \
+ -I$(top_builddir)/src/core/description \
+ -I$(top_builddir)/src/core/context \
+ -I$(top_builddir)/src/core/phaseresolver \
+ -I$(top_builddir)/src/core/engine \
+ -I$(top_builddir)/src/core/deployment \
+ -I$(top_builddir)/util/include \
+ -I$(top_builddir)/axiom/include
Added: webservices/axis2/trunk/c/src/modules/mod_addr/addr_in_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/modules/mod_addr/addr_in_handler.c?view=auto&rev=528966
==============================================================================
--- webservices/axis2/trunk/c/src/modules/mod_addr/addr_in_handler.c (added)
+++ webservices/axis2/trunk/c/src/modules/mod_addr/addr_in_handler.c Sun Apr 15 04:42:08 2007
@@ -0,0 +1,742 @@
+/*
+ * Licensed 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.
+ */
+
+#include <axis2_addr_mod.h>
+#include <axis2_addr.h>
+#include <axis2_handler_desc.h>
+#include <axutil_array_list.h>
+#include <axiom_soap_const.h>
+#include <axiom_soap_envelope.h>
+#include <axiom_soap_header.h>
+#include <axiom_soap_header_block.h>
+#include <axis2_op.h>
+#include <axis2_msg_ctx.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_msg_info_headers.h>
+#include <axutil_property.h>
+
+axis2_status_t AXIS2_CALL
+axis2_addr_in_handler_invoke(struct axis2_handler *handler,
+ const axutil_env_t *env,
+ struct axis2_msg_ctx *msg_ctx);
+
+axis2_bool_t
+axis2_addr_in_check_element(const axutil_env_t *env, axutil_qname_t *expected_qname,
+ axutil_qname_t *actual_qname);
+
+axis2_status_t
+axis2_addr_in_extract_svc_grp_ctx_id(const axutil_env_t *env,
+ axiom_soap_header_t *soap_header,
+ axis2_msg_ctx_t *msg_ctx);
+
+axis2_status_t
+axis2_addr_in_extract_ref_params(const axutil_env_t *env,
+ axiom_soap_header_t *soap_header,
+ axis2_msg_info_headers_t *msg_info_headers);
+
+axis2_status_t
+axis2_addr_in_extract_addr_final_info(const axutil_env_t *env,
+ axiom_soap_header_t *soap_header,
+ axis2_msg_info_headers_t **msg_info_headers,
+ axutil_array_list_t *addr_headers,
+ axis2_msg_ctx_t *msg_ctx);
+
+
+axis2_status_t
+axis2_addr_in_extract_to_epr_ref_params(const axutil_env_t *env,
+ axis2_endpoint_ref_t * to_epr,
+ axiom_soap_header_t *soap_header,
+ const axis2_char_t *addr_ns);
+
+axis2_status_t
+axis2_addr_in_extract_epr_information(const axutil_env_t *env,
+ axiom_soap_header_block_t *soap_header_block,
+ axis2_endpoint_ref_t *endpoint_ref,
+ const axis2_char_t *addr_ns);
+
+axis2_status_t
+axis2_addr_in_extract_addr_params(const axutil_env_t *env,
+ axiom_soap_header_t *soap_header,
+ axis2_msg_info_headers_t **msg_info_headers,
+ axutil_array_list_t *addr_headers,
+ const axis2_char_t *addr_ns,
+ axis2_msg_ctx_t *msg_ctx);
+
+axis2_status_t axis2_addr_in_extract_addr_submission_info(const axutil_env_t *env,
+ axiom_soap_header_t *soap_header,
+ axis2_msg_info_headers_t **msg_info_headers,
+ axutil_array_list_t *addr_headers,
+ axis2_msg_ctx_t *msg_ctx);
+
+void
+axis2_addr_in_create_fault_envelope(const axutil_env_t *env,
+ const axis2_char_t *header_name,
+ const axis2_char_t *addr_ns_str,
+ axis2_msg_ctx_t *msg_ctx);
+
+/******************************************************************************/
+
+AXIS2_EXTERN axis2_handler_t* AXIS2_CALL
+axis2_addr_in_handler_create(const axutil_env_t *env,
+ axutil_string_t *name)
+{
+ axis2_handler_t *handler = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ handler = axis2_handler_create(env);
+ if (!handler)
+ {
+ return NULL;
+ }
+
+ /* handler init is handled by conf loading, so no need to do it here */
+
+ axis2_handler_set_invoke(handler, env, axis2_addr_in_handler_invoke);
+
+ return handler;
+}
+
+
+axis2_status_t AXIS2_CALL
+axis2_addr_in_handler_invoke(struct axis2_handler *handler,
+ const axutil_env_t *env,
+ struct axis2_msg_ctx *msg_ctx)
+{
+ axiom_soap_envelope_t *soap_envelope = NULL;
+ axiom_soap_header_t *soap_header = NULL;
+ axutil_property_t *property = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ AXIS2_LOG_INFO(env->log, "Starting addressing in handler .........");
+
+ soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
+
+ if (soap_envelope)
+ {
+ soap_header = axiom_soap_envelope_get_header(soap_envelope, env);
+ if (soap_header)
+ {
+ axutil_array_list_t *addr_headers = NULL;
+ axis2_ctx_t *ctx = NULL;
+ axis2_char_t *addr_ns_str = NULL;
+ axis2_msg_info_headers_t *msg_info_headers = axis2_msg_ctx_get_msg_info_headers(msg_ctx, env);
+
+ addr_headers = axiom_soap_header_get_header_blocks_with_namespace_uri(soap_header, env, AXIS2_WSA_NAMESPACE_SUBMISSION);
+ if (addr_headers)
+ {
+ addr_ns_str = axutil_strdup(env, AXIS2_WSA_NAMESPACE_SUBMISSION);
+ status = axis2_addr_in_extract_addr_submission_info(env,
+ soap_header,
+ &msg_info_headers,
+ addr_headers,
+ msg_ctx);
+ }
+ else
+ {
+ addr_headers = axiom_soap_header_get_header_blocks_with_namespace_uri(soap_header, env, AXIS2_WSA_NAMESPACE);
+ if (addr_headers)
+ {
+ addr_ns_str = axutil_strdup(env, AXIS2_WSA_NAMESPACE);
+ status = axis2_addr_in_extract_addr_final_info(env,
+ soap_header,
+ &msg_info_headers,
+ addr_headers,
+ msg_ctx);
+ axis2_addr_in_extract_ref_params(env, soap_header, axis2_msg_ctx_get_msg_info_headers(msg_ctx, env));
+
+ }
+ else
+ {
+ /* addressing headers are not present in the SOAP message*/
+ AXIS2_LOG_INFO(env->log, AXIS2_LOG_SI, "No Addressing Headers present in the IN message. Addressing In Handler cannot do anything.");
+ return AXIS2_SUCCESS; /* no addressing heades means addressing not in use */
+ }
+ }
+
+ ctx = axis2_msg_ctx_get_base(msg_ctx, env);
+ if (ctx)
+ {
+ property = axutil_property_create(env);
+ axutil_property_set_scope(property, env, AXIS2_SCOPE_REQUEST);
+ axutil_property_set_value(property, env, addr_ns_str);
+ axis2_ctx_set_property(ctx, env, AXIS2_WSA_VERSION, property);
+ }
+
+ /* extract service group context, if available */
+ axis2_addr_in_extract_svc_grp_ctx_id(env, soap_header, msg_ctx);
+
+ axutil_array_list_free(addr_headers, env);
+ return status;
+ }
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t
+axis2_addr_in_extract_svc_grp_ctx_id(const axutil_env_t *env,
+ axiom_soap_header_t *soap_header,
+ axis2_msg_ctx_t *msg_ctx)
+{
+ axiom_node_t *node = NULL;
+ axiom_element_t *element = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ node = axiom_soap_header_get_base_node(soap_header, env);
+ if (node && axiom_node_get_node_type(node, env) == AXIOM_ELEMENT)
+ {
+ axutil_qname_t *qname = NULL;
+ element = (axiom_element_t *)axiom_node_get_data_element(node, env);
+ qname = axutil_qname_create(env, AXIS2_SVC_GRP_ID, AXIS2_NAMESPACE_URI,
+ AXIS2_NAMESPACE_PREFIX);
+ if (qname)
+ {
+ axiom_node_t *child_node = NULL;
+ axiom_element_t *child_element = NULL;
+ child_element = axiom_element_get_first_child_with_qname(element, env, qname, node, &child_node);
+ if (child_element)
+ {
+ axis2_conf_ctx_t * conf_ctx = NULL;
+ axis2_char_t *grp_id = axiom_element_get_text(child_element, env,
+ child_node);
+ conf_ctx = axis2_msg_ctx_get_conf_ctx(msg_ctx, env);
+ if (conf_ctx && grp_id)
+ {
+ axutil_string_t *svc_grp_ctx_id_str = axutil_string_create(env, grp_id);
+ axis2_svc_grp_ctx_t *svc_ctx_grp_ctx = axis2_conf_ctx_get_svc_grp_ctx(conf_ctx, env, grp_id);
+ if (!svc_ctx_grp_ctx)
+ {
+ /** TODO, set error */
+ return AXIS2_FAILURE;
+ }
+ axis2_msg_ctx_set_svc_grp_ctx_id(msg_ctx, env, svc_grp_ctx_id_str);
+ axutil_string_free(svc_grp_ctx_id_str, env);
+ return AXIS2_SUCCESS;
+ }
+ }
+ }
+ axutil_qname_free(qname, env);
+ }
+ /** TODO, set error */
+ return AXIS2_FAILURE;
+}
+
+
+
+axis2_status_t
+axis2_addr_in_extract_addr_final_info(const axutil_env_t *env,
+ axiom_soap_header_t *soap_header,
+ axis2_msg_info_headers_t **msg_info_headers,
+ axutil_array_list_t *addr_headers,
+ axis2_msg_ctx_t *msg_ctx)
+{
+ return axis2_addr_in_extract_addr_params(env,
+ soap_header,
+ msg_info_headers,
+ addr_headers,
+ AXIS2_WSA_NAMESPACE,
+ msg_ctx);
+}
+
+axis2_status_t axis2_addr_in_extract_addr_submission_info(const axutil_env_t *env,
+ axiom_soap_header_t *soap_header,
+ axis2_msg_info_headers_t **msg_info_headers,
+ axutil_array_list_t *addr_headers,
+ axis2_msg_ctx_t *msg_ctx)
+{
+ return axis2_addr_in_extract_addr_params(env,
+ soap_header,
+ msg_info_headers,
+ addr_headers,
+ AXIS2_WSA_NAMESPACE_SUBMISSION,
+ msg_ctx);
+}
+
+axis2_status_t
+axis2_addr_in_extract_addr_params(const axutil_env_t *env,
+ axiom_soap_header_t *soap_header,
+ axis2_msg_info_headers_t **msg_info_headers_p,
+ axutil_array_list_t *addr_headers,
+ const axis2_char_t *addr_ns_str,
+ axis2_msg_ctx_t *msg_ctx)
+{
+ axutil_hash_t *header_block_ht = NULL;
+ axutil_hash_index_t *hash_index = NULL;
+ axis2_msg_info_headers_t *msg_info_headers = *(msg_info_headers_p);
+ axis2_status_t status = AXIS2_SUCCESS;
+ axis2_bool_t to_found = AXIS2_FALSE;
+ axis2_bool_t reply_to_found = AXIS2_FALSE;
+ axis2_bool_t fault_to_found = AXIS2_FALSE;
+ axis2_bool_t action_found = AXIS2_FALSE;
+ axis2_bool_t msg_id_found = AXIS2_FALSE;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, soap_header, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_info_headers_p, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, addr_headers, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, addr_ns_str, AXIS2_FAILURE);
+
+
+
+ if (!msg_info_headers)
+ msg_info_headers = axis2_msg_info_headers_create(env, NULL, NULL);
+ if (!msg_info_headers)
+ return AXIS2_FAILURE;
+
+ header_block_ht = axiom_soap_header_get_all_header_blocks(soap_header, env);
+ if (!header_block_ht)
+ return AXIS2_FAILURE;
+
+ for (hash_index = axutil_hash_first(header_block_ht, env); hash_index;
+ hash_index = axutil_hash_next(env, hash_index))
+ {
+ void *hb = NULL;
+ axiom_soap_header_block_t *header_block = NULL;
+ axiom_node_t *header_block_node = NULL;
+ axiom_element_t *header_block_ele = NULL;
+ axis2_char_t *ele_localname = NULL;
+ axis2_endpoint_ref_t *epr = NULL;
+ axis2_char_t *role = NULL;
+
+ axutil_hash_this(hash_index, NULL, NULL, &hb);
+
+ header_block = (axiom_soap_header_block_t *)hb;
+ header_block_node = axiom_soap_header_block_get_base_node(header_block, env);
+ header_block_ele = (axiom_element_t*)axiom_node_get_data_element(header_block_node, env);
+ ele_localname = axiom_element_get_localname(header_block_ele, env);
+
+ role = axiom_soap_header_block_get_role(header_block, env);
+ if (role && axutil_strcmp(role, AXIOM_SOAP12_SOAP_ROLE_NONE) == 0)
+ {
+ /* Role is none, no need of processing */
+ continue;
+ }
+
+ if (axutil_strcmp(ele_localname, AXIS2_WSA_TO) == 0)
+ {
+ /* here the addressing epr overidde what ever already there in the message context */
+
+ epr = axis2_endpoint_ref_create(env, axiom_element_get_text(header_block_ele, env, header_block_node));
+ if (to_found == AXIS2_TRUE)
+ {
+ /* Duplicate To */
+ axis2_addr_in_create_fault_envelope(env,
+ "wsa:To", addr_ns_str, msg_ctx);
+ status = AXIS2_FAILURE;
+ continue;
+ }
+ axis2_msg_info_headers_set_to(msg_info_headers, env, epr);
+
+ axis2_addr_in_extract_to_epr_ref_params(env, epr, soap_header, addr_ns_str);
+ axiom_soap_header_block_set_processed(header_block, env);
+ to_found = AXIS2_TRUE;
+ }
+ else if (axutil_strcmp(ele_localname, AXIS2_WSA_FROM) == 0)
+ {
+ epr = axis2_msg_info_headers_get_from(msg_info_headers, env);
+ if (!epr)
+ {
+ /* The address is not know now. Pass the empty
+ string now and fill this once the element
+ under this is processed. */
+
+ epr = axis2_endpoint_ref_create(env, "");
+ axis2_msg_info_headers_set_from(msg_info_headers, env, epr);
+ }
+ axis2_addr_in_extract_epr_information(env, header_block, epr, addr_ns_str);
+ axiom_soap_header_block_set_processed(header_block, env);
+ }
+ else if (axutil_strcmp(ele_localname, AXIS2_WSA_REPLY_TO) == 0)
+ {
+ epr = axis2_msg_info_headers_get_reply_to(msg_info_headers, env);
+
+ if (reply_to_found == AXIS2_TRUE)
+ {
+ /* Duplicate Reply To */
+ axis2_addr_in_create_fault_envelope(env,
+ "wsa:ReplyTo", addr_ns_str, msg_ctx);
+ status = AXIS2_FAILURE;
+ continue;
+ }
+
+ if (!epr)
+ {
+ epr = axis2_endpoint_ref_create(env, "");
+ axis2_msg_info_headers_set_reply_to(msg_info_headers, env, epr);
+ }
+ axis2_addr_in_extract_epr_information(env, header_block, epr, addr_ns_str);
+ axiom_soap_header_block_set_processed(header_block, env);
+ reply_to_found = AXIS2_TRUE;
+ }
+ else if (axutil_strcmp(ele_localname, AXIS2_WSA_FAULT_TO) == 0)
+ {
+ epr = axis2_msg_info_headers_get_fault_to(msg_info_headers , env);
+
+ if (fault_to_found == AXIS2_TRUE)
+ {
+ /* Duplicate Fault To */
+ axis2_addr_in_create_fault_envelope(env,
+ "wsa:FaultTo", addr_ns_str, msg_ctx);
+ status = AXIS2_FAILURE;
+ axis2_msg_info_headers_set_fault_to(msg_info_headers, env, NULL);
+ continue;
+ }
+
+ if (!epr)
+ {
+ epr = axis2_endpoint_ref_create(env, "");
+ axis2_msg_info_headers_set_fault_to(msg_info_headers, env, epr);
+ }
+ axis2_addr_in_extract_epr_information(env, header_block, epr, addr_ns_str);
+ axiom_soap_header_block_set_processed(header_block, env);
+ fault_to_found = AXIS2_TRUE;
+ }
+ else if (axutil_strcmp(ele_localname, AXIS2_WSA_MESSAGE_ID) == 0)
+ {
+ axis2_char_t *text = NULL;
+
+ if (msg_id_found == AXIS2_TRUE)
+ {
+ /* Duplicate Message ID */
+ axis2_addr_in_create_fault_envelope(env,
+ "wsa:MessageID", addr_ns_str, msg_ctx);
+ status = AXIS2_FAILURE;
+ continue;
+ }
+
+ text = axiom_element_get_text(header_block_ele, env, header_block_node);
+ axis2_msg_info_headers_set_message_id(msg_info_headers, env, text);
+ axiom_soap_header_block_set_processed(header_block, env);
+ msg_id_found = AXIS2_TRUE;
+ }
+ else if (axutil_strcmp(ele_localname, AXIS2_WSA_ACTION) == 0)
+ {
+ axis2_char_t *text = NULL;
+
+ if (action_found == AXIS2_TRUE)
+ {
+ /* Duplicate Action */
+ axis2_addr_in_create_fault_envelope(env,
+ "wsa:Action", addr_ns_str, msg_ctx);
+ status = AXIS2_FAILURE;
+ continue;
+ }
+
+ text = axiom_element_get_text(header_block_ele, env, header_block_node);
+ axis2_msg_info_headers_set_action(msg_info_headers, env, text);
+ axiom_soap_header_block_set_processed(header_block, env);
+ action_found = AXIS2_TRUE;
+ }
+ else if (axutil_strcmp(ele_localname, AXIS2_WSA_RELATES_TO) == 0)
+ {
+ axis2_char_t *address = NULL;
+ axutil_qname_t *rqn = NULL;
+ axiom_attribute_t *relationship_type = NULL;
+ const axis2_char_t *relationship_type_default_value = NULL;
+ const axis2_char_t *relationship_type_value = NULL;
+ axis2_relates_to_t *relates_to = NULL;
+ if (axutil_strcmp(AXIS2_WSA_NAMESPACE_SUBMISSION , addr_ns_str) == 0)
+ {
+ relationship_type_default_value =
+ AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE_SUBMISSION;
+ }
+ else
+ {
+ relationship_type_default_value = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION;
+ }
+ rqn = axutil_qname_create(env, AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE, NULL, NULL);
+
+ relationship_type = axiom_element_get_attribute(header_block_ele, env, rqn);
+
+ if (!relationship_type)
+ {
+ relationship_type_value =
+ AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE_SUBMISSION;
+ }
+ else
+ {
+ relationship_type_value = axiom_attribute_get_value(relationship_type, env);
+ }
+
+ address = axiom_element_get_text(header_block_ele, env, header_block_node);
+ relates_to = axis2_relates_to_create(env, address, relationship_type_value);
+ axis2_msg_info_headers_set_relates_to(msg_info_headers, env, relates_to);
+ axiom_soap_header_block_set_processed(header_block, env);
+
+ axutil_qname_free(rqn, env);
+ }
+ }
+
+ if (action_found == AXIS2_FALSE) /* Check is an action was found */
+ {
+ axis2_addr_in_create_fault_envelope(env,
+ "wsa:Action", addr_ns_str, msg_ctx);
+ status = AXIS2_FAILURE;
+ }
+
+ return status;
+}
+
+axis2_status_t
+axis2_addr_in_extract_epr_information(const axutil_env_t *env,
+ axiom_soap_header_block_t *soap_header_block,
+ axis2_endpoint_ref_t *endpoint_ref,
+ const axis2_char_t *addr_ns_str)
+{
+ axutil_qname_t *epr_addr_qn = NULL;
+ axutil_qname_t *epr_ref_qn = NULL;
+ axutil_qname_t *wsa_meta_qn = NULL;
+ axiom_node_t *header_block_node = NULL;
+ axiom_element_t *header_block_ele = NULL;
+ axiom_child_element_iterator_t *child_ele_iter = NULL;
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, soap_header_block, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, endpoint_ref, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, addr_ns_str, AXIS2_FAILURE);
+
+ header_block_node = axiom_soap_header_block_get_base_node(soap_header_block, env);
+ header_block_ele = (axiom_element_t *)axiom_node_get_data_element(header_block_node, env);
+
+
+ child_ele_iter = axiom_element_get_child_elements(header_block_ele, env, header_block_node);
+ if (!child_ele_iter)
+ return AXIS2_FAILURE;
+ epr_addr_qn = axutil_qname_create(env, EPR_ADDRESS, addr_ns_str, NULL);
+ epr_ref_qn = axutil_qname_create(env, EPR_REFERENCE_PARAMETERS, addr_ns_str, NULL);
+ wsa_meta_qn = axutil_qname_create(env, AXIS2_WSA_METADATA, addr_ns_str, NULL);
+ while (AXIOM_CHILD_ELEMENT_ITERATOR_HAS_NEXT(child_ele_iter, env))
+ {
+ axiom_node_t *child_node = NULL;
+ axiom_element_t *child_ele = NULL;
+ axutil_qname_t *child_qn = NULL;
+ child_node = AXIOM_CHILD_ELEMENT_ITERATOR_NEXT(child_ele_iter, env);
+ child_ele = (axiom_element_t*)axiom_node_get_data_element(child_node, env);
+
+
+ child_qn = axiom_element_get_qname(child_ele, env, child_node);
+ if (axis2_addr_in_check_element(env, epr_addr_qn, child_qn))
+ {
+ axis2_endpoint_ref_set_address(endpoint_ref, env,
+ axiom_element_get_text(child_ele, env, child_node));
+ }
+ else if (axis2_addr_in_check_element(env, epr_ref_qn , child_qn))
+ {
+ axiom_child_element_iterator_t *ref_param_iter = NULL;
+
+ ref_param_iter = axiom_element_get_child_elements(child_ele, env, child_node);
+ if (ref_param_iter)
+ {
+ while (AXIOM_CHILD_ELEMENT_ITERATOR_HAS_NEXT(ref_param_iter, env))
+ {
+ axiom_node_t *om_node = NULL;
+ axiom_element_t *om_ele = NULL;
+ om_node = AXIOM_CHILD_ELEMENT_ITERATOR_NEXT(ref_param_iter, env);
+ om_ele = (axiom_element_t*)axiom_node_get_data_element(om_node, env);
+ }
+ }
+
+ }
+ else if (axis2_addr_in_check_element(env, wsa_meta_qn, child_qn))
+ {}
+ }
+ axutil_qname_free(epr_addr_qn, env);
+ axutil_qname_free(epr_ref_qn, env);
+ axutil_qname_free(wsa_meta_qn, env);
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t
+axis2_addr_in_extract_ref_params(const axutil_env_t *env,
+ axiom_soap_header_t *soap_header,
+ axis2_msg_info_headers_t* msg_info_headers)
+{
+ axutil_hash_t *header_block_ht = NULL;
+ axutil_hash_index_t *hash_index = NULL;
+ axutil_qname_t *wsa_qname = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, soap_header, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_info_headers, AXIS2_FAILURE);
+
+ header_block_ht = axiom_soap_header_get_all_header_blocks(soap_header, env);
+ if (!header_block_ht)
+ return AXIS2_FAILURE;
+ wsa_qname = axutil_qname_create(env, AXIS2_WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE,
+ AXIS2_WSA_NAMESPACE, NULL);
+
+ for (hash_index = axutil_hash_first(header_block_ht, env); hash_index;
+ hash_index = axutil_hash_next(env, hash_index))
+ {
+ void *hb = NULL;
+ axiom_soap_header_block_t *header_block = NULL;
+ axiom_node_t *header_block_node = NULL;
+ axiom_element_t *header_block_ele = NULL;
+
+ axutil_hash_this(hash_index, NULL, NULL, &hb);
+
+ header_block = (axiom_soap_header_block_t *)hb;
+ header_block_node = axiom_soap_header_block_get_base_node(header_block, env);
+
+ if (header_block_node &&
+ (axiom_node_get_node_type(header_block_node, env) == AXIOM_ELEMENT))
+ {
+ axiom_attribute_t *om_attr = NULL;
+ axis2_char_t *attr_value = NULL;
+ header_block_ele = (axiom_element_t*)axiom_node_get_data_element(header_block_node, env);
+ om_attr = axiom_element_get_attribute(header_block_ele, env, wsa_qname);
+ if (om_attr)
+ {
+ attr_value = axiom_attribute_get_localname(om_attr, env);
+ if (axutil_strcmp(attr_value, AXIS2_WSA_TYPE_ATTRIBUTE_VALUE) == 0)
+ {
+ axis2_msg_info_headers_add_ref_param(msg_info_headers, env, header_block_node);
+ }
+ }
+ }
+ }
+
+ axutil_qname_free(wsa_qname, env);
+
+ return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t
+axis2_addr_in_extract_to_epr_ref_params(const axutil_env_t *env,
+ axis2_endpoint_ref_t * to_epr,
+ axiom_soap_header_t *soap_header,
+ const axis2_char_t *addr_ns_str)
+{
+ axutil_hash_t *header_blocks_ht = NULL;
+ axutil_hash_index_t *hash_index = NULL;
+ axutil_qname_t *is_ref_qn = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, to_epr, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, soap_header, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, addr_ns_str, AXIS2_FAILURE);
+
+ header_blocks_ht = axiom_soap_header_get_all_header_blocks(soap_header, env);
+ if (!header_blocks_ht)
+ return AXIS2_FAILURE;
+
+ is_ref_qn = axutil_qname_create(env, "IsReferenceParameter", addr_ns_str, NULL);
+ if (!is_ref_qn)
+ return AXIS2_FAILURE;
+
+ for (hash_index = axutil_hash_first(header_blocks_ht, env); hash_index;
+ hash_index = axutil_hash_next(env, hash_index))
+ {
+ axiom_element_t *header_block_ele = NULL;
+ axiom_node_t *header_block_node = NULL;
+ axiom_soap_header_block_t *header_block = NULL;
+ void *hb = NULL;
+ axiom_attribute_t *is_ref_param_attr = NULL;
+ axis2_char_t *attr_value = NULL;
+
+ axutil_hash_this(hash_index, NULL, NULL, &hb);
+ if (hb)
+ {
+ header_block = (axiom_soap_header_block_t*)hb;
+ header_block_node = axiom_soap_header_block_get_base_node(header_block, env);
+ header_block_ele = (axiom_element_t*)
+ axiom_node_get_data_element(header_block_node, env);
+ is_ref_param_attr = axiom_element_get_attribute(header_block_ele, env, is_ref_qn);
+ if (is_ref_param_attr)
+ {
+ attr_value = axiom_attribute_get_localname(is_ref_param_attr, env);
+ if (axutil_strcmp("true", attr_value) == 0)
+ {
+ axis2_endpoint_ref_add_ref_param(to_epr, env, header_block_node);
+ }
+ }
+ }
+ }
+
+ axutil_qname_free(is_ref_qn, env);
+ return AXIS2_SUCCESS;
+}
+
+
+axis2_bool_t
+axis2_addr_in_check_element(const axutil_env_t *env,
+ axutil_qname_t *expected_qname,
+ axutil_qname_t *actual_qname)
+{
+ axis2_char_t *exp_qn_lpart = NULL;
+ axis2_char_t *act_qn_lpart = NULL;
+ axis2_char_t *exp_qn_nsuri = NULL;
+ axis2_char_t *act_qn_nsuri = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, expected_qname, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, actual_qname, AXIS2_FAILURE);
+
+ exp_qn_lpart = axutil_qname_get_localpart(expected_qname, env);
+ act_qn_lpart = axutil_qname_get_localpart(actual_qname, env);
+
+ exp_qn_nsuri = axutil_qname_get_localpart(expected_qname, env);
+ act_qn_nsuri = axutil_qname_get_localpart(actual_qname, env);
+
+ return ((axutil_strcmp(exp_qn_lpart, act_qn_lpart) == 0) &&
+ (axutil_strcmp(exp_qn_nsuri, act_qn_nsuri) == 0));
+}
+
+void
+axis2_addr_in_create_fault_envelope(const axutil_env_t *env,
+ const axis2_char_t *header_name,
+ const axis2_char_t *addr_ns_str,
+ axis2_msg_ctx_t *msg_ctx)
+{
+ axiom_soap_envelope_t *envelope = NULL;
+ axutil_array_list_t *sub_codes = NULL;
+ int soap_version = AXIOM_SOAP12;
+ axiom_node_t* text_om_node = NULL;
+ axiom_element_t * text_om_ele = NULL;
+ axiom_namespace_t *ns1 = NULL;
+
+ if ( axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
+ {
+ soap_version = AXIOM_SOAP11;
+ }
+
+
+ ns1 = axiom_namespace_create(env, addr_ns_str, "wsa");
+ text_om_ele = axiom_element_create(env, NULL, "ProblemHeaderQName", ns1, &text_om_node);
+ axiom_element_set_text(text_om_ele, env, header_name, text_om_node);
+
+ sub_codes = axutil_array_list_create(env, 2);
+ if (sub_codes)
+ {
+ axutil_array_list_add(sub_codes, env, "wsa:InvalidAddressingHeader");
+ axutil_array_list_add(sub_codes, env, "wsa:InvalidCardinality");
+ }
+
+ envelope = axiom_soap_envelope_create_default_soap_fault_envelope(env,
+ "soapenv:Sender",
+ "A header representing a Message Addressing Property is not valid and the message cannot be processed",
+ soap_version, sub_codes, text_om_node);
+ axis2_msg_ctx_set_fault_soap_envelope(msg_ctx, env, envelope);
+ axis2_msg_ctx_set_wsa_action(msg_ctx, env,
+ "http://www.w3.org/2005/08/addressing/fault");
+ return;
+}
Added: webservices/axis2/trunk/c/src/modules/mod_addr/addr_out_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/modules/mod_addr/addr_out_handler.c?view=auto&rev=528966
==============================================================================
--- webservices/axis2/trunk/c/src/modules/mod_addr/addr_out_handler.c (added)
+++ webservices/axis2/trunk/c/src/modules/mod_addr/addr_out_handler.c Sun Apr 15 04:42:08 2007
@@ -0,0 +1,818 @@
+/*
+ * Licensed 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.
+ */
+
+#include <axis2_handler_desc.h>
+#include <axutil_qname.h>
+#include <axis2_svc.h>
+#include <axiom_soap_header.h>
+#include <axiom_soap_body.h>
+#include <axis2_addr.h>
+#include <axiom_soap_header_block.h>
+#include <axis2_endpoint_ref.h>
+#include <axutil_property.h>
+#include <stdio.h>
+
+axis2_status_t AXIS2_CALL
+axis2_addr_out_handler_invoke(struct axis2_handler *handler,
+ const axutil_env_t *env,
+ struct axis2_msg_ctx *msg_ctx);
+
+
+axis2_status_t
+axis2_addr_out_handler_add_to_soap_header(const axutil_env_t *env,
+ axis2_endpoint_ref_t *
+ endpoint_ref,
+ const axis2_char_t * type,
+ axiom_soap_header_t * soap_header,
+ const axis2_char_t * addr_ns);
+
+
+axis2_status_t
+axis2_addr_out_handler_add_to_header(const axutil_env_t *env,
+ axis2_endpoint_ref_t * epr,
+ axiom_node_t ** parent_node,
+ const axis2_char_t * addr_ns);
+
+axis2_status_t
+axis2_addr_out_handler_process_any_content_type(const axutil_env_t *env,
+ axis2_any_content_type_t *
+ reference_values,
+ axiom_node_t *
+ parent_ele_node,
+ const axis2_char_t * addr_ns);
+
+axiom_node_t *axis2_addr_out_handler_process_string_info(const axutil_env_t *env,
+ const axis2_char_t *value,
+ const axis2_char_t *type,
+ axiom_soap_header_t **soap_header,
+ const axis2_char_t *addr_ns);
+
+
+AXIS2_EXTERN axis2_handler_t *AXIS2_CALL
+axis2_addr_out_handler_create(const axutil_env_t *env, axutil_string_t * name)
+{
+ axis2_handler_t *handler = NULL;
+ /*axutil_qname_t *handler_qname = NULL;*/
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ /*if (qname)
+ {
+ handler_qname = axutil_qname_clone(qname, env);
+ if (!(handler_qname))
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY,
+ AXIS2_FAILURE);
+ return NULL;
+ }
+ }
+ else
+ {
+ create default qname
+ handler_qname = axutil_qname_create(env, "addr_out_handler",
+ "http://axis.ws.apache.org",
+ NULL);
+ if (!handler_qname)
+ {
+ return NULL;
+ }
+ }*/
+
+ handler = axis2_handler_create(env);
+ if (!handler)
+ {
+ return NULL;
+ }
+
+ axis2_handler_set_invoke(handler, env, axis2_addr_out_handler_invoke);
+
+ return handler;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_addr_out_handler_invoke(struct axis2_handler * handler,
+ const axutil_env_t *env, axis2_msg_ctx_t * msg_ctx)
+{
+ axis2_char_t *addressing_version_from_msg_ctx = NULL;
+ const axis2_char_t *addr_ns = NULL;
+ axis2_msg_info_headers_t *msg_info_headers = NULL;
+ axis2_ctx_t *ctx = NULL;
+ axiom_namespace_t *addressing_namespace = NULL;
+ axiom_soap_envelope_t *soap_envelope = NULL;
+ axiom_soap_header_t *soap_header = NULL;
+ axiom_node_t *soap_header_node = NULL;
+ axiom_element_t *soap_header_ele = NULL;
+ axis2_endpoint_ref_t *epr = NULL;
+ axutil_property_t *property = NULL;
+ const axis2_char_t *wsa_action = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ msg_info_headers = axis2_msg_ctx_get_msg_info_headers(msg_ctx, env);
+ if (!msg_info_headers)
+ return AXIS2_SUCCESS; /* no addressing in use */
+ wsa_action = axis2_msg_info_headers_get_action (msg_info_headers, env);
+ if (!wsa_action || !axutil_strcmp (wsa_action, ""))
+ return AXIS2_SUCCESS; /* If no action present, assume no addressing in use */
+
+
+ ctx = axis2_msg_ctx_get_base(msg_ctx, env);
+ property =
+ axis2_ctx_get_property(ctx, env, AXIS2_WSA_VERSION);
+ if (property)
+ {
+ addressing_version_from_msg_ctx = axutil_property_get_value(property,
+ env);
+ property = NULL;
+ }
+
+ if (addressing_version_from_msg_ctx)
+ {
+ if (axutil_strcmp
+ (AXIS2_WSA_NAMESPACE, addressing_version_from_msg_ctx) == 0)
+ {
+ addr_ns = AXIS2_WSA_NAMESPACE;
+ }
+ else
+ {
+ addr_ns = AXIS2_WSA_NAMESPACE_SUBMISSION;
+ }
+ }
+ else if ( axis2_msg_ctx_get_op_ctx(msg_ctx, env))
+ {
+ axis2_op_ctx_t *op_ctx = NULL;
+ axis2_msg_ctx_t *in_msg_ctx = NULL;
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ if (op_ctx)
+ {
+ in_msg_ctx =
+ axis2_op_ctx_get_msg_ctx(op_ctx, env,
+ AXIS2_WSDL_MESSAGE_LABEL_IN);
+ }
+
+ if (!in_msg_ctx)
+ {
+ addr_ns = AXIS2_WSA_NAMESPACE; /* setting Submission version as the default addressing namespace */
+ }
+ else
+ {
+ axis2_ctx_t *in_ctx = NULL;
+ in_ctx = axis2_msg_ctx_get_base(in_msg_ctx, env);
+
+ property =
+ axis2_ctx_get_property(in_ctx, env, AXIS2_WSA_VERSION);
+ if (property)
+ {
+ addr_ns = axutil_property_get_value(property, env);
+ property = NULL;
+ }
+
+ if (!addr_ns)
+ {
+ addr_ns = AXIS2_WSA_NAMESPACE; /* Addressing version has not been set in the IN path */
+ }
+ }
+ }
+
+ if (!addr_ns || axutil_strcmp("", addr_ns) == 0)
+ {
+ addr_ns = AXIS2_WSA_NAMESPACE;
+ }
+
+ addressing_namespace = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ msg_info_headers = axis2_msg_ctx_get_msg_info_headers(msg_ctx, env);
+ soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
+ if (!soap_envelope)
+ {
+ axiom_namespace_free(addressing_namespace, env);
+ return AXIS2_SUCCESS; /* can happen in case of one way services/clients */
+ }
+ soap_header = axiom_soap_envelope_get_header(soap_envelope, env);
+
+ if (!soap_header)
+ {
+ axiom_namespace_free(addressing_namespace, env);
+ return AXIS2_SUCCESS; /*No SOAP header, so no point proceeding*/
+ }
+
+ /* by this time, we definitely have some addressing information to be sent. This is because,
+ // we have tested at the start of this whether msg_info_headers are null or not.
+ // So rather than declaring addressing namespace in each and every addressing header, lets
+ // define that in the Header itself. */
+ if (soap_header)
+ {
+ const axis2_char_t *action = NULL;
+ const axis2_char_t *address = NULL;
+ const axis2_char_t *svc_group_context_id = NULL;
+ const axis2_char_t *message_id = NULL;
+ axis2_relates_to_t *relates_to = NULL;
+ axiom_node_t *relates_to_header_node = NULL;
+ axiom_element_t *relates_to_header_ele = NULL;
+
+ soap_header_node = axiom_soap_header_get_base_node(soap_header, env);
+ soap_header_ele =
+ (axiom_element_t *)
+ axiom_node_get_data_element(soap_header_node, env);
+ axiom_element_declare_namespace(soap_header_ele, env,
+ soap_header_node, addressing_namespace);
+
+ epr = axis2_msg_info_headers_get_to(msg_info_headers, env);
+
+ if (soap_envelope && epr)
+ {
+ axiom_soap_body_t *body = axiom_soap_envelope_get_body(soap_envelope, env);
+ if (body)
+ {
+ /* in case of a SOAP fault, we got to send the response to
+ the adress specified by FaultTo */
+ if (axiom_soap_body_has_fault(body, env))
+ {
+ axis2_endpoint_ref_t *fault_epr = axis2_msg_info_headers_get_fault_to(msg_info_headers, env);
+ if (fault_epr)
+ {
+ const axis2_char_t *fault_address = axis2_endpoint_ref_get_address(fault_epr, env);
+ if (fault_address)
+ {
+ if (axutil_strcmp(AXIS2_WSA_NONE_URL, fault_address) != 0 &&
+ axutil_strcmp(AXIS2_WSA_NONE_URL_SUBMISSION, fault_address) != 0)
+ {
+ axis2_endpoint_ref_set_address(epr, env, fault_address);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (epr)
+ {
+ address = axis2_endpoint_ref_get_address(epr, env);
+ if (address && axutil_strcmp(address, "") != 0)
+ {
+ axiom_node_t *to_header_block_node = NULL;
+ axiom_soap_header_block_t *to_header_block = NULL;
+
+ to_header_block =
+ axiom_soap_header_add_header_block(soap_header, env,
+ AXIS2_WSA_TO,
+ addressing_namespace);
+ to_header_block_node =
+ axiom_soap_header_block_get_base_node(to_header_block, env);
+ if (to_header_block_node)
+ {
+ axiom_element_t *to_header_block_element = NULL;
+ to_header_block_element = (axiom_element_t*)axiom_node_get_data_element(to_header_block_node, env);
+ if (to_header_block_element)
+ {
+ axiom_element_set_text(to_header_block_element, env, address, to_header_block_node);
+ }
+ }
+ }
+ }
+
+ action = axis2_msg_info_headers_get_action(msg_info_headers, env);
+ if (action && axutil_strcmp(action, ""))
+ {
+ axis2_addr_out_handler_process_string_info(env, action,
+ AXIS2_WSA_ACTION,
+ &soap_header,
+ addr_ns);
+ }
+
+ epr = axis2_msg_info_headers_get_reply_to(msg_info_headers, env);
+ if (!epr)
+ {
+ const axis2_char_t *anonymous_uri = NULL;
+ axis2_bool_t anonymous = axis2_msg_info_headers_get_reply_to_anonymous(msg_info_headers, env);
+ axis2_bool_t none = axis2_msg_info_headers_get_reply_to_none(msg_info_headers, env);
+ if (axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION) == 0)
+ {
+ if (none)
+ anonymous_uri = AXIS2_WSA_NONE_URL_SUBMISSION;
+ else if (anonymous)
+ anonymous_uri = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION;
+ }
+ else
+ {
+ if (none)
+ anonymous_uri = AXIS2_WSA_NONE_URL;
+ else if (anonymous)
+ anonymous_uri = AXIS2_WSA_ANONYMOUS_URL;
+ }
+
+ if (anonymous_uri)
+ epr = axis2_endpoint_ref_create(env, anonymous_uri);
+ if (epr)
+ axis2_msg_info_headers_set_reply_to(msg_info_headers, env, epr);
+ }
+
+
+ /* add the service group id as a reference parameter */
+ svc_group_context_id = axutil_string_get_buffer(
+ axis2_msg_ctx_get_svc_grp_ctx_id(msg_ctx, env), env);
+
+ axis2_addr_out_handler_add_to_soap_header(env, epr,
+ AXIS2_WSA_REPLY_TO,
+ soap_header, addr_ns);
+
+ /* It is wrong freeing the epr here. Instead I set the locally
+ * created epr to msg_info_headers just after creating it
+ */
+ /*if( epr)
+ {
+ axis2_endpoint_ref_free(epr, env);
+ epr = NULL;
+ }*/
+
+ epr = axis2_msg_info_headers_get_from(msg_info_headers, env);
+
+ if (epr)
+ {
+ axis2_addr_out_handler_add_to_soap_header(env, epr,
+ AXIS2_WSA_FROM,
+ soap_header, addr_ns);
+
+ }
+
+ epr = axis2_msg_info_headers_get_fault_to(msg_info_headers, env);
+ if (!epr)
+ {
+ const axis2_char_t *anonymous_uri = NULL;
+ axis2_bool_t anonymous = axis2_msg_info_headers_get_fault_to_anonymous(msg_info_headers, env);
+ axis2_bool_t none = axis2_msg_info_headers_get_fault_to_none(msg_info_headers, env);
+ if (axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION) == 0)
+ {
+ if (none)
+ anonymous_uri = AXIS2_WSA_NONE_URL_SUBMISSION;
+ else if (anonymous)
+ anonymous_uri = AXIS2_WSA_ANONYMOUS_URL_SUBMISSION;
+ }
+ else
+ {
+ if (none)
+ anonymous_uri = AXIS2_WSA_NONE_URL;
+ else if (anonymous)
+ anonymous_uri = AXIS2_WSA_ANONYMOUS_URL;
+ }
+
+ if (anonymous_uri)
+ epr = axis2_endpoint_ref_create(env, anonymous_uri);
+ }
+
+ if (epr)
+ {
+ /* optional */
+ axis2_addr_out_handler_add_to_soap_header(env, epr,
+ AXIS2_WSA_FAULT_TO,
+ soap_header, addr_ns);
+ }
+
+ message_id = axis2_msg_info_headers_get_message_id(msg_info_headers, env);
+
+ if (message_id)
+ {
+ axis2_addr_out_handler_process_string_info(env, message_id,
+ AXIS2_WSA_MESSAGE_ID,
+ &soap_header,
+ addr_ns);
+ }
+
+ relates_to = axis2_msg_info_headers_get_relates_to(msg_info_headers, env);
+ if (relates_to)
+ {
+ const axis2_char_t *value = NULL;
+ value = axis2_relates_to_get_value(relates_to, env);
+ relates_to_header_node =
+ axis2_addr_out_handler_process_string_info(env, value,
+ AXIS2_WSA_RELATES_TO,
+ &soap_header,
+ addr_ns);
+ }
+
+ if (relates_to_header_node)
+ {
+ const axis2_char_t *relationship_type = NULL;
+ relationship_type = axis2_relates_to_get_relationship_type(relates_to, env);
+ if (axutil_strcmp(relationship_type, "") != 0)
+ {
+ axiom_attribute_t *om_attr = NULL;
+ axiom_namespace_t *addr_ns_obj = NULL;
+ axiom_namespace_t *dec_ns = NULL;
+ relates_to_header_ele =
+ (axiom_element_t *)
+ axiom_node_get_data_element(relates_to_header_node,
+ env);
+ if (relates_to_header_ele)
+ {
+ dec_ns = axiom_element_find_declared_namespace(relates_to_header_ele, env,
+ addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ if (dec_ns)
+ {
+ addr_ns_obj = dec_ns;
+ }
+ else
+ {
+ addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ }
+
+ om_attr = axiom_attribute_create(env,
+ AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE,
+ AXIS2_WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE,
+ addr_ns_obj);
+
+ axiom_element_add_attribute(relates_to_header_ele, env,
+ om_attr, relates_to_header_node);
+
+ }
+ if (relates_to_header_ele)
+ {
+ dec_ns = axiom_element_find_declared_namespace(relates_to_header_ele, env,
+ addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ if (! dec_ns)
+ {
+ dec_ns = axiom_element_find_namespace(relates_to_header_ele, env,
+ relates_to_header_node, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ if (dec_ns)
+ {
+ axiom_namespace_free(addr_ns_obj, env);
+ addr_ns_obj = NULL ;
+ axiom_attribute_set_namespace(om_attr, env, dec_ns);
+ }
+ }
+ }
+
+ }
+ }
+ }
+ return AXIS2_SUCCESS;
+}
+
+
+axiom_node_t *
+axis2_addr_out_handler_process_string_info(const axutil_env_t *env,
+ const axis2_char_t * value,
+ const axis2_char_t * type,
+ axiom_soap_header_t **
+ soap_header_p,
+ const axis2_char_t * addr_ns)
+{
+ axiom_soap_header_t *soap_header = NULL;
+ axiom_soap_header_block_t *header_block = NULL;
+ axiom_node_t *header_block_node = NULL;
+ axiom_element_t *header_block_ele = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+ AXIS2_PARAM_CHECK(env->error, value, NULL);
+ AXIS2_PARAM_CHECK(env->error, type, NULL);
+ AXIS2_PARAM_CHECK(env->error, soap_header_p, NULL);
+ AXIS2_PARAM_CHECK(env->error, addr_ns, NULL);
+
+ soap_header = *(soap_header_p);
+
+ if (value && axutil_strcmp(value, "") != 0)
+ {
+ axiom_namespace_t *addr_ns_obj = NULL;
+ addr_ns_obj =
+ axiom_namespace_create(env, addr_ns,
+ AXIS2_WSA_DEFAULT_PREFIX);
+ header_block =
+ axiom_soap_header_add_header_block(soap_header, env, type,
+ addr_ns_obj);
+ header_block_node =
+ axiom_soap_header_block_get_base_node(header_block, env);
+ header_block_ele =
+ (axiom_element_t *)
+ axiom_node_get_data_element(header_block_node, env);
+ if (header_block_ele)
+ {
+ axiom_namespace_t *dec_ns = NULL;
+ axiom_element_set_text(header_block_ele, env, value,
+ header_block_node);
+ dec_ns = axiom_element_find_declared_namespace(header_block_ele, env,
+ addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ if (! dec_ns)
+ {
+ axiom_namespace_free(addr_ns_obj, env);
+ addr_ns_obj = NULL;
+ }
+ }
+ }
+ return header_block_node;
+}
+
+axis2_status_t
+axis2_addr_out_handler_add_to_soap_header(const axutil_env_t *env,
+ axis2_endpoint_ref_t *
+ endpoint_ref,
+ const axis2_char_t * type,
+ axiom_soap_header_t * soap_header,
+ const axis2_char_t * addr_ns)
+{
+ axiom_soap_header_block_t *header_block = NULL;
+ const axis2_char_t *address = NULL;
+ axutil_array_list_t *ref_param_list = NULL;
+ axutil_array_list_t *meta_data_list = NULL;
+ axutil_array_list_t *extension_list = NULL;
+ axiom_node_t *header_block_node = NULL;
+ axiom_node_t *header_node = NULL;
+ axiom_namespace_t *addr_ns_obj = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, endpoint_ref, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, type, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, soap_header, AXIS2_FAILURE);
+
+ header_node = axiom_soap_header_get_base_node(soap_header, env);
+
+ addr_ns_obj = axiom_namespace_create(env,
+ addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ header_block =
+ axiom_soap_header_add_header_block(soap_header, env, type,
+ addr_ns_obj);
+
+ if (addr_ns_obj)
+ {
+ axiom_namespace_free(addr_ns_obj, env);
+ addr_ns_obj = NULL;
+ }
+
+ address = axis2_endpoint_ref_get_address(endpoint_ref, env);
+ if (address && axutil_strcmp("", address) != 0)
+ {
+ axiom_node_t *hb_node = NULL;
+ axiom_element_t *hb_ele = NULL;
+ axiom_node_t *address_node = NULL;
+ axiom_element_t *address_ele = NULL;
+ hb_node = axiom_soap_header_block_get_base_node(header_block, env);
+ hb_ele = (axiom_element_t *)
+ axiom_node_get_data_element(hb_node, env);
+
+ addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+
+ address_ele =
+ axiom_element_create(env, hb_node, EPR_ADDRESS, addr_ns_obj,
+ &address_node);
+ if (address_ele)
+ {
+ axiom_namespace_t *dec_ns = NULL;
+ axiom_element_set_text(address_ele, env, address, address_node);
+ dec_ns = axiom_element_find_declared_namespace(address_ele, env,
+ addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ if (! dec_ns)
+ {
+ axiom_namespace_free(addr_ns_obj, env);
+ addr_ns_obj = NULL;
+ }
+ }
+ }
+
+ header_block_node =
+ axiom_soap_header_block_get_base_node(header_block, env);
+ axis2_addr_out_handler_add_to_header(env, endpoint_ref,
+ &header_block_node, addr_ns);
+
+ ref_param_list = axis2_endpoint_ref_get_ref_param_list(endpoint_ref, env);
+ if (ref_param_list && axutil_array_list_size(ref_param_list, env) > 0)
+ {
+ axiom_node_t *reference_node = NULL;
+ axiom_element_t *reference_ele = NULL;
+ axutil_array_list_t *ref_attribute_list = NULL;
+ int i = 0;
+
+ addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+
+ reference_ele = axiom_element_create(env,
+ header_block_node,
+ EPR_REFERENCE_PARAMETERS,
+ addr_ns_obj,
+ &reference_node);
+
+ ref_attribute_list = axis2_endpoint_ref_get_ref_attribute_list(endpoint_ref, env);
+ if (ref_attribute_list)
+ {
+ int j = 0;
+ for (j = 0; j < axutil_array_list_size(ref_attribute_list, env); j++)
+ {
+ axiom_attribute_t *attr = (axiom_attribute_t *)axutil_array_list_get(ref_attribute_list, env, j);
+ if (attr)
+ {
+ axiom_element_add_attribute(reference_ele, env, attr, reference_node);
+ }
+ }
+ }
+
+ for (i = 0; i < axutil_array_list_size(ref_param_list, env); i++)
+ {
+ axiom_node_t *ref_node = (axiom_node_t *)axutil_array_list_get(ref_param_list, env, i);
+ if (ref_node)
+ {
+ axiom_node_add_child(reference_node, env, ref_node);
+ }
+ }
+
+ }
+
+ meta_data_list = axis2_endpoint_ref_get_metadata_list(endpoint_ref, env);
+ if (meta_data_list && axutil_array_list_size(meta_data_list, env) > 0)
+ {
+ axiom_node_t *reference_node = NULL;
+ axiom_element_t *reference_ele = NULL;
+ axutil_array_list_t *meta_attribute_list = NULL;
+ int i = 0;
+
+ if (!reference_node) /* may be we alredy created this in ref params block */
+ {
+ addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+
+ reference_ele = axiom_element_create(env,
+ header_block_node,
+ AXIS2_WSA_METADATA,
+ addr_ns_obj,
+ &reference_node);
+ }
+
+ meta_attribute_list = axis2_endpoint_ref_get_metadata_attribute_list(endpoint_ref, env);
+ if (meta_attribute_list)
+ {
+ int j = 0;
+ for (j = 0; j < axutil_array_list_size(meta_attribute_list, env); j++)
+ {
+ axiom_attribute_t *attr = (axiom_attribute_t *)axutil_array_list_get(meta_attribute_list, env, j);
+ if (attr)
+ {
+ axiom_element_add_attribute(reference_ele, env, attr, reference_node);
+ }
+ }
+ }
+
+ for (i = 0; i < axutil_array_list_size(meta_data_list, env); i ++)
+ {
+ axiom_node_t *ref_node = (axiom_node_t *)axutil_array_list_get(meta_data_list, env, i);
+ if (ref_node)
+ {
+ axiom_node_add_child(reference_node, env, ref_node);
+ }
+ }
+ }
+
+ extension_list = axis2_endpoint_ref_get_extension_list(endpoint_ref, env);
+ if (extension_list && axutil_array_list_size(extension_list, env) > 0)
+ {
+ int i = 0;
+ for (i = 0; i < axutil_array_list_size(extension_list, env); i ++)
+ {
+ axiom_node_t *ref_node = (axiom_node_t *)axutil_array_list_get(extension_list, env, i);
+ if (ref_node)
+ {
+ axiom_node_add_child(header_block_node, env, ref_node);
+ }
+ }
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t
+axis2_addr_out_handler_add_to_header(const axutil_env_t *env,
+ axis2_endpoint_ref_t * epr,
+ axiom_node_t ** parent_node_p,
+ const axis2_char_t * addr_ns)
+{
+ axiom_node_t *parent_node = NULL;
+ const axutil_qname_t *interface_qname = NULL;
+ axiom_node_t *interface_node = NULL;
+ axiom_element_t *interface_ele = NULL;
+ const axis2_char_t *element_localname = NULL;
+ axis2_svc_name_t *service_name = NULL;
+ axiom_namespace_t *addr_ns_obj = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, epr, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, parent_node_p, AXIS2_FAILURE);
+
+ parent_node = *(parent_node_p);
+
+
+ interface_qname = axis2_endpoint_ref_get_interface_qname(epr, env);
+
+ if (interface_qname)
+ {
+ axis2_char_t *text = NULL;
+ axis2_char_t *qname_prefix = NULL;
+ axis2_char_t *qname_localpart = NULL;
+
+ addr_ns_obj = axiom_namespace_create(env, addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+
+ if (axutil_strcmp(addr_ns, AXIS2_WSA_NAMESPACE_SUBMISSION) == 0)
+ {
+ element_localname = EPR_PORT_TYPE;
+ }
+ else
+ {
+ element_localname = AXIS2_WSA_INTERFACE_NAME;
+ }
+
+ interface_ele = axiom_element_create(env, parent_node,
+ element_localname,
+ addr_ns_obj,
+ &interface_node);
+ qname_prefix = axutil_qname_get_prefix(interface_qname, env);
+ qname_localpart = axutil_qname_get_localpart(interface_qname, env);
+
+ text =
+ AXIS2_MALLOC(env->allocator,
+ sizeof(axis2_char_t) *
+ (axutil_strlen(qname_prefix) +
+ axutil_strlen(qname_localpart) + 2));
+ sprintf(text, "%s:%s", qname_prefix, qname_localpart);
+ axiom_element_set_text(interface_ele, env, text, interface_node);
+ AXIS2_FREE(env->allocator, text);
+ if (interface_ele)
+ {
+ axiom_namespace_t *dec_ns = NULL;
+ dec_ns = axiom_element_find_declared_namespace(interface_ele , env,
+ addr_ns, AXIS2_WSA_DEFAULT_PREFIX);
+ if (! dec_ns)
+ {
+ axiom_namespace_free(addr_ns_obj, env);
+ addr_ns_obj = NULL;
+ }
+ }
+
+ }
+
+ service_name = axis2_endpoint_ref_get_svc_name(epr, env);
+ return AXIS2_SUCCESS;
+}
+
+
+axis2_status_t
+axis2_addr_out_handler_process_any_content_type(const axutil_env_t *env,
+ axis2_any_content_type_t *
+ reference_values,
+ axiom_node_t *
+ parent_ele_node,
+ const axis2_char_t * addr_ns)
+{
+ axutil_hash_t *value_ht = NULL;
+ axutil_hash_index_t *hash_index = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ if (reference_values)
+ {
+ const void *k = NULL;
+ void *v = NULL;
+ axis2_ssize_t len = 0;
+ value_ht =
+ axis2_any_content_type_get_value_map(reference_values, env);
+ if (!value_ht)
+ return AXIS2_FAILURE;
+
+ for (hash_index = axutil_hash_first(value_ht, env); hash_index;
+ hash_index = axutil_hash_next(env, hash_index))
+ {
+ axutil_hash_this(hash_index, &k, &len, &v);
+ if (k)
+ {
+ axiom_node_t *node = NULL;
+ axiom_element_t *ele = NULL;
+ ele =
+ axiom_element_create(env, parent_ele_node, k, NULL,
+ &node);
+ if (ele)
+ {
+ if (axutil_strcmp(AXIS2_WSA_NAMESPACE, addr_ns) == 0)
+ {
+ axiom_namespace_t *addr_ns_obj = NULL;
+ axiom_attribute_t *att = NULL;
+ addr_ns_obj =
+ axiom_namespace_create(env, addr_ns,
+ AXIS2_WSA_DEFAULT_PREFIX);
+ att =
+ axiom_attribute_create(env,
+ AXIS2_WSA_IS_REFERENCE_PARAMETER_ATTRIBUTE,
+ AXIS2_WSA_TYPE_ATTRIBUTE_VALUE,
+ addr_ns_obj);
+ }
+ axiom_element_set_text(ele, env, v, node);
+ }
+ }
+ }
+ }
+ return AXIS2_SUCCESS;
+}
Added: webservices/axis2/trunk/c/src/modules/mod_addr/mod_addr.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/modules/mod_addr/mod_addr.c?view=auto&rev=528966
==============================================================================
--- webservices/axis2/trunk/c/src/modules/mod_addr/mod_addr.c (added)
+++ webservices/axis2/trunk/c/src/modules/mod_addr/mod_addr.c Sun Apr 15 04:42:08 2007
@@ -0,0 +1,135 @@
+/*
+ * Licensed 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.
+ */
+#include <axis2_module.h>
+#include <axis2_addr_mod.h>
+#include <axis2_conf_ctx.h>
+
+axis2_status_t AXIS2_CALL
+axis2_mod_addr_shutdown(axis2_module_t *module,
+ const axutil_env_t *env);
+
+axis2_status_t AXIS2_CALL
+axis2_mod_addr_init(
+ axis2_module_t *module,
+ const axutil_env_t *env,
+ axis2_conf_ctx_t *conf_ctx,
+ axis2_module_desc_t *module_desc);
+
+axis2_status_t AXIS2_CALL
+axis2_mod_addr_fill_handler_create_func_map(axis2_module_t *module,
+ const axutil_env_t *env);
+
+static const axis2_module_ops_t addr_module_ops_var = {
+ axis2_mod_addr_init,
+ axis2_mod_addr_shutdown,
+ axis2_mod_addr_fill_handler_create_func_map
+};
+
+axis2_module_t *
+axis2_mod_addr_create(const axutil_env_t *env)
+{
+ axis2_module_t *module = NULL;
+ module = AXIS2_MALLOC(env->allocator,
+ sizeof(axis2_module_t));
+
+ module->ops = &addr_module_ops_var;
+
+ return module;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_mod_addr_init(
+ axis2_module_t *module,
+ const axutil_env_t *env,
+ axis2_conf_ctx_t *conf_ctx,
+ axis2_module_desc_t *module_desc)
+{
+ /* Any initialization stuff of mod_addr goes here */
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_mod_addr_shutdown(axis2_module_t *module,
+ const axutil_env_t *env)
+{
+ if (module->handler_create_func_map)
+ {
+ /* TODO
+ * do the neccessary clean in hash map
+ */
+ axutil_hash_free(module->handler_create_func_map, env);
+ module->handler_create_func_map = NULL;
+ }
+
+ if (module)
+ {
+ AXIS2_FREE(env->allocator, module);
+ module = NULL;
+ }
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_mod_addr_fill_handler_create_func_map(axis2_module_t *module,
+ const axutil_env_t *env)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ module->handler_create_func_map = axutil_hash_make(env);
+ if (!module->handler_create_func_map)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY,
+ AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+ axutil_hash_set(module->handler_create_func_map, "AddressingInHandler",
+ AXIS2_HASH_KEY_STRING, axis2_addr_in_handler_create);
+
+ axutil_hash_set(module->handler_create_func_map, "AddressingOutHandler",
+ AXIS2_HASH_KEY_STRING, axis2_addr_out_handler_create);
+
+ return AXIS2_SUCCESS;
+}
+
+/**
+ * Following block distinguish the exposed part of the dll.
+ */
+
+AXIS2_EXPORT int
+axis2_get_instance(axis2_module_t **inst,
+ const axutil_env_t *env)
+{
+ *inst = axis2_mod_addr_create(env);
+ if (!(*inst))
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT int
+axis2_remove_instance(axis2_module_t *inst,
+ const axutil_env_t *env)
+{
+ axis2_status_t status = AXIS2_FAILURE;
+ if (inst)
+ {
+ status = axis2_mod_addr_shutdown(inst, env);
+ }
+ return status;
+}
Added: webservices/axis2/trunk/c/src/modules/mod_addr/module.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/modules/mod_addr/module.xml?view=auto&rev=528966
==============================================================================
--- webservices/axis2/trunk/c/src/modules/mod_addr/module.xml (added)
+++ webservices/axis2/trunk/c/src/modules/mod_addr/module.xml Sun Apr 15 04:42:08 2007
@@ -0,0 +1,19 @@
+<module name="addressing" class="axis2_mod_addr">
+ <inflow>
+ <handler name="AddressingInHandler" class="axis2_mod_addr">
+ <order phase="PreDispatch"/>
+ </handler>
+ </inflow>
+
+ <outflow>
+ <handler name="AddressingOutHandler" class="axis2_mod_addr">
+ <order phase="MessageOut"/>
+ </handler>
+ </outflow>
+
+ <Outfaultflow>
+ <handler name="AddressingOutHandler" class="axis2_mod_addr">
+ <order phase="MessageOut"/>
+ </handler>
+ </Outfaultflow>
+</module>
Added: webservices/axis2/trunk/c/src/modules/mod_log/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/modules/mod_log/Makefile.am?view=auto&rev=528966
==============================================================================
--- webservices/axis2/trunk/c/src/modules/mod_log/Makefile.am (added)
+++ webservices/axis2/trunk/c/src/modules/mod_log/Makefile.am Sun Apr 15 04:42:08 2007
@@ -0,0 +1,22 @@
+prglibdir=$(prefix)/modules/logging
+prglib_LTLIBRARIES = libaxis2_mod_log.la
+prglib_DATA= module.xml
+EXTRA_DIST = module.xml mod_log.h
+libaxis2_mod_log_la_SOURCES = log_in_handler.c \
+ log_out_handler.c \
+ mod_log.c
+
+libaxis2_mod_log_la_LIBADD = \
+ $(top_builddir)/src/core/engine/libaxis2_engine.la \
+ $(top_builddir)/util/src/libaxutil.la \
+ $(top_builddir)/axiom/src/om/libaxis2_axiom.la
+
+INCLUDES = -I$(top_builddir)/include \
+ -I$(top_builddir)/src/core/description \
+ -I$(top_builddir)/src/core/context \
+ -I$(top_builddir)/src/core/phaseresolver \
+ -I$(top_builddir)/src/core/engine \
+ -I$(top_builddir)/src/core/deployment \
+ -I$(top_builddir)/util/include\
+ -I$(top_builddir)/axiom/include
+
Added: webservices/axis2/trunk/c/src/modules/mod_log/log_in_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/modules/mod_log/log_in_handler.c?view=auto&rev=528966
==============================================================================
--- webservices/axis2/trunk/c/src/modules/mod_log/log_in_handler.c (added)
+++ webservices/axis2/trunk/c/src/modules/mod_log/log_in_handler.c Sun Apr 15 04:42:08 2007
@@ -0,0 +1,90 @@
+/*
+ * Licensed 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.
+ */
+
+#include <axis2_handler_desc.h>
+#include <axutil_array_list.h>
+#include <axiom_soap_const.h>
+#include <axiom_soap_envelope.h>
+#include <axiom_soap_header.h>
+#include <axiom_soap_header_block.h>
+#include <axis2_op.h>
+#include <axis2_msg_ctx.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_msg_info_headers.h>
+#include <axutil_property.h>
+
+axis2_status_t AXIS2_CALL
+axutil_log_in_handler_invoke(struct axis2_handler *handler,
+ const axutil_env_t *env,
+ struct axis2_msg_ctx *msg_ctx);
+
+AXIS2_EXTERN axis2_handler_t* AXIS2_CALL
+axutil_log_in_handler_create(const axutil_env_t *env,
+ axutil_string_t *name)
+{
+ axis2_handler_t *handler = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ handler = axis2_handler_create(env);
+ if (!handler)
+ {
+ return NULL;
+ }
+
+ axis2_handler_set_invoke(handler, env, axutil_log_in_handler_invoke);
+
+ return handler;
+}
+
+
+axis2_status_t AXIS2_CALL
+axutil_log_in_handler_invoke(struct axis2_handler *handler,
+ const axutil_env_t *env,
+ struct axis2_msg_ctx *msg_ctx)
+{
+ axiom_soap_envelope_t *soap_envelope = NULL;
+ axiom_node_t *ret_node = NULL;
+
+ AXIS2_ENV_CHECK( env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ AXIS2_LOG_INFO(env->log, "Starting logging in handler .........");
+
+ soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
+
+ if (soap_envelope)
+ {
+ /* ensure SOAP buider state is in sync */
+ axiom_soap_envelope_get_body(soap_envelope, env);
+ ret_node = axiom_soap_envelope_get_base_node(soap_envelope, env);
+
+ if(ret_node)
+ {
+ axis2_char_t *om_str = NULL;
+ om_str = axiom_node_to_string(ret_node, env);
+ if(om_str)
+ {
+ AXIS2_LOG_INFO(env->log, "Input message: %s", om_str);
+ }
+ }
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+
Added: webservices/axis2/trunk/c/src/modules/mod_log/log_out_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/modules/mod_log/log_out_handler.c?view=auto&rev=528966
==============================================================================
--- webservices/axis2/trunk/c/src/modules/mod_log/log_out_handler.c (added)
+++ webservices/axis2/trunk/c/src/modules/mod_log/log_out_handler.c Sun Apr 15 04:42:08 2007
@@ -0,0 +1,88 @@
+/*
+ * Licensed 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.
+ */
+
+#include <axis2_handler_desc.h>
+#include <axutil_array_list.h>
+#include <axiom_soap_const.h>
+#include <axiom_soap_envelope.h>
+#include <axiom_soap_header.h>
+#include <axiom_soap_header_block.h>
+#include <axis2_op.h>
+#include <axis2_msg_ctx.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_msg_info_headers.h>
+#include <axutil_property.h>
+
+axis2_status_t AXIS2_CALL
+axutil_log_out_handler_invoke(struct axis2_handler *handler,
+ const axutil_env_t *env,
+ struct axis2_msg_ctx *msg_ctx);
+
+AXIS2_EXTERN axis2_handler_t* AXIS2_CALL
+axutil_log_out_handler_create(const axutil_env_t *env,
+ axutil_string_t *name)
+{
+ axis2_handler_t *handler = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ handler = axis2_handler_create(env);
+ if (!handler)
+ {
+ return NULL;
+ }
+
+ axis2_handler_set_invoke(handler, env, axutil_log_out_handler_invoke);
+
+ return handler;
+}
+
+
+axis2_status_t AXIS2_CALL
+axutil_log_out_handler_invoke(struct axis2_handler *handler,
+ const axutil_env_t *env,
+ struct axis2_msg_ctx *msg_ctx)
+{
+ axiom_soap_envelope_t *soap_envelope = NULL;
+ axiom_node_t *ret_node = NULL;
+
+ AXIS2_ENV_CHECK( env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ AXIS2_LOG_INFO(env->log, "Starting logging out handler .........");
+
+ soap_envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
+
+ if (soap_envelope)
+ {
+ ret_node = axiom_soap_envelope_get_base_node(soap_envelope, env);
+
+ if(ret_node)
+ {
+ axis2_char_t *om_str = NULL;
+ om_str = axiom_node_to_string(ret_node, env);
+ if(om_str)
+ {
+ AXIS2_LOG_INFO(env->log, "Output message: %s", om_str);
+ }
+ }
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+
Added: webservices/axis2/trunk/c/src/modules/mod_log/mod_log.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/modules/mod_log/mod_log.c?view=auto&rev=528966
==============================================================================
--- webservices/axis2/trunk/c/src/modules/mod_log/mod_log.c (added)
+++ webservices/axis2/trunk/c/src/modules/mod_log/mod_log.c Sun Apr 15 04:42:08 2007
@@ -0,0 +1,141 @@
+/*
+ * Licensed 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.
+ */
+#include <axis2_module.h>
+#include <axis2_conf_ctx.h>
+
+#include "mod_log.h"
+
+axis2_status_t AXIS2_CALL
+axis2_mod_log_shutdown(axis2_module_t *module,
+ const axutil_env_t *env);
+
+axis2_status_t AXIS2_CALL
+axis2_mod_log_init(
+ axis2_module_t *module,
+ const axutil_env_t *env,
+ axis2_conf_ctx_t *conf_ctx,
+ axis2_module_desc_t *module_desc);
+
+axis2_status_t AXIS2_CALL
+axis2_mod_log_fill_handler_create_func_map(axis2_module_t *module,
+ const axutil_env_t *env);
+
+/**
+ * Module operations struct variable with functions assigned to members
+ */
+static const axis2_module_ops_t log_module_ops_var = {
+ axis2_mod_log_init,
+ axis2_mod_log_shutdown,
+ axis2_mod_log_fill_handler_create_func_map
+};
+
+axis2_module_t *
+axis2_mod_log_create(const axutil_env_t *env)
+{
+ axis2_module_t *module = NULL;
+ module = AXIS2_MALLOC(env->allocator,
+ sizeof(axis2_module_t));
+
+ /* initialize operations */
+ module->ops = &log_module_ops_var;
+
+ return module;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_mod_log_init(
+ axis2_module_t *module,
+ const axutil_env_t *env,
+ axis2_conf_ctx_t *conf_ctx,
+ axis2_module_desc_t *module_desc)
+{
+ /* Any initialization stuff related to this module can be here */
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_mod_log_shutdown(axis2_module_t *module,
+ const axutil_env_t *env)
+{
+ if(module->handler_create_func_map)
+ {
+ axutil_hash_free(module->handler_create_func_map, env);
+ }
+
+ if(module)
+ {
+ AXIS2_FREE(env->allocator, module);
+ }
+ return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+axis2_mod_log_fill_handler_create_func_map(axis2_module_t *module,
+ const axutil_env_t *env)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+
+ module->handler_create_func_map = axutil_hash_make(env);
+ if(!module->handler_create_func_map)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY,
+ AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+
+ /* add in handler */
+ axutil_hash_set(module->handler_create_func_map, "LoggingInHandler",
+ AXIS2_HASH_KEY_STRING, axutil_log_in_handler_create);
+
+ /* add out handler */
+ axutil_hash_set(module->handler_create_func_map, "LoggingOutHandler",
+ AXIS2_HASH_KEY_STRING, axutil_log_out_handler_create);
+
+ return AXIS2_SUCCESS;
+}
+
+/**
+ * Following functions are expected to be there in the module lib
+ * that helps to create and remove module instances
+ */
+
+AXIS2_EXPORT int
+axis2_get_instance(axis2_module_t **inst,
+ const axutil_env_t *env)
+{
+ *inst = axis2_mod_log_create(env);
+ if(!(*inst))
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT int
+axis2_remove_instance(axis2_module_t *inst,
+ const axutil_env_t *env)
+{
+ axis2_status_t status = AXIS2_FAILURE;
+ if (inst)
+ {
+ status = axis2_mod_log_shutdown(inst, env);
+ }
+ return status;
+}
+
+
Added: webservices/axis2/trunk/c/src/modules/mod_log/mod_log.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/modules/mod_log/mod_log.h?view=auto&rev=528966
==============================================================================
--- webservices/axis2/trunk/c/src/modules/mod_log/mod_log.h (added)
+++ webservices/axis2/trunk/c/src/modules/mod_log/mod_log.h Sun Apr 15 04:42:08 2007
@@ -0,0 +1,47 @@
+/*
+ * Licensed 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_MOD_LOG_H
+#define AXIS2_MOD_LOG_H
+
+/**
+ * @file mod_log.h
+ * @brief Axis2 logging module interface
+ */
+
+#include <axis2_handler.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+AXIS2_EXTERN axis2_handler_t* AXIS2_CALL
+axutil_log_in_handler_create(const axutil_env_t *env,
+ axutil_string_t *name);
+
+AXIS2_EXTERN axis2_handler_t* AXIS2_CALL
+axutil_log_out_handler_create(const axutil_env_t *env,
+ axutil_string_t *name);
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* AXIS2_MOD_LOG_H */
Added: webservices/axis2/trunk/c/src/modules/mod_log/module.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/src/modules/mod_log/module.xml?view=auto&rev=528966
==============================================================================
--- webservices/axis2/trunk/c/src/modules/mod_log/module.xml (added)
+++ webservices/axis2/trunk/c/src/modules/mod_log/module.xml Sun Apr 15 04:42:08 2007
@@ -0,0 +1,19 @@
+<module name="logging" class="axis2_mod_log">
+ <inflow>
+ <handler name="LoggingInHandler" class="axis2_mod_log">
+ <order phase="PreDispatch"/>
+ </handler>
+ </inflow>
+
+ <outflow>
+ <handler name="LoggingOutHandler" class="axis2_mod_log">
+ <order phase="MessageOut"/>
+ </handler>
+ </outflow>
+
+ <Outfaultflow>
+ <handler name="LoggingOutHandler" class="axis2_mod_log">
+ <order phase="MessageOut"/>
+ </handler>
+ </Outfaultflow>
+</module>
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org