summaryrefslogtreecommitdiffstats
path: root/src/core/receivers
diff options
context:
space:
mode:
authorGravatar gmcdonald2010-02-13 01:32:03 +0000
committerGravatar gmcdonald2010-02-13 01:32:03 +0000
commit0425aadc78680e53000fd0108b540d6eca048516 (patch)
tree8ec7ab8e015d454c5ec586dfc91e05a2dce1cfc0 /src/core/receivers
downloadaxis2c-0425aadc78680e53000fd0108b540d6eca048516.tar.gz
axis2c-0425aadc78680e53000fd0108b540d6eca048516.tar.bz2
Moving axis svn, part of TLP move INFRA-2441
git-svn-id: http://svn.apache.org/repos/asf/axis/axis2/c/core/trunk@909681 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/core/receivers')
-rw-r--r--src/core/receivers/Makefile.am11
-rw-r--r--src/core/receivers/msg_recv.c560
-rw-r--r--src/core/receivers/raw_xml_in_out_msg_recv.c442
-rw-r--r--src/core/receivers/svr_callback.c112
4 files changed, 1125 insertions, 0 deletions
diff --git a/src/core/receivers/Makefile.am b/src/core/receivers/Makefile.am
new file mode 100644
index 0000000..8b12372
--- /dev/null
+++ b/src/core/receivers/Makefile.am
@@ -0,0 +1,11 @@
+noinst_LTLIBRARIES = libaxis2_receivers.la
+
+libaxis2_receivers_la_SOURCES = msg_recv.c \
+ raw_xml_in_out_msg_recv.c \
+ svr_callback.c
+
+INCLUDES = -I$(top_builddir)/include \
+ -I$(top_builddir)/src/core/engine \
+ -I$(top_builddir)/src/core/util \
+ -I$(top_builddir)/util/include \
+ -I$(top_builddir)/axiom/include
diff --git a/src/core/receivers/msg_recv.c b/src/core/receivers/msg_recv.c
new file mode 100644
index 0000000..87bcc1d
--- /dev/null
+++ b/src/core/receivers/msg_recv.c
@@ -0,0 +1,560 @@
+/*
+ * 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_msg_recv.h>
+#include <axutil_param.h>
+#include <axis2_description.h>
+#include <axutil_class_loader.h>
+#include <axis2_engine.h>
+#include <axis2_core_utils.h>
+#include <axutil_property.h>
+#include <axiom_soap_envelope.h>
+#include <axiom_soap_body.h>
+#include <axutil_thread.h>
+
+struct axis2_msg_recv
+{
+ axis2_char_t *scope;
+ /**
+ * conf ctx is added to pass for the load_and_init_svc method
+ */
+ axis2_conf_ctx_t *conf_ctx;
+
+ void *derived;
+
+ /**
+ * This contain in out synchronous business invoke logic
+ * @param msg_recv pointer to message receiver
+ * @param env pointer to environment struct
+ * @param in_msg_ctx pointer to in message context
+ * @param out_msg_ctx pointer to out message context
+ * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+ */
+ axis2_status_t
+ (
+ AXIS2_CALL * invoke_business_logic)
+ (
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx * in_msg_ctx,
+ struct axis2_msg_ctx * out_msg_ctx);
+
+ /**
+ * This method is called from axis2_engine_receive method. This method's
+ * actual implementation is decided from the create method of the
+ * extended message receiver object. There depending on the synchronous or
+ * asynchronous type, receive method is assigned with the synchronous or
+ * asynchronous implementation of receive.
+ * @see raw_xml_in_out_msg_recv_create method where receive is assigned
+ * to receive_sync
+ * @param msg_recv pointer to message receiver
+ * @param env pointer to environment struct
+ * @param in_msg_ctx pointer to in message context
+ * @return AXIS2_SUCCESS on success, else AXIS2_FAILURE
+ */
+ axis2_status_t
+ (
+ AXIS2_CALL * receive)
+ (
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx * in_msg_ctx,
+ void *callback_recv_param);
+
+ axis2_status_t
+ (
+ AXIS2_CALL *load_and_init_svc)
+( axis2_msg_recv_t *msg_recv,
+const axutil_env_t *env,
+struct axis2_svc *svc);
+
+};
+
+static axis2_status_t AXIS2_CALL
+axis2_msg_recv_receive_impl(
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx,
+ void *callback_recv_param);
+
+static axis2_status_t AXIS2_CALL
+axis2_msg_recv_load_and_init_svc_impl(
+ axis2_msg_recv_t *msg_recv,
+ const axutil_env_t *env,
+ struct axis2_svc *svc)
+{
+ axutil_param_t *impl_info_param = NULL;
+ void *impl_class = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ if(!svc)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ impl_class = axis2_svc_get_impl_class(svc, env);
+ if(impl_class)
+ {
+ return AXIS2_SUCCESS;
+ }
+ /* When we load the DLL we have to make sure that only one thread will load it */
+ axutil_thread_mutex_lock(axis2_svc_get_mutex(svc, env));
+ /* If more than one thread tries to acquires the lock, first thread loads the DLL.
+ Others should not load the DLL */
+ impl_class = axis2_svc_get_impl_class(svc, env);
+ if(impl_class)
+ {
+ axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
+ return AXIS2_SUCCESS;
+ }
+ impl_info_param = axis2_svc_get_param(svc, env, AXIS2_SERVICE_CLASS);
+ if(!impl_info_param)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC, AXIS2_FAILURE);
+ axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
+ return AXIS2_FAILURE;
+ }
+
+ axutil_allocator_switch_to_global_pool(env->allocator);
+
+ axutil_class_loader_init(env);
+
+ impl_class = axutil_class_loader_create_dll(env, impl_info_param);
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "loading the services from msg_recv_load_and_init_svc");
+
+ if(impl_class)
+ {
+ axis2_conf_t *conf = NULL;
+ conf = axis2_conf_ctx_get_conf(msg_recv->conf_ctx, env);
+ AXIS2_SVC_SKELETON_INIT((axis2_svc_skeleton_t *)impl_class, env);
+ }
+
+ axis2_svc_set_impl_class(svc, env, impl_class);
+
+ axutil_allocator_switch_to_local_pool(env->allocator);
+ axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT axis2_msg_recv_t *AXIS2_CALL
+axis2_msg_recv_create(
+ const axutil_env_t * env)
+{
+ axis2_msg_recv_t *msg_recv = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ msg_recv = (axis2_msg_recv_t *)AXIS2_MALLOC(env->allocator, sizeof(axis2_msg_recv_t));
+
+ if(!msg_recv)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+ msg_recv->conf_ctx = NULL;
+ msg_recv->scope = axutil_strdup(env, "app*");
+ msg_recv->derived = NULL;
+ msg_recv->load_and_init_svc = axis2_msg_recv_load_and_init_svc_impl;
+ msg_recv->receive = axis2_msg_recv_receive_impl;
+ return msg_recv;
+}
+
+AXIS2_EXPORT void AXIS2_CALL
+axis2_msg_recv_free(
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env)
+{
+ AXIS2_ENV_CHECK(env, void);
+
+ if(msg_recv->scope)
+ {
+ AXIS2_FREE(env->allocator, msg_recv->scope);
+ }
+
+ if(msg_recv)
+ {
+ AXIS2_FREE(env->allocator, msg_recv);
+ }
+
+ return;
+}
+
+AXIS2_EXPORT axis2_svc_skeleton_t *AXIS2_CALL
+axis2_msg_recv_make_new_svc_obj(
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx * msg_ctx)
+{
+ struct axis2_svc *svc = NULL;
+ struct axis2_op_ctx *op_ctx = NULL;
+ struct axis2_svc_ctx *svc_ctx = NULL;
+ axutil_param_t *impl_info_param = NULL;
+ void *impl_class = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ svc_ctx = axis2_op_ctx_get_parent(op_ctx, env);
+ svc = axis2_svc_ctx_get_svc(svc_ctx, env);
+ if(!svc)
+ {
+ return NULL;
+ }
+
+ impl_class = axis2_svc_get_impl_class(svc, env);
+ if(impl_class)
+ {
+ return impl_class;
+ }
+ else
+ {
+ /* When we load the DLL we have to make sure that only one thread will load it */
+ axutil_thread_mutex_lock(axis2_svc_get_mutex(svc, env));
+ /* If more than one thread tries to acquires the lock, first thread loads the DLL.
+ Others should not load the DLL */
+ impl_class = axis2_svc_get_impl_class(svc, env);
+ if(impl_class)
+ {
+ axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
+ return impl_class;
+ }
+ impl_info_param = axis2_svc_get_param(svc, env, AXIS2_SERVICE_CLASS);
+ if(!impl_info_param)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC, AXIS2_FAILURE);
+ axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
+ return NULL;
+ }
+
+ axutil_allocator_switch_to_global_pool(env->allocator);
+
+ axutil_class_loader_init(env);
+
+ impl_class = axutil_class_loader_create_dll(env, impl_info_param);
+
+ if(impl_class)
+ {
+ AXIS2_SVC_SKELETON_INIT((axis2_svc_skeleton_t *)impl_class, env);
+ }
+
+ axis2_svc_set_impl_class(svc, env, impl_class);
+
+ axutil_allocator_switch_to_local_pool(env->allocator);
+ axutil_thread_mutex_unlock(axis2_svc_get_mutex(svc, env));
+ return impl_class;
+ }
+}
+
+/*AXIS2_EXPORT axis2_svc_skeleton_t *AXIS2_CALL
+axis2_msg_recv_get_impl_obj(
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx * msg_ctx)
+{
+ struct axis2_svc *svc = NULL;
+ struct axis2_op_ctx *op_ctx = NULL;
+ struct axis2_svc_ctx *svc_ctx = NULL;
+
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, NULL);
+
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ svc_ctx = axis2_op_ctx_get_parent(op_ctx, env);
+ svc = axis2_svc_ctx_get_svc(svc_ctx, env);
+ if(!svc)
+ {
+ return NULL;
+ }
+
+ return axis2_msg_recv_make_new_svc_obj(msg_recv, env, msg_ctx);
+}*/
+
+AXIS2_EXPORT axis2_status_t AXIS2_CALL
+axis2_msg_recv_set_scope(
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env,
+ const axis2_char_t * scope)
+{
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, scope, AXIS2_FAILURE);
+
+ if(msg_recv->scope)
+ {
+ AXIS2_FREE(env->allocator, msg_recv->scope);
+ }
+ msg_recv->scope = axutil_strdup(env, scope);
+ if(!msg_recv->scope)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT axis2_char_t *AXIS2_CALL
+axis2_msg_recv_get_scope(
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env)
+{
+ return msg_recv->scope;
+}
+
+AXIS2_EXPORT axis2_status_t AXIS2_CALL
+axis2_msg_recv_delete_svc_obj(
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ axis2_svc_t *svc = NULL;
+ axis2_op_ctx_t *op_ctx = NULL;
+ axis2_svc_ctx_t *svc_ctx = NULL;
+ axutil_param_t *impl_info_param = NULL;
+ axutil_param_t *scope_param = NULL;
+ axis2_char_t *param_value = NULL;
+ axutil_dll_desc_t *dll_desc = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ svc_ctx = axis2_op_ctx_get_parent(op_ctx, env);
+ svc = axis2_svc_ctx_get_svc(svc_ctx, env);
+ if(!svc)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ scope_param = axis2_svc_get_param(svc, env, AXIS2_SCOPE);
+ if(scope_param)
+ {
+ param_value = axutil_param_get_value(scope_param, env);
+ }
+ if(param_value && (0 == axutil_strcmp(AXIS2_APPLICATION_SCOPE, param_value)))
+ {
+ return AXIS2_SUCCESS;
+ }
+
+ impl_info_param = axis2_svc_get_param(svc, env, AXIS2_SERVICE_CLASS);
+ if(!impl_info_param)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_INVALID_STATE_SVC, AXIS2_FAILURE);
+ return AXIS2_FAILURE;
+ }
+ dll_desc = axutil_param_get_value(impl_info_param, env);
+ return axutil_class_loader_delete_dll(env, dll_desc);
+}
+
+static axis2_status_t AXIS2_CALL
+axis2_msg_recv_receive_impl(
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx,
+ void *callback_recv_param)
+{
+ axis2_msg_ctx_t *out_msg_ctx = NULL;
+ axis2_engine_t *engine = NULL;
+ axis2_conf_ctx_t *conf_ctx = NULL;
+ axis2_op_ctx_t *op_ctx = NULL;
+ axis2_svc_ctx_t *svc_ctx = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[axis2]Entry:axis2_msg_recv_receive_impl");
+ out_msg_ctx = axis2_core_utils_create_out_msg_ctx(env, msg_ctx);
+ if(!out_msg_ctx)
+ {
+ return AXIS2_FAILURE;
+ }
+ op_ctx = axis2_msg_ctx_get_op_ctx(out_msg_ctx, env);
+ if(!op_ctx)
+ {
+ axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
+ axis2_msg_ctx_free(out_msg_ctx, env);
+ return AXIS2_FAILURE;
+ }
+
+ status = axis2_op_ctx_add_msg_ctx(op_ctx, env, out_msg_ctx);
+ if(!status)
+ {
+ axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
+ axis2_msg_ctx_free(out_msg_ctx, env);
+ return status;
+ }
+ status = axis2_op_ctx_add_msg_ctx(op_ctx, env, msg_ctx);
+
+ if(!status)
+ {
+ return status;
+ }
+
+ status = axis2_msg_recv_invoke_business_logic(msg_recv, env, msg_ctx, out_msg_ctx);
+ if(AXIS2_SUCCESS != status)
+ {
+ axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
+ axis2_msg_ctx_free(out_msg_ctx, env);
+ return status;
+ }
+ svc_ctx = axis2_op_ctx_get_parent(op_ctx, env);
+ conf_ctx = axis2_svc_ctx_get_conf_ctx(svc_ctx, env);
+ engine = axis2_engine_create(env, conf_ctx);
+ if(!engine)
+ {
+ axis2_msg_ctx_free(out_msg_ctx, env);
+ return AXIS2_FAILURE;
+ }
+ if(axis2_msg_ctx_get_soap_envelope(out_msg_ctx, env))
+ {
+ axiom_soap_envelope_t *soap_envelope = axis2_msg_ctx_get_soap_envelope(out_msg_ctx, env);
+ if(soap_envelope)
+ {
+ axiom_soap_body_t *body = axiom_soap_envelope_get_body(soap_envelope, env);
+ if(body)
+ {
+ /* in case of a SOAP fault, we got to return failure so that
+ transport gets to know that it should send 500 */
+ if(axiom_soap_body_has_fault(body, env))
+ {
+ status = AXIS2_FAILURE;
+ axis2_msg_ctx_set_fault_soap_envelope(msg_ctx, env, soap_envelope);
+ axis2_msg_ctx_set_soap_envelope(out_msg_ctx, env, NULL);
+ }
+ else
+ {
+ /* if it is two way and not a fault then send through engine.
+ if it is one way we do not need to do an engine send */
+ status = axis2_engine_send(engine, env, out_msg_ctx);
+ }
+ }
+ }
+ }
+ axis2_engine_free(engine, env);
+
+ /* Reset the out message context to avoid double freeing at http worker. For example if this is
+ * not done here both in and out message context will try to free the transport out stream
+ * which will result in memory corruption.
+ */
+ if(!axis2_msg_ctx_is_paused(out_msg_ctx, env) && !axis2_msg_ctx_is_keep_alive(out_msg_ctx, env))
+ {
+ axis2_core_utils_reset_out_msg_ctx(env, out_msg_ctx);
+ }
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI, "[axis2]Exit:axis2_msg_recv_receive_impl");
+ return status;
+}
+
+AXIS2_EXPORT axis2_status_t AXIS2_CALL
+axis2_msg_recv_set_invoke_business_logic(
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env,
+ AXIS2_MSG_RECV_INVOKE_BUSINESS_LOGIC func)
+{
+ msg_recv->invoke_business_logic = func;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT axis2_status_t AXIS2_CALL
+axis2_msg_recv_invoke_business_logic(
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env,
+ struct axis2_msg_ctx * in_msg_ctx,
+ struct axis2_msg_ctx * out_msg_ctx)
+{
+ return msg_recv->invoke_business_logic(msg_recv, env, in_msg_ctx, out_msg_ctx);
+}
+
+AXIS2_EXPORT axis2_status_t AXIS2_CALL
+axis2_msg_recv_set_derived(
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env,
+ void *derived)
+{
+ msg_recv->derived = derived;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT void *AXIS2_CALL
+axis2_msg_recv_get_derived(
+ const axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env)
+{
+ return msg_recv->derived;
+}
+
+AXIS2_EXPORT axis2_status_t AXIS2_CALL
+axis2_msg_recv_set_receive(
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env,
+ AXIS2_MSG_RECV_RECEIVE func)
+{
+ msg_recv->receive = func;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT axis2_status_t AXIS2_CALL
+axis2_msg_recv_receive(
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx,
+ void *callback_recv_param)
+{
+ return msg_recv->receive(msg_recv, env, msg_ctx, callback_recv_param);
+}
+
+AXIS2_EXPORT axis2_status_t AXIS2_CALL
+axis2_msg_recv_set_load_and_init_svc(
+ axis2_msg_recv_t *msg_recv,
+ const axutil_env_t *env,
+ AXIS2_MSG_RECV_LOAD_AND_INIT_SVC func)
+{
+ msg_recv->load_and_init_svc = func;
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT axis2_status_t AXIS2_CALL
+axis2_msg_recv_load_and_init_svc(
+ axis2_msg_recv_t *msg_recv,
+ const axutil_env_t *env,
+ struct axis2_svc *svc)
+{
+ if(msg_recv->load_and_init_svc)
+ {
+ return msg_recv->load_and_init_svc(msg_recv, env, svc);
+ }
+ else
+ {
+ /* message receivers without physical service (e.g : programatical service injection) */
+ return AXIS2_SUCCESS;
+ }
+}
+AXIS2_EXPORT void AXIS2_CALL
+ axis2_msg_recv_set_conf_ctx(axis2_msg_recv_t *msg_recv,
+ const axutil_env_t *env,
+ struct axis2_conf_ctx *conf_ctx)
+{
+ msg_recv->conf_ctx = conf_ctx;
+}
+
+AXIS2_EXPORT struct axis2_conf_ctx* AXIS2_CALL
+axis2_msg_recv_get_conf_ctx(
+ axis2_msg_recv_t *msg_recv,
+ const axutil_env_t *env)
+{
+ if(msg_recv)
+ return msg_recv->conf_ctx;
+ return NULL;
+}
diff --git a/src/core/receivers/raw_xml_in_out_msg_recv.c b/src/core/receivers/raw_xml_in_out_msg_recv.c
new file mode 100644
index 0000000..4bb2de8
--- /dev/null
+++ b/src/core/receivers/raw_xml_in_out_msg_recv.c
@@ -0,0 +1,442 @@
+/*
+ * 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_raw_xml_in_out_msg_recv.h>
+#include <string.h>
+#include <axiom_element.h>
+#include <axiom_soap_envelope.h>
+#include <axiom_soap_header.h>
+#include <axiom_soap_body.h>
+#include <axiom_soap_fault.h>
+#include <axiom_soap.h>
+
+static axis2_status_t AXIS2_CALL
+axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync(
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx,
+ axis2_msg_ctx_t * new_msg_ctx);
+
+AXIS2_EXTERN axis2_msg_recv_t *AXIS2_CALL
+axis2_raw_xml_in_out_msg_recv_create(
+ const axutil_env_t * env)
+{
+ axis2_msg_recv_t *msg_recv = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+
+ msg_recv = axis2_msg_recv_create(env);
+ if(!msg_recv)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+ status = axis2_msg_recv_set_scope(msg_recv, env, AXIS2_APPLICATION_SCOPE);
+ if(!status)
+ {
+ axis2_msg_recv_free(msg_recv, env);
+ return NULL;
+ }
+
+ axis2_msg_recv_set_invoke_business_logic(msg_recv, env,
+ axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync);
+
+ return msg_recv;
+}
+
+static axis2_status_t AXIS2_CALL
+axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync(
+ axis2_msg_recv_t * msg_recv,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx,
+ axis2_msg_ctx_t * new_msg_ctx)
+{
+ axis2_svc_skeleton_t *svc_obj = NULL;
+ axis2_op_ctx_t *op_ctx = NULL;
+ axis2_op_t *op_desc = NULL;
+ const axis2_char_t *style = NULL;
+ axiom_node_t *om_node = NULL;
+ axiom_element_t *om_element = NULL;
+ axis2_char_t *local_name = NULL;
+ axiom_node_t *result_node = NULL;
+ axiom_node_t *body_content_node = NULL;
+ axiom_element_t *body_content_element = NULL;
+ axiom_soap_envelope_t *default_envelope = NULL;
+ axiom_soap_body_t *out_body = NULL;
+ axiom_soap_header_t *out_header = NULL;
+ axiom_soap_fault_t *soap_fault = NULL;
+ axiom_node_t *out_node = NULL;
+ axis2_status_t status = AXIS2_SUCCESS;
+ axis2_bool_t skel_invoked = AXIS2_FALSE;
+ const axis2_char_t *soap_ns = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI;
+ int soap_version = AXIOM_SOAP12;
+ axiom_namespace_t *env_ns = NULL;
+ axiom_node_t *fault_node = NULL;
+ axiom_soap_fault_detail_t *fault_detail;
+ axis2_bool_t is_fault = AXIS2_FALSE;
+
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, new_msg_ctx, AXIS2_FAILURE);
+
+ AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
+ "[axis2]Entry:axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync");
+
+ /* get the implementation class for the Web Service */
+ svc_obj = axis2_msg_recv_make_new_svc_obj(msg_recv, env, msg_ctx);
+
+ if(!svc_obj)
+ {
+ const axis2_char_t *svc_name = NULL;
+ axis2_svc_t *svc = axis2_msg_ctx_get_svc(msg_ctx, env);
+
+ if(svc)
+ {
+ svc_name = axis2_svc_get_name(svc, env);
+ }
+ else
+ {
+ svc_name = "unknown";
+ }
+
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
+ "Impl object for service '%s' not set in message receiver. %d :: %s", svc_name,
+ env->error->error_number, AXIS2_ERROR_GET_MESSAGE(env->error));
+
+ status = AXIS2_FAILURE;
+ }
+ else
+ {
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ op_desc = axis2_op_ctx_get_op(op_ctx, env);
+
+ style = axis2_op_get_style(op_desc, env);
+ if(0 == axutil_strcmp(AXIS2_STYLE_DOC, style))
+ {
+ axiom_soap_envelope_t *envelope = NULL;
+ axiom_soap_body_t *body = NULL;
+
+ envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
+ body = axiom_soap_envelope_get_body(envelope, env);
+ om_node = axiom_soap_body_get_base_node(body, env);
+ om_element = axiom_node_get_data_element(om_node, env);
+ om_node = axiom_node_get_first_element(om_node, env);
+ }
+ else if(0 == axutil_strcmp(AXIS2_STYLE_RPC, style))
+ {
+ axiom_soap_envelope_t *envelope = NULL;
+ axiom_soap_body_t *body = NULL;
+ axiom_node_t *op_node = NULL;
+ axiom_element_t *op_element = NULL;
+
+ envelope = axis2_msg_ctx_get_soap_envelope(msg_ctx, env);
+ body = axiom_soap_envelope_get_body(envelope, env);
+ op_node = axiom_soap_body_get_base_node(body, env);
+ op_element = axiom_node_get_data_element(op_node, env);
+ if(op_element)
+ {
+ local_name = axiom_element_get_localname(op_element, env);
+ if(local_name)
+ {
+ axutil_array_list_t *function_arr = NULL;
+ int i = 0;
+ int size = 0;
+ axis2_bool_t matches = AXIS2_FALSE;
+
+ function_arr = svc_obj->func_array;
+ if(function_arr)
+ {
+ size = axutil_array_list_size(function_arr, env);
+ }
+
+ for(i = 0; i < size; i++)
+ {
+ axis2_char_t *function_name = NULL;
+
+ function_name = (axis2_char_t *)axutil_array_list_get(function_arr, env, i);
+ if(!axutil_strcmp(function_name, local_name))
+ {
+ matches = AXIS2_TRUE;
+
+ }
+ }
+
+ if(matches)
+ {
+ om_node = axiom_node_get_first_child(op_node, env);
+ om_element = axiom_node_get_data_element(om_node, env);
+ }
+ else
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_OM_ELEMENT_MISMATCH, AXIS2_FAILURE);
+ status = AXIS2_FAILURE;
+ }
+ }
+ else
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_OM_ELEMENT_INVALID_STATE, AXIS2_FAILURE);
+ status = AXIS2_FAILURE;
+ }
+ }
+ else
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_RPC_NEED_MATCHING_CHILD, AXIS2_FAILURE);
+ status = AXIS2_FAILURE;
+ }
+ }
+ else
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_UNKNOWN_STYLE, AXIS2_FAILURE);
+ status = AXIS2_FAILURE;
+ }
+
+ if(status == AXIS2_SUCCESS)
+ {
+ skel_invoked = AXIS2_TRUE;
+ result_node = AXIS2_SVC_SKELETON_INVOKE(svc_obj, env, om_node, new_msg_ctx);
+ }
+
+ if(result_node)
+ {
+ if(0 == axutil_strcmp(style, AXIS2_STYLE_RPC))
+ {
+ axiom_namespace_t *ns = NULL;
+ axis2_char_t *res_name = NULL;
+
+ res_name = axutil_stracat(env, local_name, "Response");
+ ns = axiom_namespace_create(env, "http://soapenc/", "res");
+ if(!ns)
+ {
+ status = AXIS2_FAILURE;
+ }
+ else
+ {
+ body_content_element = axiom_element_create(env, NULL, res_name, ns,
+ &body_content_node);
+ axiom_node_add_child(body_content_node, env, result_node);
+ }
+ }
+ else
+ {
+ body_content_node = result_node;
+ }
+ }
+ else
+ {
+ axis2_char_t *mep = (axis2_char_t *)axis2_op_get_msg_exchange_pattern(op_desc, env);
+ if(axutil_strcmp(mep, AXIS2_MEP_URI_IN_ONLY) && axutil_strcmp(mep,
+ AXIS2_MEP_URI_ROBUST_IN_ONLY))
+ {
+ status = AXIS2_ERROR_GET_STATUS_CODE(env->error);
+ if(status == AXIS2_SUCCESS)
+ {
+ axis2_msg_ctx_set_no_content(new_msg_ctx, env, AXIS2_TRUE);
+ }
+ else
+ {
+ axis2_msg_ctx_set_status_code(msg_ctx, env, axis2_msg_ctx_get_status_code(
+ new_msg_ctx, env));
+ }
+ /* The new_msg_ctx is passed to the service. The status code must
+ * be taken from here and set to the old message context which is
+ * used by the worker when the request processing fails.
+ */
+ if(svc_obj->ops->on_fault)
+ {
+ fault_node = AXIS2_SVC_SKELETON_ON_FAULT(svc_obj, env, om_node);
+ }
+ is_fault = AXIS2_TRUE;
+ }
+ else
+ {
+ /* If we have a in only message result node is NULL. We create fault only if
+ * an error is set
+ */
+ status = AXIS2_ERROR_GET_STATUS_CODE(env->error);
+ if(status == AXIS2_SUCCESS)
+ {
+ axis2_msg_ctx_set_no_content(new_msg_ctx, env, AXIS2_TRUE);
+ }
+ else
+ {
+ axis2_msg_ctx_set_status_code(msg_ctx, env, axis2_msg_ctx_get_status_code(
+ new_msg_ctx, env));
+ if(!axutil_strcmp(mep, AXIS2_MEP_URI_ROBUST_IN_ONLY))
+ {
+ /* The new_msg_ctx is passed to the service. The status code must
+ * be taken from here and set to the old message context which is
+ * used by the worker when the request processing fails.
+ */
+ if(svc_obj->ops->on_fault)
+ {
+ fault_node = AXIS2_SVC_SKELETON_ON_FAULT(svc_obj, env, om_node);
+ }
+ is_fault = AXIS2_TRUE;
+ }
+ }
+ }
+ }
+ }
+
+ if(msg_ctx && axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
+ {
+ soap_ns = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; /* default is 1.2 */
+ soap_version = AXIOM_SOAP11;
+ }
+
+ if(axis2_msg_ctx_get_soap_envelope(new_msg_ctx, env))
+ {
+ /* service implementation has set the envelope,
+ useful when setting a SOAP fault.
+ No need to further process */
+ return AXIS2_SUCCESS;
+ }
+
+ /* create the soap envelope here */
+ env_ns = axiom_namespace_create(env, soap_ns, "soapenv");
+ if(!env_ns)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ default_envelope = axiom_soap_envelope_create(env, env_ns);
+
+ if(!default_envelope)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ out_header = axiom_soap_header_create_with_parent(env, default_envelope);
+ if(!out_header)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ out_body = axiom_soap_body_create_with_parent(env, default_envelope);
+ if(!out_body)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ out_node = axiom_soap_body_get_base_node(out_body, env);
+ if(!out_node)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ if(status != AXIS2_SUCCESS || is_fault)
+ {
+ /* something went wrong. set a SOAP Fault */
+ const axis2_char_t *fault_value_str = "soapenv:Sender";
+ const axis2_char_t *fault_reason_str = NULL;
+ const axis2_char_t *err_msg = NULL;
+
+ if(!skel_invoked)
+ {
+ if(axis2_msg_ctx_get_is_soap_11(msg_ctx, env))
+ {
+fault_value_str =
+ AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
+ AXIOM_SOAP11_FAULT_CODE_RECEIVER;
+ }
+ else
+ {
+ fault_value_str =
+ AXIOM_SOAP_DEFAULT_NAMESPACE_PREFIX ":"
+ AXIOM_SOAP12_SOAP_FAULT_VALUE_RECEIVER;
+ }
+ }
+
+ err_msg = AXIS2_ERROR_GET_MESSAGE(env->error);
+ if (err_msg && axutil_strcmp(err_msg, ""))
+ {
+ if(!axutil_strcmp(err_msg, "No Error"))
+ {
+ fault_reason_str = "An error has occurred, but could not determine exact details";
+ }
+ else
+ {
+ fault_reason_str = err_msg;
+ }
+ }
+ else
+ {
+ fault_reason_str = "An error has occurred, but could not determine exact details";
+ }
+
+ soap_fault = axiom_soap_fault_create_default_fault(env, out_body, fault_value_str,
+ fault_reason_str, soap_version);
+
+ if (fault_node)
+ {
+ axiom_node_t *fault_detail_node = NULL;
+
+ fault_detail = axiom_soap_fault_detail_create_with_parent(env, soap_fault);
+ fault_detail_node = axiom_soap_fault_detail_get_base_node(fault_detail, env);
+ AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "fault_detail:%s", axiom_node_to_string(
+ fault_detail_node, env));
+
+ axiom_soap_fault_detail_add_detail_entry(fault_detail, env, fault_node);
+ }
+}
+
+if (body_content_node)
+{
+ axiom_node_add_child(out_node, env, body_content_node);
+ status = axis2_msg_ctx_set_soap_envelope(new_msg_ctx, env, default_envelope);
+}
+else if (soap_fault)
+{
+ axis2_msg_ctx_set_soap_envelope(new_msg_ctx, env, default_envelope);
+ status = AXIS2_SUCCESS;
+}
+else
+{
+ /* we should free the memory as the envelope is not used, one way case */
+ axiom_soap_envelope_free(default_envelope, env);
+ default_envelope = NULL;
+}
+
+AXIS2_LOG_TRACE(env->log, AXIS2_LOG_SI,
+ "[axis2]Exit:axis2_raw_xml_in_out_msg_recv_invoke_business_logic_sync");
+
+return status;
+}
+
+AXIS2_EXPORT int
+axis2_get_instance(
+ struct axis2_msg_recv **inst,
+ const axutil_env_t * env)
+{
+ *inst = axis2_raw_xml_in_out_msg_recv_create(env);
+ if(!(*inst))
+ {
+ return AXIS2_FAILURE;
+ }
+
+ return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT int
+axis2_remove_instance(
+ struct axis2_msg_recv *inst,
+ const axutil_env_t * env)
+{
+ if(inst)
+ {
+ axis2_msg_recv_free(inst, env);
+ }
+ return AXIS2_SUCCESS;
+}
diff --git a/src/core/receivers/svr_callback.c b/src/core/receivers/svr_callback.c
new file mode 100644
index 0000000..2fe68b1
--- /dev/null
+++ b/src/core/receivers/svr_callback.c
@@ -0,0 +1,112 @@
+/*
+ * 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_svr_callback.h>
+#include <axis2_engine.h>
+
+struct axis2_svr_callback
+{
+ axis2_char_t *scope;
+};
+
+AXIS2_EXPORT axis2_svr_callback_t *AXIS2_CALL
+axis2_svr_callback_create(
+ const axutil_env_t * env)
+{
+ axis2_svr_callback_t *svr_callback = NULL;
+
+ AXIS2_ENV_CHECK(env, NULL);
+
+ svr_callback = (axis2_svr_callback_t *)AXIS2_MALLOC(env->allocator,
+ sizeof(axis2_svr_callback_t));
+
+ if(!svr_callback)
+ {
+ AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE);
+ return NULL;
+ }
+
+ return svr_callback;
+}
+
+AXIS2_EXPORT void AXIS2_CALL
+axis2_svr_callback_free(
+ axis2_svr_callback_t * svr_callback,
+ const axutil_env_t * env)
+{
+ AXIS2_ENV_CHECK(env, void);
+
+ if(svr_callback)
+ {
+ AXIS2_FREE(env->allocator, svr_callback);
+ }
+
+ return;
+}
+
+AXIS2_EXPORT axis2_status_t AXIS2_CALL
+axis2_svr_callback_handle_result(
+ axis2_svr_callback_t * svr_callback,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ axis2_engine_t *engine = NULL;
+ axis2_conf_ctx_t *conf_ctx = NULL;
+ axis2_svc_ctx_t *svc_ctx = NULL;
+ axis2_op_ctx_t *op_ctx = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ svc_ctx = axis2_op_ctx_get_parent(op_ctx, env);
+ conf_ctx = axis2_svc_ctx_get_conf_ctx(svc_ctx, env);
+ engine = axis2_engine_create(env, conf_ctx);
+ if(!engine)
+ {
+ return AXIS2_FAILURE;
+ }
+ return axis2_engine_send(engine, env, msg_ctx);
+}
+
+AXIS2_EXPORT axis2_status_t AXIS2_CALL
+axis2_svr_callback_handle_fault(
+ axis2_svr_callback_t * svr_callback,
+ const axutil_env_t * env,
+ axis2_msg_ctx_t * msg_ctx)
+{
+ axis2_engine_t *engine = NULL;
+ axis2_conf_ctx_t *conf_ctx = NULL;
+ axis2_svc_ctx_t *svc_ctx = NULL;
+ axis2_op_ctx_t *op_ctx = NULL;
+ axis2_msg_ctx_t *fault_ctx = NULL;
+
+ AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
+ AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
+
+ op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+ svc_ctx = axis2_op_ctx_get_parent(op_ctx, env);
+ conf_ctx = axis2_svc_ctx_get_conf_ctx(svc_ctx, env);
+ engine = axis2_engine_create(env, conf_ctx);
+ if(!engine)
+ {
+ return AXIS2_FAILURE;
+ }
+
+ fault_ctx = axis2_engine_create_fault_msg_ctx(engine, env, msg_ctx, NULL, NULL);
+ return axis2_engine_send_fault(engine, env, fault_ctx);
+}