From 0425aadc78680e53000fd0108b540d6eca048516 Mon Sep 17 00:00:00 2001 From: gmcdonald Date: Sat, 13 Feb 2010 01:32:03 +0000 Subject: 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 --- src/core/transport/amqp/receiver/Makefile.am | 25 ++ .../transport/amqp/receiver/axis2_amqp_receiver.c | 275 +++++++++++++++++ .../transport/amqp/receiver/axis2_amqp_receiver.h | 82 +++++ .../amqp/receiver/qpid_receiver/Makefile.am | 29 ++ .../receiver/qpid_receiver/axis2_qpid_receiver.cpp | 167 +++++++++++ .../receiver/qpid_receiver/axis2_qpid_receiver.h | 39 +++ .../axis2_qpid_receiver_interface.cpp | 102 +++++++ .../qpid_receiver/axis2_qpid_receiver_interface.h | 58 ++++ .../qpid_receiver/axis2_qpid_receiver_listener.cpp | 123 ++++++++ .../qpid_receiver/axis2_qpid_receiver_listener.h | 43 +++ .../qpid_receiver/request_processor/Makefile.am | 20 ++ .../axis2_amqp_request_processor.c | 334 +++++++++++++++++++++ .../axis2_amqp_request_processor.h | 55 ++++ 13 files changed, 1352 insertions(+) create mode 100644 src/core/transport/amqp/receiver/Makefile.am create mode 100644 src/core/transport/amqp/receiver/axis2_amqp_receiver.c create mode 100644 src/core/transport/amqp/receiver/axis2_amqp_receiver.h create mode 100644 src/core/transport/amqp/receiver/qpid_receiver/Makefile.am create mode 100644 src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver.cpp create mode 100644 src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver.h create mode 100644 src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_interface.cpp create mode 100644 src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_interface.h create mode 100644 src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_listener.cpp create mode 100644 src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_listener.h create mode 100644 src/core/transport/amqp/receiver/qpid_receiver/request_processor/Makefile.am create mode 100644 src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.c create mode 100644 src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.h (limited to 'src/core/transport/amqp/receiver') diff --git a/src/core/transport/amqp/receiver/Makefile.am b/src/core/transport/amqp/receiver/Makefile.am new file mode 100644 index 0000000..4e16b0f --- /dev/null +++ b/src/core/transport/amqp/receiver/Makefile.am @@ -0,0 +1,25 @@ +SUBDIRS = qpid_receiver + +lib_LTLIBRARIES = libaxis2_amqp_receiver.la + +libaxis2_amqp_receiver_la_SOURCES = axis2_amqp_receiver.c + +libaxis2_amqp_receiver_la_LIBADD = $(top_builddir)/util/src/libaxutil.la \ + $(top_builddir)/src/core/transport/amqp/util/libaxis2_amqp_util.la \ + $(top_builddir)/src/core/transport/amqp/receiver/qpid_receiver/libaxis2_qpid_receiver.la + +libaxis2_amqp_receiver_la_LDFLAGS = -version-info $(VERSION_NO) + +INCLUDES = -I$(top_builddir)/include \ + -I$(top_builddir)/src/core/transport/amqp/util \ + -I$(top_builddir)/src/core/transport/amqp/receiver \ + -I$(top_builddir)/src/core/transport/amqp/sender/qpid_sender \ + -I$(top_builddir)/src/core/transport/amqp/receiver/qpid_receiver \ + -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 + diff --git a/src/core/transport/amqp/receiver/axis2_amqp_receiver.c b/src/core/transport/amqp/receiver/axis2_amqp_receiver.c new file mode 100644 index 0000000..5ff69af --- /dev/null +++ b/src/core/transport/amqp/receiver/axis2_amqp_receiver.c @@ -0,0 +1,275 @@ +/* + * 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 +#include +#include + +static const axis2_transport_receiver_ops_t amqp_receiver_ops = +{ + axis2_amqp_receiver_init, + axis2_amqp_receiver_start, + axis2_amqp_receiver_get_reply_to_epr, + axis2_amqp_receiver_get_conf_ctx, + axis2_amqp_receiver_is_running, + axis2_amqp_receiver_stop, + axis2_amqp_receiver_free +}; + +AXIS2_EXTERN axis2_transport_receiver_t* AXIS2_CALL +axis2_amqp_receiver_create( + const axutil_env_t* env, + const axis2_char_t* repo, + const axis2_char_t* qpid_broker_ip, + int qpid_broker_port) +{ + AXIS2_ENV_CHECK(env, NULL); + + axis2_amqp_receiver_resource_pack_t* receiver_resource_pack = NULL; + + receiver_resource_pack = (axis2_amqp_receiver_resource_pack_t*)AXIS2_MALLOC(env->allocator, + sizeof(axis2_amqp_receiver_resource_pack_t)); + + if(!receiver_resource_pack) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + receiver_resource_pack->receiver.ops = &amqp_receiver_ops; + receiver_resource_pack->qpid_receiver = NULL; + receiver_resource_pack->conf_ctx = NULL; + receiver_resource_pack->conf_ctx_private = NULL; + + if(repo) + { + /** + * 1. We first create a private conf ctx which is owned by this server + * we only free this private conf context. We should never free the + * receiver_impl->conf_ctx because it may be owned by any other object which + * may lead to double free. + * + * 2. The Qpid broker IP and port are set in conf_ctx at two different places. + * If the repo is specified, they are set here. Otherwise, they are set + * in axis2_amqp_receiver_init method. + */ + axutil_property_t* property = NULL; + const axis2_char_t* broker_ip = NULL; + int* broker_port = (int*)AXIS2_MALLOC(env->allocator, sizeof(int)); + *broker_port = AXIS2_QPID_NULL_CONF_INT; + + receiver_resource_pack->conf_ctx_private = axis2_build_conf_ctx(env, repo); + if(!receiver_resource_pack->conf_ctx_private) + { + axis2_amqp_receiver_free((axis2_transport_receiver_t *)receiver_resource_pack, env); + return NULL; + } + + /* Set broker IP */ + broker_ip = qpid_broker_ip ? qpid_broker_ip : AXIS2_QPID_DEFAULT_BROKER_IP; + property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0, + (void*)broker_ip); + axis2_conf_ctx_set_property(receiver_resource_pack->conf_ctx_private, env, + AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP, property); + + /* Set broker port */ + *broker_port = (qpid_broker_port != AXIS2_QPID_NULL_CONF_INT) ? qpid_broker_port + : AXIS2_QPID_DEFAULT_BROKER_PORT; + property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0, + (void*)broker_port); + axis2_conf_ctx_set_property(receiver_resource_pack->conf_ctx_private, env, + AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT, property); + + receiver_resource_pack->conf_ctx = receiver_resource_pack->conf_ctx_private; + } + + return &(receiver_resource_pack->receiver); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_amqp_receiver_init( + axis2_transport_receiver_t* receiver, + const axutil_env_t* env, + axis2_conf_ctx_t* conf_ctx, + axis2_transport_in_desc_t* in_desc) +{ + axis2_amqp_receiver_resource_pack_t* receiver_resource_pack = NULL; + axutil_property_t* property = NULL; + const axis2_char_t* broker_ip = NULL; + int* broker_port = (int*)AXIS2_MALLOC(env->allocator, sizeof(int)); + *broker_port = AXIS2_QPID_NULL_CONF_INT; + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + receiver_resource_pack = AXIS2_AMQP_RECEIVER_TO_RESOURCE_PACK(receiver); + receiver_resource_pack->conf_ctx = conf_ctx; + + /* Set broker IP */ + broker_ip = axis2_amqp_util_get_in_desc_conf_value_string(in_desc, env, + AXIS2_AMQP_CONF_QPID_BROKER_IP); + if(!broker_ip) + { + broker_ip = AXIS2_QPID_DEFAULT_BROKER_IP; + } + property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0, + (void*)broker_ip); + axis2_conf_ctx_set_property(receiver_resource_pack->conf_ctx, env, + AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_IP, property); + + /* Set broker port */ + *broker_port = axis2_amqp_util_get_in_desc_conf_value_int(in_desc, env, + AXIS2_AMQP_CONF_QPID_BROKER_PORT); + if(*broker_port == AXIS2_QPID_NULL_CONF_INT) + { + *broker_port = AXIS2_QPID_DEFAULT_BROKER_PORT; + } + property = axutil_property_create_with_args(env, AXIS2_SCOPE_APPLICATION, 0, 0, + (void*)broker_port); + axis2_conf_ctx_set_property(receiver_resource_pack->conf_ctx, env, + AXIS2_AMQP_CONF_CTX_PROPERTY_BROKER_PORT, property); + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_amqp_receiver_start( + axis2_transport_receiver_t* receiver, + const axutil_env_t* env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + axis2_status_t status = AXIS2_FAILURE; + + axis2_amqp_receiver_resource_pack_t* amqp_receiver_resource_pack = NULL; + axis2_qpid_receiver_resource_pack_t* qpid_receiver_resource_pack = NULL; + + amqp_receiver_resource_pack = AXIS2_AMQP_RECEIVER_TO_RESOURCE_PACK(receiver); + + /* Create Qpid Receiver */ + qpid_receiver_resource_pack = axis2_qpid_receiver_create(env, + amqp_receiver_resource_pack->conf_ctx); + + if(qpid_receiver_resource_pack) + { + amqp_receiver_resource_pack->qpid_receiver = qpid_receiver_resource_pack; + + status = axis2_qpid_receiver_start(qpid_receiver_resource_pack, env); + } + + return status; +} + +AXIS2_EXTERN axis2_endpoint_ref_t* AXIS2_CALL +axis2_amqp_receiver_get_reply_to_epr( + axis2_transport_receiver_t* receiver, + const axutil_env_t* env, + const axis2_char_t* svc_name) +{ + return NULL; +} + +AXIS2_EXTERN axis2_conf_ctx_t* AXIS2_CALL +axis2_amqp_receiver_get_conf_ctx( + axis2_transport_receiver_t* receiver, + const axutil_env_t* env) +{ + AXIS2_ENV_CHECK(env, NULL); + + return AXIS2_AMQP_RECEIVER_TO_RESOURCE_PACK(receiver)->conf_ctx; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axis2_amqp_receiver_is_running( + axis2_transport_receiver_t* receiver, + const axutil_env_t* env) +{ + return AXIS2_TRUE; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_amqp_receiver_stop( + axis2_transport_receiver_t* receiver, + const axutil_env_t* env) +{ + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN void AXIS2_CALL +axis2_amqp_receiver_free( + axis2_transport_receiver_t* receiver, + const axutil_env_t* env) +{ + AXIS2_ENV_CHECK(env, void); + + axis2_amqp_receiver_resource_pack_t* receiver_resource_pack = NULL; + receiver_resource_pack = AXIS2_AMQP_RECEIVER_TO_RESOURCE_PACK(receiver); + + if(receiver_resource_pack->qpid_receiver) + { + axis2_qpid_receiver_free(receiver_resource_pack->qpid_receiver, env); + receiver_resource_pack->qpid_receiver = NULL; + } + + if(receiver_resource_pack->conf_ctx_private) + { + axis2_conf_ctx_free(receiver_resource_pack->conf_ctx_private, env); + receiver_resource_pack->conf_ctx_private = NULL; + } + + receiver_resource_pack->conf_ctx = NULL; /* Do not free this. It may be owned by some other object */ + + AXIS2_FREE(env->allocator, receiver_resource_pack); +} + +/* Library Exports */ + +AXIS2_EXPORT int +#ifndef AXIS2_STATIC_DEPLOY +axis2_get_instance( +#else + axis2_amqp_receiver_get_instance( +#endif + struct axis2_transport_receiver** inst, + const axutil_env_t* env) +{ + int status = AXIS2_SUCCESS; + + *inst = axis2_amqp_receiver_create(env, NULL, NULL, AXIS2_QPID_NULL_CONF_INT); + if(!(*inst)) + { + status = AXIS2_FAILURE; + } + + return status; +} + +AXIS2_EXPORT int +#ifndef AXIS2_STATIC_DEPLOY +axis2_remove_instance( +#else + axis2_amqp_receiver_remove_instance( +#endif + axis2_transport_receiver_t* inst, + const axutil_env_t* env) +{ + if(inst) + { + axis2_transport_receiver_free(inst, env); + } + + return AXIS2_SUCCESS; +} diff --git a/src/core/transport/amqp/receiver/axis2_amqp_receiver.h b/src/core/transport/amqp/receiver/axis2_amqp_receiver.h new file mode 100644 index 0000000..209e2bb --- /dev/null +++ b/src/core/transport/amqp/receiver/axis2_amqp_receiver.h @@ -0,0 +1,82 @@ +/* +* 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_AMQP_RECEIVER_H +#define AXIS2_AMQP_RECEIVER_H + +#include +#include +#include + +typedef struct axis2_amqp_receiver_resource_pack +{ + axis2_transport_receiver_t receiver; + axis2_qpid_receiver_resource_pack_t* qpid_receiver; + axis2_conf_ctx_t* conf_ctx; + axis2_conf_ctx_t* conf_ctx_private; +} +axis2_amqp_receiver_resource_pack_t; + +#define AXIS2_AMQP_RECEIVER_TO_RESOURCE_PACK(amqp_receiver) \ + ((axis2_amqp_receiver_resource_pack_t*)(amqp_receiver)) + +AXIS2_EXTERN axis2_transport_receiver_t* AXIS2_CALL +axis2_amqp_receiver_create( + const axutil_env_t* env, + const axis2_char_t* repo, + const axis2_char_t* qpid_broker_ip, + int qpid_broker_port); + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_amqp_receiver_init( + axis2_transport_receiver_t* receiver, + const axutil_env_t* env, + axis2_conf_ctx_t* conf_ctx, + axis2_transport_in_desc_t* in_desc); + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_amqp_receiver_start( + axis2_transport_receiver_t* receiver, + const axutil_env_t* env); + +AXIS2_EXTERN axis2_endpoint_ref_t* AXIS2_CALL +axis2_amqp_receiver_get_reply_to_epr( + axis2_transport_receiver_t* receiver, + const axutil_env_t* env, + const axis2_char_t* svc_name); + +AXIS2_EXTERN axis2_conf_ctx_t* AXIS2_CALL +axis2_amqp_receiver_get_conf_ctx( + axis2_transport_receiver_t* receiver, + const axutil_env_t* env); + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axis2_amqp_receiver_is_running( + axis2_transport_receiver_t* receiver, + const axutil_env_t* env); + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_amqp_receiver_stop( + axis2_transport_receiver_t* receiver, + const axutil_env_t* env); + +AXIS2_EXTERN void AXIS2_CALL +axis2_amqp_receiver_free( + axis2_transport_receiver_t* receiver, + const axutil_env_t* env); + +#endif diff --git a/src/core/transport/amqp/receiver/qpid_receiver/Makefile.am b/src/core/transport/amqp/receiver/qpid_receiver/Makefile.am new file mode 100644 index 0000000..3ecdf34 --- /dev/null +++ b/src/core/transport/amqp/receiver/qpid_receiver/Makefile.am @@ -0,0 +1,29 @@ +SUBDIRS = request_processor + +lib_LTLIBRARIES = libaxis2_qpid_receiver.la + +libaxis2_qpid_receiver_la_SOURCES = axis2_qpid_receiver.cpp \ + axis2_qpid_receiver_interface.cpp \ + axis2_qpid_receiver_listener.cpp + +libaxis2_qpid_receiver_la_LIBADD = $(top_builddir)/util/src/libaxutil.la \ + $(QPID_HOME)/lib/libqpidclient.la \ + $(top_builddir)/src/core/transport/amqp/util/libaxis2_amqp_util.la \ + $(top_builddir)/src/core/transport/amqp/receiver/qpid_receiver/request_processor/libaxis2_amqp_request_processor.la + +libaxis2_qpid_receiver_la_LDFLAGS = g++ -version-info $(VERSION_NO) + +INCLUDES = -I$(top_builddir)/include \ + -I$(top_builddir)/src/core/transport/amqp/receiver/qpid_receiver \ + -I$(top_builddir)/src/core/transport/amqp/receiver/qpid_receiver/request_processor \ + -I$(top_builddir)/src/core/transport/amqp/util \ + -I$(top_builddir)/src/core/transport/amqp/sender/qpid_sender \ + -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 \ + -I$(QPID_HOME)/include + diff --git a/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver.cpp b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver.cpp new file mode 100644 index 0000000..140ab0e --- /dev/null +++ b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver.cpp @@ -0,0 +1,167 @@ +/* + * 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 + * + * tcp://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 +#include +#include +#include +#include +#include +#include +#include +#include + +Axis2QpidReceiver::Axis2QpidReceiver( + const axutil_env_t* env, + axis2_conf_ctx_t* conf_ctx) +{ + this->env = env; + this->conf_ctx = conf_ctx; +} + +Axis2QpidReceiver::~Axis2QpidReceiver( + void) +{ +} + +bool +Axis2QpidReceiver::start( + void) +{ + if(!conf_ctx) + return false; + + Connection connection; + axis2_bool_t serverSide = AXIS2_TRUE; + + serverSide = axis2_amqp_util_conf_ctx_get_server_side(conf_ctx, env); + + while(true) + { + try + { + std::list queueNameList; + string qpidBrokerIP = axis2_amqp_util_conf_ctx_get_qpid_broker_ip(conf_ctx, env); + int qpidBrokerPort = axis2_amqp_util_conf_ctx_get_qpid_broker_port(conf_ctx, env); + + /* Check if Client Side and Resolve Dynamic Queue Name */ + if(serverSide == AXIS2_TRUE) /* Server side */ + { + std::cout << "Connecting to Qpid Broker on " << qpidBrokerIP << ":" + << qpidBrokerPort << " ... "; + } + + /* Create Connection to Qpid Broker */ + connection.open(qpidBrokerIP, qpidBrokerPort); + + if(serverSide == AXIS2_TRUE) /* Server side */ + { + /* Create queue for each service. Queue name is equal to service name */ + axis2_conf_t* conf = axis2_conf_ctx_get_conf(conf_ctx, env); + if(!conf) + return false; + + axutil_hash_t* serviceMap = axis2_conf_get_all_svcs(conf, env); + if(!serviceMap) + return false; + + axutil_hash_index_t* serviceHI = NULL; + void* serviceValue = NULL; + + for(serviceHI = axutil_hash_first(serviceMap, env); serviceHI; serviceHI + = axutil_hash_next(env, serviceHI)) + { + axutil_hash_this(serviceHI, NULL, NULL, &serviceValue); + + axis2_svc_t* service = (axis2_svc_t*)serviceValue; + if(!service) + return false; + + axis2_char_t* serviceName = axutil_qname_get_localpart(axis2_svc_get_qname( + service, env), env); + if(!serviceName) + return false; + + queueNameList.push_back(serviceName); + } + + std::cout << "CONNECTED" << std::endl; + } + else /* Client side separate listener in dual-channel case */ + { + string queueName = axis2_amqp_util_conf_ctx_get_dual_channel_queue_name(conf_ctx, + env); + + queueNameList.push_back(queueName); + } + + /* Create new session */ + Session session = connection.newSession(); + + /* Create Subscription manager */ + SubscriptionManager subscriptionManager(session); + + Axis2QpidReceiverListener qpidReceiverListener(env, conf_ctx); + + /* Subscribe to queues */ + while(!queueNameList.empty()) + { + string queueName = queueNameList.front(); + + session.queueDeclare(arg::queue = queueName, arg::autoDelete = true); + session.exchangeBind(arg::exchange = AXIS2_AMQP_EXCHANGE_DIRECT, arg::queue + = queueName, arg::bindingKey = queueName); + + subscriptionManager.subscribe(qpidReceiverListener, queueName); + + queueNameList.pop_front(); + } + + /* Listen and Wait */ + if(serverSide == AXIS2_TRUE) /* Server side */ + { + std::cout << "Started Axis2 AMQP Server ..." << std::endl; + } + + subscriptionManager.run(); + + return true; + } + catch(const std::exception& e) + { + connection.close(); + + if(serverSide == AXIS2_TRUE) /* Server side */ + { + std::cout << "FAILED" << std::endl; + } + + sleep(5); + } + } + + connection.close(); + + return false; +} + +bool +Axis2QpidReceiver::shutdown( + void) +{ + return true; +} diff --git a/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver.h b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver.h new file mode 100644 index 0000000..66108d5 --- /dev/null +++ b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver.h @@ -0,0 +1,39 @@ +/* + * 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 + * + * tcp://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_QPID_RECEIVER_H +#define AXIS2_QPID_RECEIVER_H + +#include +#include + +class Axis2QpidReceiver +{ + public: + Axis2QpidReceiver(const axutil_env_t* env, + axis2_conf_ctx_t* conf_ctx); + ~Axis2QpidReceiver(void); + + bool start(void); + bool shutdown(void); + + private: + const axutil_env_t* env; + axis2_conf_ctx_t* conf_ctx; +}; + +#endif diff --git a/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_interface.cpp b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_interface.cpp new file mode 100644 index 0000000..79faa86 --- /dev/null +++ b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_interface.cpp @@ -0,0 +1,102 @@ +/* +* 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 +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + +AXIS2_EXTERN axis2_qpid_receiver_resource_pack_t* AXIS2_CALL +axis2_qpid_receiver_create( + const axutil_env_t* env, + axis2_conf_ctx_t* conf_ctx) +{ + AXIS2_ENV_CHECK(env, NULL); + + axis2_qpid_receiver_resource_pack_t* resource_pack = NULL; + + resource_pack = (axis2_qpid_receiver_resource_pack_t*)AXIS2_MALLOC + (env->allocator, sizeof(axis2_qpid_receiver_resource_pack_t)); + + if (!resource_pack) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + /* Create Qpid Receiver */ + Axis2QpidReceiver* qpid_receiver = new Axis2QpidReceiver(env, conf_ctx); + + resource_pack->qpid_receiver = qpid_receiver; + + return resource_pack; +} + + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +axis2_qpid_receiver_start( + axis2_qpid_receiver_resource_pack_t* receiver_resource_pack, + const axutil_env_t* env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + axis2_status_t status = AXIS2_FAILURE; + + /* Start Qpid Receiver */ + Axis2QpidReceiver* qpid_receiver = (Axis2QpidReceiver*)receiver_resource_pack->qpid_receiver; + + if ((qpid_receiver) && (qpid_receiver->start())) + { + status = AXIS2_SUCCESS; + } + + return status; +} + + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +axis2_qpid_receiver_is_running( + axis2_qpid_receiver_resource_pack_t* receiver_resource_pack, + const axutil_env_t* env) +{ + return AXIS2_TRUE; +} + + +AXIS2_EXTERN void AXIS2_CALL +axis2_qpid_receiver_free( + axis2_qpid_receiver_resource_pack_t* receiver_resource_pack, + const axutil_env_t* env) +{ + AXIS2_ENV_CHECK(env, void); + + if (receiver_resource_pack) + { + Axis2QpidReceiver* qpid_receiver = (Axis2QpidReceiver*)receiver_resource_pack->qpid_receiver; + if (qpid_receiver) + delete qpid_receiver; + + AXIS2_FREE(env->allocator, receiver_resource_pack); + } +} + +#ifdef __cplusplus +} +#endif diff --git a/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_interface.h b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_interface.h new file mode 100644 index 0000000..d141dfc --- /dev/null +++ b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_interface.h @@ -0,0 +1,58 @@ +/* +* 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_QPID_RECEIVER_INTERFACE_H +#define AXIS2_QPID_RECEIVER_INTERFACE_H + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axis2_qpid_receiver_resource_pack + { + void* qpid_receiver; + }axis2_qpid_receiver_resource_pack_t; + + AXIS2_EXTERN axis2_qpid_receiver_resource_pack_t* AXIS2_CALL + axis2_qpid_receiver_create( + const axutil_env_t* env, + axis2_conf_ctx_t* conf_ctx); + + AXIS2_EXTERN axis2_status_t AXIS2_CALL + axis2_qpid_receiver_start( + axis2_qpid_receiver_resource_pack_t* receiver_resource_pack, + const axutil_env_t* env); + + AXIS2_EXTERN axis2_bool_t AXIS2_CALL + axis2_qpid_receiver_is_running( + axis2_qpid_receiver_resource_pack_t* receiver_resource_pack, + const axutil_env_t* env); + + AXIS2_EXTERN void AXIS2_CALL + axis2_qpid_receiver_free( + axis2_qpid_receiver_resource_pack_t* receiver_resource_pack, + const axutil_env_t* env); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_listener.cpp b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_listener.cpp new file mode 100644 index 0000000..63717ca --- /dev/null +++ b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_listener.cpp @@ -0,0 +1,123 @@ +/* + * 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 + * + * tcp://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 +#include +#include +#include +#include +#include + +Axis2QpidReceiverListener::Axis2QpidReceiverListener( + const axutil_env_t* env, + axis2_conf_ctx_t* conf_ctx) +{ + this->env = env; + this->conf_ctx = conf_ctx; +} + +Axis2QpidReceiverListener::~Axis2QpidReceiverListener( + void) +{ +} + +void +Axis2QpidReceiverListener::received( + Message& message) +{ + AXIS2_ENV_CHECK(env, void); + + axis2_amqp_request_processor_resource_pack_t* request_data = NULL; +#ifdef AXIS2_SVR_MULTI_THREADED + axutil_thread_t* worker_thread = NULL; +#endif + + request_data = (axis2_amqp_request_processor_resource_pack_t*)AXIS2_MALLOC(env->allocator, + sizeof(axis2_amqp_request_processor_resource_pack_t)); + + if(!request_data) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Memory Allocation Error"); + return; + } + + request_data->env = (axutil_env_t*)env; + request_data->conf_ctx = conf_ctx; + + /* Create a Local Copy of Request Content */ + std::string message_data = message.getData(); + axis2_char_t* request_content = + (axis2_char_t*)AXIS2_MALLOC(env->allocator, message_data.size()); + memcpy(request_content, message_data.c_str(), message_data.size()); + + request_data->request_content = request_content; + request_data->content_length = message_data.size(); + + /* Set ReplyTo */ + request_data->reply_to = NULL; + if(message.getMessageProperties().hasReplyTo()) + { + /* Create a Local Copy of ReplyTo */ + std::string reply_to_tmp = message.getMessageProperties().getReplyTo().getRoutingKey(); + axis2_char_t* reply_to = (axis2_char_t*)AXIS2_MALLOC(env->allocator, reply_to_tmp.size() + + 1); + strcpy(reply_to, reply_to_tmp.c_str()); + + request_data->reply_to = reply_to; + } + + /* Copy AMQP headers */ + /* Content-Type */ + request_data->content_type = NULL; + std::string content_type_tmp = message.getHeaders().getAsString(AXIS2_AMQP_HEADER_CONTENT_TYPE); + if(!content_type_tmp.empty()) + { + axis2_char_t* content_type = (axis2_char_t*)AXIS2_MALLOC(env->allocator, + content_type_tmp.size() + 1); + strcpy(content_type, content_type_tmp.c_str()); + + request_data->content_type = content_type; + } + + /* SOAPAction */ + request_data->soap_action = NULL; + std::string soap_action_tmp = message.getHeaders().getAsString(AXIS2_AMQP_HEADER_SOAP_ACTION); + if(!soap_action_tmp.empty()) + { + axis2_char_t* soap_action = (axis2_char_t*)AXIS2_MALLOC(env->allocator, + soap_action_tmp.size() + 1); + strcpy(soap_action, soap_action_tmp.c_str()); + + request_data->soap_action = soap_action; + } + +#ifdef AXIS2_SVR_MULTI_THREADED + worker_thread = axutil_thread_pool_get_thread(env->thread_pool, + axis2_amqp_request_processor_thread_function, + (void*)request_data); + + if (!worker_thread) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create Thread"); + return; + } + + axutil_thread_pool_thread_detach(env->thread_pool, worker_thread); +#else + axis2_amqp_request_processor_thread_function(NULL, (void*)request_data); +#endif +} diff --git a/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_listener.h b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_listener.h new file mode 100644 index 0000000..d5923db --- /dev/null +++ b/src/core/transport/amqp/receiver/qpid_receiver/axis2_qpid_receiver_listener.h @@ -0,0 +1,43 @@ +/* + * 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 + * + * tcp://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_QPID_RECEIVER_LISTENER_H +#define AXIS2_QPID_RECEIVER_LISTENER_H + +#include +#include +#include +#include + +using namespace qpid::client; +using namespace qpid::framing; + +class Axis2QpidReceiverListener : public MessageListener +{ + public: + Axis2QpidReceiverListener(const axutil_env_t* env, + axis2_conf_ctx_t* conf_ctx); + ~Axis2QpidReceiverListener(void); + + private: + virtual void received(Message& message); + + const axutil_env_t* env; + axis2_conf_ctx_t* conf_ctx; +}; + +#endif diff --git a/src/core/transport/amqp/receiver/qpid_receiver/request_processor/Makefile.am b/src/core/transport/amqp/receiver/qpid_receiver/request_processor/Makefile.am new file mode 100644 index 0000000..77cac4a --- /dev/null +++ b/src/core/transport/amqp/receiver/qpid_receiver/request_processor/Makefile.am @@ -0,0 +1,20 @@ +lib_LTLIBRARIES = libaxis2_amqp_request_processor.la + +libaxis2_amqp_request_processor_la_SOURCES = axis2_amqp_request_processor.c + +libaxis2_amqp_request_processor_la_LIBADD = $(top_builddir)/util/src/libaxutil.la \ + $(top_builddir)/src/core/transport/amqp/util/libaxis2_amqp_util.la + +libaxis2_amqp_request_processor_la_LDFLAGS = -version-info $(VERSION_NO) + +INCLUDES = -I$(top_builddir)/include \ + -I$(top_builddir)/src/core/transport/amqp/receiver/qpid_receiver/request_processor \ + -I$(top_builddir)/src/core/transport/amqp/util \ + -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 + diff --git a/src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.c b/src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.c new file mode 100644 index 0000000..0e0c9f8 --- /dev/null +++ b/src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.c @@ -0,0 +1,334 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include +#include +#include + +void* AXIS2_THREAD_FUNC +axis2_amqp_request_processor_thread_function( + axutil_thread_t* thread, + void* request_data) +{ + axis2_status_t status = AXIS2_FAILURE; + axutil_env_t* env = NULL; + axutil_env_t* thread_env = NULL; + axis2_amqp_request_processor_resource_pack_t* request_resource_pack = NULL; + +#ifndef WIN32 +#ifdef AXIS2_SVR_MULTI_THREADED + signal(SIGPIPE, SIG_IGN); +#endif +#endif + + request_resource_pack = (axis2_amqp_request_processor_resource_pack_t*)request_data; + + env = request_resource_pack->env; + thread_env = axutil_init_thread_env(env); + + /* Process Request */ + status = axis2_amqp_process_request(thread_env, request_resource_pack); + + if(status == AXIS2_SUCCESS) + { + AXIS2_LOG_INFO(thread_env->log, "Request Processed Successfully"); + } + else + { + AXIS2_LOG_WARNING(thread_env->log, AXIS2_LOG_SI, "Error while Processing Request"); + } + + AXIS2_FREE(thread_env->allocator, request_resource_pack->request_content); + AXIS2_FREE(thread_env->allocator, request_resource_pack->reply_to); + AXIS2_FREE(thread_env->allocator, request_resource_pack->content_type); + AXIS2_FREE(thread_env->allocator, request_resource_pack->soap_action); + + AXIS2_FREE(thread_env->allocator, request_resource_pack); + + if(thread_env) + { + thread_env = NULL; + } + +#ifdef AXIS2_SVR_MULTI_THREADED + axutil_thread_pool_exit_thread(env->thread_pool, thread); +#endif + + return NULL; +} + +axis2_status_t +axis2_amqp_process_request( + const axutil_env_t* env, + axis2_amqp_request_processor_resource_pack_t* request_resource_pack) +{ + axiom_xml_reader_t* xml_reader = NULL; + axiom_stax_builder_t* stax_builder = NULL; + axiom_soap_builder_t* soap_builder = NULL; + axis2_transport_out_desc_t* out_desc = NULL; + axis2_transport_in_desc_t* in_desc = NULL; + axis2_msg_ctx_t* msg_ctx = NULL; + axiom_soap_envelope_t* soap_envelope = NULL; + axis2_engine_t* engine = NULL; + const axis2_char_t* soap_ns_uri = NULL; + axis2_bool_t is_soap_11 = AXIS2_FALSE; + axis2_char_t *soap_body_str = NULL; + int soap_body_len = 0; + axis2_bool_t is_mtom = AXIS2_FALSE; + axis2_status_t status = AXIS2_FAILURE; + axutil_hash_t *binary_data_map = NULL; + axiom_soap_body_t *soap_body = NULL; + axutil_property_t* reply_to_property = NULL; + + /* Create msg_ctx */ + if(!request_resource_pack->conf_ctx) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Conf Context not Available"); + return AXIS2_FAILURE; + } + + out_desc = axis2_conf_get_transport_out(axis2_conf_ctx_get_conf( + request_resource_pack->conf_ctx, env), env, AXIS2_TRANSPORT_ENUM_AMQP); + if(!out_desc) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport Out Descriptor not Found"); + return AXIS2_FAILURE; + } + + in_desc = axis2_conf_get_transport_in(axis2_conf_ctx_get_conf(request_resource_pack->conf_ctx, + env), env, AXIS2_TRANSPORT_ENUM_AMQP); + if(!in_desc) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Transport In Descriptor not Found"); + return AXIS2_FAILURE; + } + + /* Create msg_ctx */ + msg_ctx = axis2_msg_ctx_create(env, request_resource_pack->conf_ctx, in_desc, out_desc); + + axis2_msg_ctx_set_server_side(msg_ctx, env, AXIS2_TRUE); + + /* Handle MTOM */ + if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_MULTIPART_RELATED)) + { + axis2_char_t* mime_boundary = axis2_amqp_util_get_value_from_content_type(env, + request_resource_pack->content_type, AXIS2_AMQP_HEADER_CONTENT_TYPE_MIME_BOUNDARY); + + if(mime_boundary) + { + axiom_mime_parser_t *mime_parser = NULL; + int soap_body_len = 0; + axutil_param_t *buffer_size_param = NULL; + axutil_param_t *max_buffers_param = NULL; + axutil_param_t *attachment_dir_param = NULL; + axis2_char_t *value_size = NULL; + axis2_char_t *value_num = NULL; + axis2_char_t *value_dir = NULL; + int size = 0; + int num = 0; + + mime_parser = axiom_mime_parser_create(env); + + buffer_size_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_BUFFER_SIZE); + if(buffer_size_param) + { + value_size = (axis2_char_t*)axutil_param_get_value(buffer_size_param, env); + if(value_size) + { + size = atoi(value_size); + axiom_mime_parser_set_buffer_size(mime_parser, env, size); + } + } + + max_buffers_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_MTOM_MAX_BUFFERS); + if(max_buffers_param) + { + value_num = (axis2_char_t*)axutil_param_get_value(max_buffers_param, env); + if(value_num) + { + num = atoi(value_num); + axiom_mime_parser_set_max_buffers(mime_parser, env, num); + } + } + + /* If this paramter is there mime_parser will cached the attachment + * using to the directory for large attachments. */ + attachment_dir_param = axis2_msg_ctx_get_parameter(msg_ctx, env, AXIS2_ATTACHMENT_DIR); + if(attachment_dir_param) + { + value_dir = (axis2_char_t*)axutil_param_get_value(attachment_dir_param, env); + if(value_dir) + { + axiom_mime_parser_set_attachment_dir(mime_parser, env, value_dir); + } + } + + if(mime_parser) + { + axis2_callback_info_t *callback_ctx = NULL; + axutil_stream_t *stream = NULL; + + callback_ctx = AXIS2_MALLOC(env->allocator, sizeof(axis2_callback_info_t)); + + stream = axutil_stream_create_basic(env); + if(stream) + { + axutil_stream_write(stream, env, request_resource_pack->request_content, + request_resource_pack->content_length); + callback_ctx->env = env; + callback_ctx->in_stream = stream; + callback_ctx->content_length = request_resource_pack->content_length; + callback_ctx->unread_len = request_resource_pack->content_length; + callback_ctx->chunked_stream = NULL; + } + + /*binary_data_map = + axiom_mime_parser_parse(mime_parser, env, + axis2_amqp_util_on_data_request, + (void*)callback_ctx, + mime_boundary);*/ + if(!binary_data_map) + { + return AXIS2_FAILURE; + } + + soap_body_str = axiom_mime_parser_get_soap_body_str(mime_parser, env); + soap_body_len = axiom_mime_parser_get_soap_body_len(mime_parser, env); + + axutil_stream_free(stream, env); + AXIS2_FREE(env->allocator, callback_ctx); + axiom_mime_parser_free(mime_parser, env); + } + + AXIS2_FREE(env->allocator, mime_boundary); + } + + is_mtom = AXIS2_TRUE; + } + else + { + soap_body_str = request_resource_pack->request_content; + soap_body_len = request_resource_pack->content_length; + } + + soap_body_len = axutil_strlen(soap_body_str); + + xml_reader = axiom_xml_reader_create_for_memory(env, soap_body_str, soap_body_len, NULL, + AXIS2_XML_PARSER_TYPE_BUFFER); + if(!xml_reader) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create XML Reader"); + return AXIS2_FAILURE; + } + + stax_builder = axiom_stax_builder_create(env, xml_reader); + if(!stax_builder) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create StAX Builder"); + return AXIS2_FAILURE; + } + + soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; + + if(request_resource_pack->content_type) + { + if(strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML)) + { + is_soap_11 = AXIS2_TRUE; + soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; + } + /*if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_APPL_SOAP)) + { + is_soap_11 = AXIS2_FALSE; + soap_ns_uri = AXIOM_SOAP12_SOAP_ENVELOPE_NAMESPACE_URI; + } + else if (strstr(request_resource_pack->content_type, AXIS2_AMQP_HEADER_ACCEPT_TEXT_XML)) + { + is_soap_11 = AXIS2_TRUE; + soap_ns_uri = AXIOM_SOAP11_SOAP_ENVELOPE_NAMESPACE_URI; + }*/ + } + + soap_builder = axiom_soap_builder_create(env, stax_builder, soap_ns_uri); + if(!soap_builder) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Failed to Create SOAP Builder"); + return AXIS2_FAILURE; + } + + if(binary_data_map) + { + axiom_soap_builder_set_mime_body_parts(soap_builder, env, binary_data_map); + } + + soap_envelope = axiom_soap_builder_get_soap_envelope(soap_builder, env); + axis2_msg_ctx_set_soap_envelope(msg_ctx, env, soap_envelope); + + soap_body = axiom_soap_envelope_get_body(soap_envelope, env); + + if(!soap_body) + { + return AXIS2_FAILURE; + } + + /* SOAPAction */ + if(request_resource_pack->soap_action) + { + axis2_msg_ctx_set_soap_action(msg_ctx, env, axutil_string_create(env, + request_resource_pack->soap_action)); + } + + /* SOAP version */ + axis2_msg_ctx_set_is_soap_11(msg_ctx, env, is_soap_11); + + /* Set ReplyTo in the msg_ctx as a property. This is used by the server when + * 1. WS-A is not in use + * 2. ReplyTo is an anonymous EPR - Sandesha2/Dual-channel */ + reply_to_property = axutil_property_create_with_args(env, AXIS2_SCOPE_REQUEST, 0, 0, + (void*)request_resource_pack->reply_to); + axis2_msg_ctx_set_property(msg_ctx, env, AXIS2_AMQP_MSG_CTX_PROPERTY_REPLY_TO, + reply_to_property); + + engine = axis2_engine_create(env, request_resource_pack->conf_ctx); + + if(AXIS2_TRUE == axiom_soap_body_has_fault(soap_body, env)) + { + status = axis2_engine_receive_fault(engine, env, msg_ctx); + } + else + { + status = axis2_engine_receive(engine, env, msg_ctx); + } + + if(engine) + { + axis2_engine_free(engine, env); + } + + if(soap_body_str && is_mtom) + { + AXIS2_FREE(env->allocator, soap_body_str); + } + + return status; +} diff --git a/src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.h b/src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.h new file mode 100644 index 0000000..97f13b2 --- /dev/null +++ b/src/core/transport/amqp/receiver/qpid_receiver/request_processor/axis2_amqp_request_processor.h @@ -0,0 +1,55 @@ +/* + * 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_AMQP_REQUEST_PROCESSOR_H +#define AXIS2_AMQP_REQUEST_PROCESSOR_H + +#include +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + typedef struct axis2_amqp_request_processor_resource_pack + { + axutil_env_t* env; + axis2_conf_ctx_t* conf_ctx; + axis2_char_t* request_content; + int content_length; + axis2_char_t* reply_to; + axis2_char_t* content_type; + axis2_char_t* soap_action; + } axis2_amqp_request_processor_resource_pack_t; + + /* The worker thread function */ + void* AXIS2_THREAD_FUNC + axis2_amqp_request_processor_thread_function( + axutil_thread_t* thread, + void* request_data); + + axis2_status_t + axis2_amqp_process_request( + const axutil_env_t* env, + axis2_amqp_request_processor_resource_pack_t* request_resource_pack); + +#ifdef __cplusplus +} +#endif + +#endif -- cgit v1.1-32-gdbae