From e982b4ef38fd043c15e89bdd60763b10434a087e Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Sun, 28 Feb 2010 19:40:06 +0000 Subject: Moving old inactive code to a branch as it's confusing code assist, searches and indexing in trunk. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@917273 13f79535-47bb-0310-9956-ffa450edef68 --- .../runtime/extensions/ws/service/Makefile.am | 18 + .../extensions/ws/service/axis2c/Makefile.am | 18 + .../extensions/ws/service/axis2c/src/Makefile.am | 94 ++++ .../extensions/ws/service/axis2c/src/axis2.xml | 181 +++++++ .../extensions/ws/service/axis2c/src/deploy.bat | 39 ++ .../extensions/ws/service/axis2c/src/deploy.sh | 47 ++ .../extensions/ws/service/axis2c/src/module.xml | 25 + .../extensions/ws/service/axis2c/src/services.xml | 25 + .../axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp | 177 +++++++ .../src/tuscany/sca/ws/Axis2DispatcherModule.cpp | 149 ++++++ .../axis2c/src/tuscany/sca/ws/Axis2Service.cpp | 553 ++++++++++++++++++++ .../axis2c/src/tuscany/sca/ws/Axis2Utils.cpp | 77 +++ .../service/axis2c/src/tuscany/sca/ws/Axis2Utils.h | 46 ++ .../tuscany/sca/ws/WSReferenceBindingExtension.cpp | 119 +++++ .../tuscany/sca/ws/WSReferenceBindingExtension.h | 76 +++ .../axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp | 579 +++++++++++++++++++++ .../axis2c/src/tuscany/sca/ws/WSServiceProxy.h | 95 ++++ .../ws/service/axis2c/src/tuscany/sca/ws/export.h | 38 ++ .../tuscany/sca/ws/model/WSReferenceBinding.cpp | 151 ++++++ .../src/tuscany/sca/ws/model/WSReferenceBinding.h | 143 +++++ 20 files changed, 2650 insertions(+) create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/Makefile.am create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/Makefile.am create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/Makefile.am create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/axis2.xml create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/deploy.bat create mode 100755 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/deploy.sh create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/module.xml create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/services.xml create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2DispatcherModule.cpp create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.h create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.h create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.h create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/export.h create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.cpp create mode 100644 sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.h (limited to 'sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service') diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/Makefile.am b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/Makefile.am new file mode 100644 index 0000000000..18e9ba89b9 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/Makefile.am @@ -0,0 +1,18 @@ +# 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. + +SUBDIRS = axis2c diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/Makefile.am b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/Makefile.am new file mode 100644 index 0000000000..feadf9e317 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/Makefile.am @@ -0,0 +1,18 @@ +# 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. + +SUBDIRS = src \ No newline at end of file diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/Makefile.am b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/Makefile.am new file mode 100644 index 0000000000..88f7fc1a9e --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/Makefile.am @@ -0,0 +1,94 @@ +# 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. + +libdir=$(prefix)/extensions/ws/service/lib +lib_LTLIBRARIES = \ +libtuscany_sca_ws_service.la \ +libtuscany_sca_ws_dispatcher.la + +noinst_HEADERS = \ +tuscany/sca/ws/*.h \ +tuscany/sca/ws/model/*.h + +libtuscany_sca_ws_service_la_SOURCES = \ +tuscany/sca/ws/WSReferenceBindingExtension.cpp \ +tuscany/sca/ws/model/WSReferenceBinding.cpp \ +tuscany/sca/ws/WSServiceProxy.cpp \ +tuscany/sca/ws/Axis2Service.cpp \ +tuscany/sca/ws/Axis2Utils.cpp + +libtuscany_sca_ws_service_la_LIBADD = \ + -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo -ltuscany_sdo_axiom \ + -L$(top_builddir)/runtime/core/src -ltuscany_sca \ + -L$(AXIS2C_HOME)/lib \ + -laxis2_util \ + -laxis2_axiom \ + -laxis2_wsdl \ + -laxis2_engine \ + -laxis2_parser \ + -laxis2_minizip \ + -lpthread \ + -lwoden \ + -laxis2_http_sender \ + -laxis2_http_receiver + +rootdir=$(prefix)/extensions/ws/service +root_DATA = axis2.xml +root_SCRIPTS = deploy.sh + +libtuscany_sca_ws_dispatcher_la_SOURCES = \ +tuscany/sca/ws/Axis2Dispatcher.cpp \ +tuscany/sca/ws/Axis2DispatcherModule.cpp + +libtuscany_sca_ws_dispatcher_la_LIBADD = \ + -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo -ltuscany_sdo_axiom \ + -L$(top_builddir)/runtime/core/src -ltuscany_sca \ + -L$(AXIS2C_HOME)/lib \ + -laxis2_util \ + -laxis2_axiom \ + -laxis2_wsdl \ + -laxis2_engine \ + -laxis2_parser \ + -laxis2_minizip \ + -lpthread \ + -lwoden \ + -laxis2_http_sender \ + -laxis2_http_receiver + +servicedir=$(rootdir)/services/tuscany +service_DATA = services.xml + +modulesdir=$(rootdir)/modules/tuscany +modules_DATA = module.xml + +EXTRA_DIST = axis2.xml services.xml module.xml deploy.sh + +install-data-hook: + cd $(servicedir); ln -s -f ../../lib/libtuscany_sca_ws_service.so libtuscany_sca_ws_service.so + cd $(modulesdir); ln -s -f ../../lib/libtuscany_sca_ws_dispatcher.so libtuscany_sca_ws_dispatcher.so + +INCLUDES = -I$(top_builddir)/runtime/core/src \ + -I${TUSCANY_SDOCPP}/include \ + -I${AXIS2C_HOME}/include + +moduledir=$(prefix)/extensions/ws/service/module +extension = libtuscany_sca_ws_service$(libsuffix) + +install-exec-hook: + test -z $(moduledir) || $(mkdir_p) $(moduledir); + -rm -f $(moduledir)/$(extension) + $(LN_S) $(libdir)/$(extension) $(moduledir)/$(extension) diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/axis2.xml b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/axis2.xml new file mode 100644 index 0000000000..641085466e --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/axis2.xml @@ -0,0 +1,181 @@ + + + + + + false + false + false + true + + admin + axis2 + + . + + 127.0.0.1 + 5555 + + + + + + + + + + + + + + + + + + + + + + + + + 6060 + + + + + + + + + + + + HTTP/1.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/deploy.bat b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/deploy.bat new file mode 100644 index 0000000000..6493e1cec9 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/deploy.bat @@ -0,0 +1,39 @@ +@echo off +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM http://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. + + +rem Will deploy the Tuscany SCA WS service Axis2C service and module +rem to the correct places within the AXIS2C_HOME directory +setlocal +set currentPath=%~d0%~p0 + +if "%AXIS2C_HOME%" == "" ( +echo "AXIS2C_HOME not set" +goto end +) +echo Deploying to Axis2C installed at %AXIS2C_HOME% + +if not exist %AXIS2C_HOME%\services\tuscany mkdir %AXIS2C_HOME%\services\tuscany +if not exist %AXIS2C_HOME%\modules\tuscany mkdir %AXIS2C_HOME%\modules\tuscany + +copy %currentPath%\services\tuscany\* %AXIS2C_HOME%\services\tuscany +copy %currentPath%\modules\tuscany\* %AXIS2C_HOME%\modules\tuscany +copy %currentPath%\axis2.xml %AXIS2C_HOME%\axis2.xml + +:end +endlocal diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/deploy.sh b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/deploy.sh new file mode 100755 index 0000000000..ffe571b0ee --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/deploy.sh @@ -0,0 +1,47 @@ +#!/bin/sh + +# 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. + +APFULLDIR=`pwd` + +if [ x$AXIS2C_HOME = x ]; then +echo "AXIS2C_HOME not set" +exit; +fi +echo "Deploying to Axis2C installed at $AXIS2C_HOME" + +if ! [ -d $AXIS2C_HOME/services/tuscany ]; then + mkdir $AXIS2C_HOME/services/tuscany +fi + +if ! [ -d $AXIS2C_HOME/modules/tuscany ]; then + mkdir $AXIS2C_HOME/modules/tuscany +fi + +cp $APFULLDIR/services/tuscany/services.xml $AXIS2C_HOME/services/tuscany + +if ! [ -f $AXIS2C_HOME/services/tuscany/libtuscany_sca_ws_service.so ]; then + ln -s $APFULLDIR/services/tuscany/libtuscany_sca_ws_service.so $AXIS2C_HOME/services/tuscany/libtuscany_sca_ws_service.so +fi + +cp $APFULLDIR/modules/tuscany/module.xml $AXIS2C_HOME/modules/tuscany +if ! [ -f $AXIS2C_HOME/modules/tuscany/libtuscany_sca_ws_dispatcher.so ]; then + ln -s $APFULLDIR/modules/tuscany/libtuscany_sca_ws_dispatcher.so $AXIS2C_HOME/modules/tuscany/libtuscany_sca_ws_dispatcher.so +fi + +cp $APFULLDIR/axis2.xml $AXIS2C_HOME/axis2.xml diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/module.xml b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/module.xml new file mode 100644 index 0000000000..97d4d43a86 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/module.xml @@ -0,0 +1,25 @@ + + + + + + + + diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/services.xml b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/services.xml new file mode 100644 index 0000000000..335d4d96be --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/services.xml @@ -0,0 +1,25 @@ + + + + + tuscany_sca_ws_service + + + diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp new file mode 100644 index 0000000000..b6d2ac9225 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp @@ -0,0 +1,177 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#pragma warning(disable: 4091) +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "tuscany/sca/util/Logging.h" + +extern "C" +{ + +axis2_status_t AXIS2_CALL +Axis2Dispatcher_invoke ( + axis2_handler_t * handler, + const axis2_env_t *env, + struct axis2_msg_ctx *msg_ctx); + +axis2_svc_t *AXIS2_CALL +Axis2Dispatcher_find_svc( + axis2_msg_ctx_t *msg_ctx, + const axis2_env_t *env); + +axis2_op_t *AXIS2_CALL +Axis2Dispatcher_find_op( + axis2_msg_ctx_t *msg_ctx, + const axis2_env_t *env, + axis2_svc_t *svc); + + +AXIS2_EXPORT axis2_handler_t* AXIS2_CALL +Axis2Dispatcher_create(const axis2_env_t *env, + axis2_qname_t *qname) +{ + axis2_handler_t *handler = NULL; + + handler = axis2_handler_create(env); + if (!handler) + { + return NULL; + } + + /* handler init is handled by conf loading, so no need to do it here */ + + /* set the base struct's invoke op */ + if (handler->ops) + handler->ops->invoke = Axis2Dispatcher_invoke; + + return handler; +} + +axis2_svc_t *AXIS2_CALL +Axis2Dispatcher_find_svc( + axis2_msg_ctx_t *msg_ctx, + const axis2_env_t *env) +{ + axis2_svc_t *svc = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + axis2_conf_ctx_t *conf_ctx = NULL; + conf_ctx = AXIS2_MSG_CTX_GET_CONF_CTX(msg_ctx, env); + if (conf_ctx) + { + axis2_conf_t *conf = NULL; + conf = AXIS2_CONF_CTX_GET_CONF(conf_ctx, env); + if (conf) + { + axis2_char_t* service_name = "TuscanyService"; + svc = AXIS2_CONF_GET_SVC(conf, env, service_name); + if (svc) + { + loginfo("Service found using target endpoint address"); + } + } + } + + return svc; +} + +axis2_op_t *AXIS2_CALL +Axis2Dispatcher_find_op( + axis2_msg_ctx_t *msg_ctx, + const axis2_env_t *env, + axis2_svc_t *svc) +{ + axis2_op_t *op = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + axis2_qname_t *op_qname = NULL; + axis2_char_t* execute_op_name = "execute"; + op_qname = axis2_qname_create(env, execute_op_name, NULL, NULL); + + op = AXIS2_SVC_GET_OP_WITH_NAME(svc, env, AXIS2_QNAME_GET_LOCALPART(op_qname, env)); + + AXIS2_QNAME_FREE(op_qname, env); + if (op) + { + loginfo("TuscanyService execute operation found"); + } + return op; +} + +axis2_status_t AXIS2_CALL +Axis2Dispatcher_invoke( + axis2_handler_t * handler, + const axis2_env_t *env, + struct axis2_msg_ctx *msg_ctx) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if (!(AXIS2_MSG_CTX_GET_SERVER_SIDE(msg_ctx, env))) + return AXIS2_SUCCESS; + + msg_ctx->ops->find_svc = Axis2Dispatcher_find_svc; + msg_ctx->ops->find_op = Axis2Dispatcher_find_op; + + axis2_svc_t *axis_service = NULL; + axis2_op_t *op = NULL; + + axis_service = AXIS2_MSG_CTX_GET_SVC(msg_ctx, env); + + if (!axis_service) + { + axis_service = AXIS2_MSG_CTX_FIND_SVC(msg_ctx, env); + if (axis_service) + { + AXIS2_MSG_CTX_SET_SVC(msg_ctx, env, axis_service); + /*TODO Set the Service Group Context to the message Context*/ + } + } + op = AXIS2_MSG_CTX_GET_OP(msg_ctx, env); + if (!op) + { + op = AXIS2_MSG_CTX_FIND_OP(msg_ctx, env, axis_service); + + if (op) + { + AXIS2_MSG_CTX_SET_OP(msg_ctx, env, op); + } + } + + return AXIS2_SUCCESS; +} + +} diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2DispatcherModule.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2DispatcherModule.cpp new file mode 100644 index 0000000000..0dc8f3358a --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2DispatcherModule.cpp @@ -0,0 +1,149 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#pragma warning(disable: 4091) +#endif + +#include +#include +#include +#include + +extern "C" +{ + +axis2_status_t AXIS2_CALL +Axis2DispatcherModule_shutdown(axis2_module_t *module, + const axis2_env_t *env); + +axis2_status_t AXIS2_CALL +Axis2DispatcherModule_init( + axis2_module_t *module, + const axis2_env_t *env, + axis2_conf_ctx_t *conf_ctx, + axis2_module_desc_t *module_desc); + +axis2_status_t AXIS2_CALL +Axis2DispatcherModule_fill_handler_create_func_map(axis2_module_t *module, + const axis2_env_t *env); + +AXIS2_EXTERN axis2_handler_t* AXIS2_CALL +Axis2Dispatcher_create(const axis2_env_t *env, + axis2_qname_t *qname); + +axis2_module_t * +Axis2DispatcherModule_create(const axis2_env_t *env) +{ + axis2_module_t *module = NULL; + module = (axis2_module_t*)AXIS2_MALLOC(env->allocator, + sizeof(axis2_module_t)); + + + module->ops = (axis2_module_ops_t*)AXIS2_MALLOC( + env->allocator, sizeof(axis2_module_ops_t)); + + module->ops->shutdown = Axis2DispatcherModule_shutdown; + module->ops->init = Axis2DispatcherModule_init; + module->ops->fill_handler_create_func_map = + Axis2DispatcherModule_fill_handler_create_func_map; + + return module; +} + +axis2_status_t AXIS2_CALL +Axis2DispatcherModule_init( + axis2_module_t *module, + const axis2_env_t *env, + axis2_conf_ctx_t *conf_ctx, + axis2_module_desc_t *module_desc) +{ + return AXIS2_SUCCESS; +} + +axis2_status_t AXIS2_CALL +Axis2DispatcherModule_shutdown(axis2_module_t *module, + const axis2_env_t *env) +{ + if(module->ops) + { + AXIS2_FREE(env->allocator, module->ops); + module->ops = NULL; + } + + if(module->handler_create_func_map) + { + axis2_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 +Axis2DispatcherModule_fill_handler_create_func_map(axis2_module_t *module, + const axis2_env_t *env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + module->handler_create_func_map = axis2_hash_make(env); + axis2_hash_set(module->handler_create_func_map, "TuscanyDispatcher", + (axis2_ssize_t)AXIS2_HASH_KEY_STRING, (const void *)Axis2Dispatcher_create); + + return AXIS2_SUCCESS; +} + +/** + * Following block distinguish the exposed part of the dll. + */ + +AXIS2_EXPORT int +axis2_get_instance(axis2_module_t **inst, + const axis2_env_t *env) +{ + *inst = Axis2DispatcherModule_create(env); + if(!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; +} + +AXIS2_EXPORT int +axis2_remove_instance(axis2_module_t *inst, + const axis2_env_t *env) +{ + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = Axis2DispatcherModule_shutdown(inst, env); + } + return status; +} + +} diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp new file mode 100644 index 0000000000..9f1207dce8 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp @@ -0,0 +1,553 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#pragma warning(disable: 4091) +#endif + +#include + +#include +#include +#include +#include +#include + +#include + +#include "tuscany/sca/core/Exceptions.h" +#include "tuscany/sca/util/Logging.h" +#include "WSServiceProxy.h" +#include "model/WSReferenceBinding.h" +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/CompositeService.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/Reference.h" +#include "tuscany/sca/model/ReferenceType.h" +#include "tuscany/sca/model/WSDLDefinition.h" +#include "tuscany/sca/model/WSDLOperation.h" +#include "tuscany/sca/model/WSDLMessagePart.h" +#include "tuscany/sca/model/WSDLInterface.h" +#include "tuscany/sca/model/Interface.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "tuscany/sca/util/Utils.h" +#include "Axis2Utils.h" + +using namespace std; +using namespace commonj::sdo; +using namespace commonj::sdo_axiom; +using namespace tuscany::sca; +using namespace tuscany::sca::model; +using namespace tuscany::sca::util; + +namespace tuscany +{ + namespace sca + { + namespace ws + { + + int AXIS2_CALL + Axis2Service_free(axis2_svc_skeleton_t *svc_skeleton, + const axis2_env_t *env); + + axiom_node_t* AXIS2_CALL + Axis2Service_invoke(axis2_svc_skeleton_t *svc_skeleton, + const axis2_env_t *env, + axiom_node_t *node, + axis2_msg_ctx_t *msg_ctx); + + int AXIS2_CALL + Axis2Service_init(axis2_svc_skeleton_t *svc_skeleton, + const axis2_env_t *env); + + axis2_svc_skeleton_t* + axis2_Axis2Service_create(axis2_env_t *env) + { + axis2_svc_skeleton_t *svc_skeleton = NULL; + svc_skeleton = (axis2_svc_skeleton_t *) AXIS2_MALLOC((env)->allocator, + sizeof(axis2_svc_skeleton_t)); + + + svc_skeleton->ops = (axis2_svc_skeleton_ops_t *) AXIS2_MALLOC( + (env)->allocator, sizeof(axis2_svc_skeleton_ops_t)); + + svc_skeleton->func_array = NULL; + + svc_skeleton->ops->free = Axis2Service_free; + svc_skeleton->ops->init = Axis2Service_init; + svc_skeleton->ops->invoke = Axis2Service_invoke; + /*svc_skeleton->ops->on_fault = Axis2Service_on_fault;*/ + + return svc_skeleton; + } + + int AXIS2_CALL + Axis2Service_init(axis2_svc_skeleton_t *svc_skeleton, + const axis2_env_t *env) + { + // This method never seems to be called - an old Axis2C artifact? + + svc_skeleton->func_array = axis2_array_list_create(env, 0); + return AXIS2_SUCCESS; + } + + int AXIS2_CALL + Axis2Service_free(axis2_svc_skeleton_t *svc_skeleton, + const axis2_env_t *env) + { + if(svc_skeleton->ops) + { + AXIS2_FREE((env)->allocator, svc_skeleton->ops); + svc_skeleton->ops = NULL; + } + + if(svc_skeleton) + { + AXIS2_FREE((env)->allocator, svc_skeleton); + svc_skeleton = NULL; + } + return AXIS2_SUCCESS; + } + + + /** + * Initialize the SCA runtime + */ + CompositeService* initializeSCARuntime(const char*home, const char* root, + const char* path, const char* baseURI, const char *component, const char* service) + { + logentry(); + loginfo("Home: %s", home); + loginfo("Root: %s", root); + loginfo("Path: %s", path); + loginfo("Base URI: %s", baseURI); + loginfo("Component: %s", component); + loginfo("Service: %s", service); + + try + { + SCARuntime* runtime = SCARuntime::initializeSharedRuntime(home, root, path, baseURI); + + string componentName; + if (strlen(component)) + { + componentName = component; + } + else + { + componentName = runtime->getDefaultComponentName(); + } + string serviceName = service; + + loginfo("Resolving composite: %s, service: %s", componentName.c_str(), serviceName.c_str()); + Component* compositeComponent = runtime->getSystem()->findComponent(componentName); + if (compositeComponent == NULL) + { + string msg = "Component not found " + componentName; + throwException(SystemConfigurationException, msg.c_str()); + } + runtime->setDefaultComponent(compositeComponent); + + Composite* composite = (Composite*)compositeComponent->getType(); + CompositeService* compositeService = (CompositeService*)composite->findComponent(serviceName); + if (compositeService == NULL) + { + string msg = "Composite service not found " + serviceName; + throwException(SystemConfigurationException, msg.c_str()); + } + + return compositeService; + } + catch(TuscanyRuntimeException &ex) + { + ostringstream msg; + msg << ex; + logerror("Failed to initialize SCA runtime: %s", msg.str().c_str()); + throw; + } + } + + + /* + * This method invokes the target service method + */ + axiom_node_t* AXIS2_CALL + Axis2Service_invoke(axis2_svc_skeleton_t *svc_skeleton, + const axis2_env_t *env, + axiom_node_t *node, + axis2_msg_ctx_t *msg_ctx) + { + logentry(); + + try + { + if (node) + { + if (AXIOM_NODE_GET_NODE_TYPE(node, env) == AXIOM_ELEMENT) + { + axiom_element_t *element = NULL; + element = (axiom_element_t *)AXIOM_NODE_GET_DATA_ELEMENT(node, env); + if (element) + { + string op_name = ""; + + axis2_bool_t rest = AXIS2_MSG_CTX_GET_DOING_REST(msg_ctx, env); + if (rest) + { + axis2_endpoint_ref_t *endpoint_ref = AXIS2_MSG_CTX_GET_FROM(msg_ctx, env); + if (endpoint_ref) + { + const axis2_char_t *addr = AXIS2_ENDPOINT_REF_GET_ADDRESS(endpoint_ref, env); + if (addr) + { + // REST request, the op name is the last segment of the path + string raddress = addr; + string path; + string query; + Utils::tokeniseString("?", raddress, path, query); + string uri; + Utils::rTokeniseString("/", path, uri, op_name); + } + } + } + else + { + // SOAP request + // Get the operation name from the root element name, this is correct for DocLit Wrapped style + op_name = AXIOM_ELEMENT_GET_LOCALNAME(element, env); + } + + if (op_name != "") + { + CompositeService* compositeService; + + // Get the Tuscany home, system root, path and composite service name from the Axis2 + // service parameters + char* homeParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyHome"); + if (homeParam == NULL) + homeParam = ""; + + char* rootParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyRoot"); + if (rootParam == NULL) + rootParam = ""; + + char* pathParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyPath"); + if (pathParam == NULL) + pathParam = ""; + + char* baseURIParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyBaseURI"); + if (baseURIParam == NULL) + baseURIParam = ""; + + char* serviceParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyService"); + if (serviceParam != NULL) + { + loginfo("System root: %s, service name: %s, operation name: %s", rootParam, serviceParam, op_name.c_str()); + + // Service is of the form "component name"/"composite service name" + string component, service; + Utils::rTokeniseString("/", serviceParam, component, service); + + compositeService = initializeSCARuntime(homeParam, rootParam, pathParam, baseURIParam, component.c_str(), service.c_str()); + } + else { + + // Use the default home, system root and component, the service is + // derived from the target address + axis2_endpoint_ref_t *endpoint_ref = NULL; + endpoint_ref = AXIS2_MSG_CTX_GET_FROM(msg_ctx, env); + string address = AXIS2_ENDPOINT_REF_GET_ADDRESS(endpoint_ref, env); + + axis2_bool_t isrest = AXIS2_MSG_CTX_GET_DOING_REST(msg_ctx, env); + string path; + if (isrest) + { + string op; + Utils::rTokeniseString("/", address, path, op); + } + else + { + path = address; + } + + string path2; + string service; + Utils::rTokeniseString("/", path, path2, service); + + string path3; + string component; + Utils::rTokeniseString("/", path2, path3, component); + if (component == "services") + { + component = ""; + } + + loginfo("System root: %s, component name: %s, service name: %s, operation name: %s", + rootParam, component.c_str(), service.c_str(), op_name.c_str()); + + compositeService = initializeSCARuntime(homeParam, rootParam, pathParam, baseURIParam, component.c_str(), service.c_str()); + } + + if(!compositeService) + { + throwException(SystemConfigurationException, + "Failed to initialize SCA runtime, could not initialize CompositeService"); + } + + DataFactoryPtr dataFactory = compositeService->getComposite()->getDataFactory(); + if (dataFactory == 0) + { + throwException(SystemConfigurationException, + "Failed to initialize SCA runtime, could not get DataFactory"); + } + + // Get the WS binding and the WSDL operation + Composite* composite = compositeService->getComposite(); + Reference* reference = compositeService->getReference(); + WSReferenceBinding* binding = (WSReferenceBinding*)reference->getBinding(); + WSDLOperation wsdlOperation; + + // First use the WSDL definition specified in the binding + string wsdlNamespace = binding->getWSDLNamespaceURL(); + if (wsdlNamespace != "") + { + WSDLDefinition* wsdlDefinition = composite->findWSDLDefinition(wsdlNamespace); + if (wsdlDefinition == 0) + { + string msg = "WSDL not found for: " + wsdlNamespace; + throwException(SystemConfigurationException, msg.c_str()); + } + + // Find the target operation in the WSDL port type. + try { + wsdlOperation = wsdlDefinition->findOperation( + binding->getServiceName(), + binding->getEndpointName(), + op_name.c_str()); + } + catch(SystemConfigurationException&) + { + throw; + } + + } + else + { + // Then use the WSDL definition specified in the WSDL interface, if any + Interface* iface = reference->getType()->getInterface(); + if (iface != NULL && + iface->getInterfaceTypeQName() == WSDLInterface::typeQName) + { + WSDLInterface* wsdlInterface = (WSDLInterface*)iface; + wsdlNamespace = wsdlInterface->getNamespaceURI(); + + if (wsdlNamespace != "") + { + + WSDLDefinition* wsdl = composite->findWSDLDefinition(wsdlNamespace); + if (wsdl == 0) + { + string msg = "WSDL not found for: " + wsdlNamespace; + throwException(SystemConfigurationException, msg.c_str()); + } + + try + { + wsdlOperation = wsdl->findOperation(wsdlInterface->getName(), op_name.c_str()); + } + catch(SystemConfigurationException&) + { + throw; + } + } + } + } + + // No WSDL definition was specified in the binding or interface + // Create a default document literal wrapped WSDL operation + if (wsdlNamespace == "") + { + WSDLMessagePart inPart(op_name, "", "http://tempuri.org"); + WSDLMessagePart outPart((op_name+"Response"), "", "http://tempuri.org"); + wsdlNamespace = compositeService->getName(); + wsdlOperation = WSDLOperation(); + wsdlOperation.setOperationName(op_name.c_str()); + wsdlOperation.setSoapAction(wsdlNamespace+ "#" +op_name); + wsdlOperation.setEndpoint(""); + wsdlOperation.setSoapVersion(WSDLOperation::SOAP11); + wsdlOperation.setDocumentStyle(true); + wsdlOperation.setWrappedStyle(true); + wsdlOperation.setInputEncoded(false); + wsdlOperation.setOutputEncoded(false); + wsdlOperation.setInputMessagePart(op_name, inPart); + wsdlOperation.setOutputMessagePart((op_name+"Response"), outPart); + } + else if (!wsdlOperation.isDocumentStyle() || !wsdlOperation.isWrappedStyle()) + { + throwException(ServiceInvocationException, + "Only wrapped document style WSDL operations are currentlysupported"); + } + + // Convert the input AXIOM node to an SDO DataObject + axiom_node_t* body = AXIOM_NODE_GET_PARENT(node, env); + char* str = NULL; + str = AXIOM_NODE_TO_STRING(body, env); + if (str) + { + loginfo("Received request Axis2 OM: %s", str); + } + + // Convert the SOAP body to an SDO DataObject + DataObjectPtr inputBodyDataObject = NULL; + DataObjectPtr inputDataObject = NULL; + + AxiomHelper* axiomHelper = AxiomHelper::getHelper(); + + try + { + inputBodyDataObject = axiomHelper->toSdo(body, dataFactory); + if(!inputBodyDataObject) + { + string msg = "Could not convert request Axis2 OM to SDO"; + throwException(ServiceInvocationException, msg.c_str()); + } + else + { + ostringstream os; + os << inputBodyDataObject; + loginfo("Converted Axis2 OM node to SDO: %s", os.str().c_str()); + } + + // Get the first body part representing the doc-lit-wrapped wrapper element + PropertyList bpl = inputBodyDataObject->getInstanceProperties(); + if (bpl.size()!=0) + { + if (bpl[0].isMany()) + { + DataObjectList& parts = inputBodyDataObject->getList((unsigned int)0); + inputDataObject = parts[0]; + } + else + { + inputDataObject = inputBodyDataObject->getDataObject(bpl[0]); + } + } + if (inputDataObject == NULL) + { + string msg = "Could not convert Axis2 body part to SDO"; + throwException(ServiceInvocationException, msg.c_str()); + } + } + catch(SDORuntimeException &ex) + { + throwException(ServiceDataException, ex); + } + + // Dispatch to the WS proxy + WSServiceProxy* proxy = (WSServiceProxy*)binding->getServiceProxy(); + + DataObjectPtr outputDataObject = proxy->invoke(wsdlOperation, inputDataObject); + + if(!outputDataObject) + { + return 0; + } + + try + { + std::list partList = + wsdlOperation.getOutputMessagePartNames(); + const WSDLMessagePart &outPart = + wsdlOperation.getOutputMessagePart(partList.front()); + // Convert the output DataObject to an Axiom node + axiom_node_t* outputNode = + axiomHelper->toAxiomNode(outputDataObject, + outPart.getPartUri().c_str(), + outPart.getPartName().c_str()); + + AxiomHelper::releaseHelper(axiomHelper); + + str = AXIOM_NODE_TO_STRING(outputNode, env); + if (str) + { + loginfo("Sending response Axis2 OM : %s", str); + } + + return outputNode; + } + catch(SDORuntimeException &ex) + { + throwException(ServiceDataException, ex); + } + } + } + } + } + + string msg = "Invalid parameters in Axis2 request OM"; + throwException(ServiceInvocationException, msg.c_str()); + + } + catch(TuscanyRuntimeException& ex) + { + ostringstream msg; + msg << ex; + logerror("Failed to process Web service invocation: %s", msg.str().c_str()); + } + return 0; + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany + +extern "C" +{ + + /** + * Following block distinguish the exposed part of the dll. + */ + + AXIS2_EXPORT int axis2_get_instance(axis2_svc_skeleton **inst, + axis2_env_t *env) + { + *inst = tuscany::sca::ws::axis2_Axis2Service_create(env); + if(!(*inst)) + { + return AXIS2_FAILURE; + } + + return AXIS2_SUCCESS; + } + + AXIS2_EXPORT int axis2_remove_instance(axis2_svc_skeleton_t *inst, + axis2_env_t *env) + { + axis2_status_t status = AXIS2_FAILURE; + if (inst) + { + status = AXIS2_SVC_SKELETON_FREE(inst, env); + } + return status; + } +} diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp new file mode 100644 index 0000000000..09c3862590 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp @@ -0,0 +1,77 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) +#pragma warning(disable: 4091) +#endif + +#include +#include + +#include "tuscany/sca/util/Logging.h" +#include "Axis2Utils.h" + +using namespace tuscany::sca; +using namespace tuscany::sca::ws; + +namespace tuscany +{ + namespace sca + { + namespace ws + { + + char* Axis2Utils::getAxisServiceParameterValue(const axis2_env_t *env, axis2_msg_ctx_t *msg_ctx, char* parameterName) + { + logentry(); + + struct axis2_svc *svc = NULL; + struct axis2_op_ctx *op_ctx = NULL; + struct axis2_svc_ctx *svc_ctx = NULL; + axis2_param_t *param = NULL; + char* paramValue = 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(NULL == svc) + { + return NULL; + } + + param = AXIS2_SVC_GET_PARAM(svc, env, parameterName); + if(!param) + { + logwarning("Axis parameter %s cannot be found", parameterName); + } + else + { + paramValue = (char*) AXIS2_PARAM_GET_VALUE(param, env); + } + + return paramValue; + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany + diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.h new file mode 100644 index 0000000000..4e8b069010 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.h @@ -0,0 +1,46 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_extension_ws_axis2utils_h +#define tuscany_sca_extension_ws_axis2utils_h + +#include +#include + + +namespace tuscany +{ + namespace sca + { + namespace ws + { + + class Axis2Utils + { + public: + static char* getAxisServiceParameterValue(const axis2_env_t *env, axis2_msg_ctx_t *msg_ctx, char* parameterName); + }; + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_extension_ws_axis2utils_h diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp new file mode 100644 index 0000000000..24a7552bc4 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.cpp @@ -0,0 +1,119 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + + +#include "WSReferenceBindingExtension.h" +#include "model/WSReferenceBinding.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/core/SCARuntime.h" + +using namespace std; +using namespace tuscany::sca::model; +using namespace commonj::sdo; + +extern "C" +{ +#if defined(WIN32) || defined(_WINDOWS) + __declspec(dllexport) +#endif + void tuscany_sca_ws_service_initialize() + { + tuscany::sca::ws::WSReferenceBindingExtension::initialize(); + } +} + +namespace tuscany +{ + namespace sca + { + namespace ws + { + // =================================================================== + // Constructor for the WSReferenceBinding class. + // =================================================================== + WSReferenceBindingExtension::WSReferenceBindingExtension() + { + logentry(); + } + + // =================================================================== + // Destructor for the WSReferenceBindingExtension class. + // =================================================================== + WSReferenceBindingExtension::~WSReferenceBindingExtension() + { + logentry(); + } + + const string WSReferenceBindingExtension::extensionName("ws"); + const string WSReferenceBindingExtension::typeQName("http://www.osoa.org/xmlns/sca/1.0#WebServiceBinding"); + + // =================================================================== + // loadModelElement - load the info from binding.ws + // =================================================================== + ReferenceBinding* WSReferenceBindingExtension::getReferenceBinding(Composite *composite, Reference* reference, DataObjectPtr scdlBinding) + { + logentry(); + + string uri = scdlBinding->getCString("uri"); + + string endpoint; + try + { + endpoint = scdlBinding->getCString("endpoint"); + } + catch (SDORuntimeException&) + { + endpoint = ""; + } + + string version; + try + { + commonj::sdo::DataObjectList& soap = scdlBinding->getList("soapbinding"); + if (soap.size()!=0) + { + version = soap.getCString(0); + } + else + { + version = ""; + } + } + catch (SDORuntimeException&) + { + version = ""; + } + + WSReferenceBinding* serviceBinding = new WSReferenceBinding(reference, uri, endpoint, version); + + return serviceBinding; + } + + void WSReferenceBindingExtension::initialize() + { + logentry(); + SCARuntime::getCurrentRuntime()->registerReferenceBindingExtension(new WSReferenceBindingExtension()); + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.h new file mode 100644 index 0000000000..712e7d2646 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSReferenceBindingExtension.h @@ -0,0 +1,76 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_extension_ws_wsreferencebindingextension_h +#define tuscany_sca_extension_ws_wsreferencebindingextension_h + +#include "tuscany/sca/extension/ReferenceBindingExtension.h" + +namespace tuscany +{ + namespace sca + { + namespace ws + { + + class WSReferenceBindingExtension : public ReferenceBindingExtension + { + public: + /** + * Default constructor + */ + WSReferenceBindingExtension(); + + /** + * Destructor + */ + virtual ~WSReferenceBindingExtension(); + + /** + * return the name of the extension + */ + virtual const std::string& getExtensionName() {return extensionName;} + + /** + * return the QName of schema elemant for this implementation extension + * (e.g. "http://www.osoa.org/xmlns/sca/1.0#binding.ws") + */ + virtual const std::string& getExtensionTypeQName() {return typeQName;} + + virtual tuscany::sca::model::ReferenceBinding* getReferenceBinding( + tuscany::sca::model::Composite* composite, + tuscany::sca::model::Reference *reference, commonj::sdo::DataObjectPtr scdlBinding); + + static void initialize(); + + private: + static const std::string extensionName; + static const std::string typeQName; + + }; + + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_extension_ws_wsreferencebindingextension_h + diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp new file mode 100644 index 0000000000..bea4168984 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp @@ -0,0 +1,579 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#include + +#include "commonj/sdo/SDO.h" + +#include "WSServiceProxy.h" +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/core/Exceptions.h" +#include "tuscany/sca/util/Utils.h" +#include "tuscany/sca/util/SDOUtils.h" +#include "tuscany/sca/core/SCARuntime.h" +#include "tuscany/sca/model/Reference.h" +#include "tuscany/sca/model/ReferenceType.h" +#include "tuscany/sca/model/Service.h" +#include "tuscany/sca/model/ServiceType.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/ComponentType.h" +#include "tuscany/sca/core/ServiceWrapper.h" +#include "tuscany/sca/model/Composite.h" +#include "tuscany/sca/model/ServiceBinding.h" +#include "tuscany/sca/model/WSDLDefinition.h" +#include "tuscany/sca/model/WSDLInterface.h" +#include "tuscany/sca/model/WSDLOperation.h" +#include "model/WSReferenceBinding.h" + +using namespace std; +using namespace commonj::sdo; +using namespace tuscany::sca::model; +using namespace tuscany::sca::util; + +namespace tuscany +{ + namespace sca + { + namespace ws + { + + // ============================ + // Constructor: Create a proxy + // ============================ + WSServiceProxy::WSServiceProxy(Reference* reference) + : ServiceProxy(reference) + { + logentry(); + + // Get the target service wrapper + WSReferenceBinding* referenceBinding = (WSReferenceBinding*)reference->getBinding(); + serviceWrapper = referenceBinding->getTargetServiceBinding()->getServiceWrapper(); + + // Define the SOAP Body type and element to allow a SOAP body to + // be loaded in a DataObject + DataFactoryPtr dataFactory = reference->getComponent()->getComposite()->getDataFactory(); + try { + const Type& bodyType = dataFactory->getType("http://www.w3.org/2003/05/soap-envelope", "Body"); + } catch (SDORuntimeException&) + { + + // Define the SOAP 1.2 Body type + dataFactory->addType("http://www.w3.org/2003/05/soap-envelope", "RootType", false, false, false); + dataFactory->addType("http://www.w3.org/2003/05/soap-envelope", "Body", false, true, false); + dataFactory->addPropertyToType( + "http://www.w3.org/2003/05/soap-envelope", "RootType", + "Body", + "http://www.w3.org/2003/05/soap-envelope", "Body", + false, false, true); + + // Define the SOAP 1.1 Body type + dataFactory->addType("http://schemas.xmlsoap.org/soap/envelope/", "RootType", false, false, false); + dataFactory->addType("http://schemas.xmlsoap.org/soap/envelope/", "Body", false, true, false); + dataFactory->addPropertyToType( + "http://schemas.xmlsoap.org/soap/envelope/", "RootType", + "Body", + "http://schemas.xmlsoap.org/soap/envelope/", "Body", + false, false, true); + } + + try { + const Type& tempType = dataFactory->getType("http://tempuri.org", "RootType"); + } catch (SDORuntimeException&) + { + dataFactory->addType("http://tempuri.org", "RootType", false, false, false); + dataFactory->addType("http://tempuri.org", "Wrapper", false, true, false); + dataFactory->addPropertyToType( + "http://tempuri.org", "RootType", + "Wrapper", + "http://tempuri.org", "Wrapper", + false, false, true); + dataFactory->addType("http://tempuri.org", "Part", false, true, false); + dataFactory->addPropertyToType( + "http://tempuri.org", "RootType", + "Part", + "http://tempuri.org", "Part", + false, false, true); + } + } + + // ========== + // Destructor + // ========== + WSServiceProxy::~WSServiceProxy() + { + logentry(); + } + + /// + /// This method will be called to process an operation invocation. + /// + DataObjectPtr WSServiceProxy::invoke(const WSDLOperation& wsdlOperation, DataObjectPtr inputDataObject) + { + logentry(); + + Reference* reference = getReference(); + Component* component = reference->getComponent(); + Composite* composite = component ->getComposite(); + + WSReferenceBinding* referenceBinding = (WSReferenceBinding*)reference->getBinding(); + DataFactoryPtr dataFactoryPtr = reference->getComponent()->getComposite()->getDataFactory(); + + // Since its Document wrapped, there will only be one message part + std::list partList = wsdlOperation.getOutputMessagePartNames(); + const WSDLMessagePart &part = wsdlOperation.getOutputMessagePart(partList.front()); + const char* outputTypeURI = part.getPartUri().c_str(); + const char* outputTypeName = part.getPartName().c_str(); + + loginfo("WSDLOperation input message Type: %s#%s", + wsdlOperation.getInputMessageUri().c_str(), + wsdlOperation.getInputMessageName().c_str()); + loginfo("WSDLOperation outputType: %s#%s", + outputTypeURI, + outputTypeName); + + try + { + + // Create new Operation object and set parameters and return value + Operation operation(wsdlOperation.getOperationName().c_str()); + + // Go through the input data object to set the operation parameters + PropertyList pl = inputDataObject->getInstanceProperties(); + + for(unsigned int i=0; igetBoolean(pl[i]); + operation.addParameter(boolData); + } + break; + case Type::ByteType: + { + char* byteData = new char; + *byteData = inputDataObject->getByte(pl[i]); + operation.addParameter(byteData); + } + break; + case Type::BytesType: + { + int len = inputDataObject->getLength(pl[i]); + char** bytesData = new char*; + *bytesData = new char[len+1]; + int bytesWritten = inputDataObject->getBytes(pl[i], *bytesData, len); + // Ensure the bytes end with the null char. Not sure if this is neccessary + if(bytesWritten <= len) + { + (*bytesData)[bytesWritten] = 0; + } + else + { + (*bytesData)[len] = 0; + } + operation.addParameter(bytesData); + } + break; + case Type::CharacterType: + { + // This code should work but won't be used as there is no mapping from an XSD type to the SDO CharacterType + wchar_t* charData = new wchar_t; + *charData = inputDataObject->getCharacter(pl[i]); + operation.addParameter(charData); + } + break; + case Type::DoubleType: + { + long double* doubleData = new long double; + *doubleData = inputDataObject->getDouble(pl[i]); + operation.addParameter(doubleData); + } + break; + case Type::FloatType: + { + float* floatData = new float; + *floatData = inputDataObject->getFloat(pl[i]); + operation.addParameter(floatData); + } + break; + case Type::IntType: + { + long* intData = new long; + *intData = inputDataObject->getInt(pl[i]); + operation.addParameter(intData); + } + break; + case Type::ShortType: + { + short* shortData = new short; + *shortData = inputDataObject->getShort(pl[i]); + operation.addParameter(shortData); + } + break; + case Type::StringType: + { + string* stringData; + if(inputDataObject->isSet(pl[i])) + { + stringData = new string(inputDataObject->getCString(pl[i])); + } + else + { + // The data is not set, so pass an empty string as the parameter + stringData = new string(); + } + operation.addParameter(stringData); + } + break; + case Type::DataObjectType: + { + if (!strcmp(pl[i].getType().getURI(), SDOUtils::sdoURI) && + !strcmp(pl[i].getType().getName(), "OpenDataObject")) { + + /* + * This code deals with xsd:any element parameters + * Get each element as a DataObject and add in to the parameter list + */ + + DataObjectList& dataObjectList = inputDataObject->getList(pl[i]); + + for(unsigned int j=0; jgetSequence(); + if (sequence->size()!=0) + { + // Add a text element + if (sequence->isText(0)) + { + string* stringData = new string(sequence->getCStringValue(0)); + operation.addParameter(stringData); + } + else + { + // Add a complex element DataObject + DataObjectPtr* dataObjectData = new DataObjectPtr; + *dataObjectData = sequence->getDataObjectValue(0); + if(!*dataObjectData) + { + loginfo("Null DataObject parameter named %s", name); + } + else + { + (*dataObjectData)->detach(); + } + operation.addParameter(dataObjectData); + } + } + else + { + // Empty content, add an empty string + loginfo("Empty OpenDataObject parameter named %s[%d]", name, j); + string* stringData = new string(""); + operation.addParameter(stringData); + } + } + } + } + else { + DataObjectPtr* dataObjectData = new DataObjectPtr; + *dataObjectData = inputDataObject->getDataObject(pl[i]); + if(!*dataObjectData) + { + loginfo("Null DataObject parameter named %s", name); + } + else + { + (*dataObjectData)->detach(); + } + operation.addParameter(dataObjectData); + } + } + break; + default: + { + ostringstream msg; + msg << "Unsupported param type: " << pl[i].getTypeEnum(); + throwException(SystemConfigurationException, msg.str().c_str()); + } + } + } + + // Call into the target service wrapper + serviceWrapper->invoke(operation); + + // Set the data in the outputDataObject to be returned + DataObjectPtr outputDataObject; + try + { + // Create the output wrapper + const Type& rootType = dataFactoryPtr->getType(outputTypeURI, "RootType"); + const Property& prop = rootType.getProperty(outputTypeName); + const Type& outputType = prop.getType(); + outputDataObject = dataFactoryPtr->create(outputType); + } + catch (SDORuntimeException&) + { + try + { + // Create the output wrapper + const Type& outputType = dataFactoryPtr->getType(outputTypeURI, outputTypeName); + outputDataObject = dataFactoryPtr->create(outputType); + } + catch (SDORuntimeException&) + { + // The output wrapper type is not known, create an open DataObject + //outputDataObject = dataFactoryPtr->create("http://tempuri.org", "Wrapper"); + outputDataObject = dataFactoryPtr->create(SDOUtils::sdoURI, "OpenDataObject"); + } + } + + setOutputData(operation, outputDataObject, dataFactoryPtr); + + return outputDataObject; + + } + catch(SDORuntimeException& ex) + { + throwException(ServiceInvocationException, ex); + } + catch(TuscanyRuntimeException&) + { + throw; + } + } + + + void WSServiceProxy::setOutputData(Operation& operation, DataObjectPtr outputDataObject, DataFactoryPtr dataFactoryPtr) + { + logentry(); + + // Go through data object to set the return value + PropertyList pl = outputDataObject->getType().getProperties(); + + if(pl.size() == 0) + { + if(outputDataObject->getType().isOpenType() && outputDataObject->getType().isDataObjectType()) + { + /* + * This code deals with returning xsd:any elements + */ + DataObjectList& l = outputDataObject->getList("return"); + Operation::ParameterType resultType = operation.getReturnType(); + switch(resultType) + { + case Operation::BOOL: + { + l.append(*(bool*)operation.getReturnValue()); + break; + } + case Operation::SHORT: + { + l.append(*(short*)operation.getReturnValue()); + break; + } + case Operation::INT: + { + l.append(*(long*)operation.getReturnValue()); + break; + } + case Operation::LONG: + { + l.append(*(long*)operation.getReturnValue()); + break; + } + case Operation::USHORT: + { + l.append(*(short*)operation.getReturnValue()); + break; + } + case Operation::UINT: + { + l.append(*(long*)operation.getReturnValue()); + break; + } + case Operation::ULONG: + { + l.append(*(long*)operation.getReturnValue()); + break; + } + case Operation::FLOAT: + { + l.append(*(float*)operation.getReturnValue()); + break; + } + case Operation::DOUBLE: + { + l.append(*(long double*)operation.getReturnValue()); + break; + } + case Operation::LONGDOUBLE: + { + l.append(*(long double*)operation.getReturnValue()); + break; + } + case Operation::CHARS: + { + l.append(*(char**)operation.getReturnValue()); + break; + } + case Operation::STRING: + { + l.append((*(string*)operation.getReturnValue()).c_str()); + break; + } + case Operation::DATAOBJECT: + { + l.append(*(DataObjectPtr*)operation.getReturnValue()); + break; + } + default: + { + // One way operation, no return value + break; + } + } + } + else + { + loginfo("No return values defined"); + } + } + else { + + // Should only be one return value.. This goes through all return values + for(unsigned int i=0; isetBoolean(pl[i], *(bool*)operation.getReturnValue()); + break; + } + case Operation::SHORT: + { + outputDataObject->setShort(pl[i], *(short*)operation.getReturnValue()); + break; + } + case Operation::INT: + { + outputDataObject->setInt(pl[i], *(int*)operation.getReturnValue()); + break; + } + case Operation::LONG: + { + outputDataObject->setInt(pl[i], *(long*)operation.getReturnValue()); + break; + } + case Operation::USHORT: + { + outputDataObject->setInt(pl[i], *(unsigned short*)operation.getReturnValue()); + break; + } + case Operation::UINT: + { + outputDataObject->setInt(pl[i], *(unsigned int*)operation.getReturnValue()); + break; + } + case Operation::ULONG: + { + outputDataObject->setInt(pl[i], *(unsigned long*)operation.getReturnValue()); + break; + } + case Operation::FLOAT: + { + outputDataObject->setFloat(pl[i], *(float*)operation.getReturnValue()); + break; + } + case Operation::DOUBLE: + { + outputDataObject->setDouble(pl[i], *(double*)operation.getReturnValue()); + break; + } + case Operation::LONGDOUBLE: + { + outputDataObject->setDouble(pl[i], *(long double*)operation.getReturnValue()); + break; + } + case Operation::CHARS: + { + if(*(char**)operation.getReturnValue() != NULL) + { + outputDataObject->setCString(pl[i], *(char**)operation.getReturnValue()); + } + else + { + loginfo("Null return value, leaving property %s unset", pl[i].getName()); + } + break; + } + case Operation::STRING: + { + outputDataObject->setCString(pl[i], (*(string*)operation.getReturnValue()).c_str()); + break; + } + case Operation::DATAOBJECT: + { + + if(*(DataObjectPtr*)operation.getReturnValue() != NULL) + { + outputDataObject->setDataObject(pl[i], *(DataObjectPtr*)operation.getReturnValue()); + } + else + { + loginfo("Null return value, leaving property %s unset", pl[i].getName()); + } + + break; + } + default: + { + // One way operation, no return value + break; + } + } + } + } + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.h new file mode 100644 index 0000000000..4d57514688 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.h @@ -0,0 +1,95 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_extension_ws_wsserviceproxy_h +#define tuscany_sca_extension_ws_wsserviceproxy_h + +#include "commonj/sdo/SDO.h" + +#include "tuscany/sca/core/ServiceProxy.h" +#include "tuscany/sca/core/ServiceWrapper.h" +#include "tuscany/sca/model/Component.h" +#include "tuscany/sca/model/Reference.h" +#include "tuscany/sca/model/Service.h" +#include "tuscany/sca/model/WSDLOperation.h" +#include "model/WSReferenceBinding.h" + + +namespace tuscany +{ + namespace sca + { + namespace ws + { + + /** + * Holds a proxy for a given component and reference. + * The proxy which is held inside a ServiceProxy will be specific to the programming + * interface expected by the client. In this particular case the client is an Axis2 + * Web service skeleton. + */ + class WSServiceProxy : public ServiceProxy + { + public: + /** + * Create a new service proxy for a reference. The proxy will contain a pointer to + * the target ServiceWrapper. + * @param reference The reference on the source component. + * @param target The wrapper of the service which is wired to this reference. + */ + WSServiceProxy(tuscany::sca::model::Reference* reference); + + /** + * Create a new service proxy for a service. The proxy will contain a pointer to + * the target ServiceWrapper. + * @param reference The service on the target component. + * @param target The wrapper of the target service. + */ + WSServiceProxy(tuscany::sca::model::Service* service); + + /** + * Destructor. + */ + virtual ~WSServiceProxy(); + + /** + * Invoke the specified operation + */ + commonj::sdo::DataObjectPtr invoke(const tuscany::sca::model::WSDLOperation& wsdlOperation, + commonj::sdo::DataObjectPtr inputDataObject); + + private: + + void setOutputData(Operation& operation, + commonj::sdo::DataObjectPtr outputDataObject, commonj::sdo::DataFactoryPtr dataFactoryPtr); + + /** + * The target service wrapper + */ + ServiceWrapper* serviceWrapper; + + }; + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_extension_ws_wsserviceproxy_h diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/export.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/export.h new file mode 100644 index 0000000000..e52adf4db0 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/export.h @@ -0,0 +1,38 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_ws_service_export_h +#define tuscany_sca_ws_service_export_h + +#if defined(WIN32) || defined (_WINDOWS) +#pragma warning(disable: 4786) + +#ifdef TUSCANY_SCA_WS_SERVICE_EXPORTS +#define SCA_WS_SERVICE_API __declspec(dllexport) +#else +#define SCA_WS_SERVICE_API __declspec(dllimport) +#endif + +#else +#define SCA_WS_SERVICE_API +#endif + +#endif // tuscany_sca_ws_service_export_h diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.cpp b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.cpp new file mode 100644 index 0000000000..4f170ebf52 --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.cpp @@ -0,0 +1,151 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#include "tuscany/sca/util/Logging.h" +#include "tuscany/sca/ws/model/WSReferenceBinding.h" +#include "tuscany/sca/core/ServiceProxy.h" +#include "tuscany/sca/ws/WSServiceProxy.h" + +using namespace std; +using namespace tuscany::sca::model; + +namespace tuscany +{ + namespace sca + { + namespace ws + { + + // Constructor + WSReferenceBinding::WSReferenceBinding(Reference* reference, const string& uri, const string& endpoint, const string&version) + : ReferenceBinding(reference, uri), endpoint(endpoint), soapVersion(version) + { + logentry(); + + parseEndpoint(); + } + + void WSReferenceBinding::parseEndpoint() + { + logentry(); + + // Endpoint is of the form: #wsdl.endpoint(/) + string::size_type hash = endpoint.find("#"); + if (hash != string::npos) + { + // Found a hash + + // Namepace is the part before the # + wsdlNamespaceURL = endpoint.substr(0, hash); + + + if ( (hash+1) < endpoint.length()) + { + // Check the next part is wsdl.endpoint( + int ending = hash+15; + string check = endpoint.substr(hash+1, 14); + if (check.compare("wsdl.endpoint(") == 0) + { + // Find the matching ) + int endBracket = endpoint.find(")",ending); + if (endBracket-1 > ending+1) + { + string serviceAndEndpoint = endpoint.substr(ending, endBracket-ending); + // Look for a '/' + string::size_type slash = serviceAndEndpoint.find("/"); + if (slash != string::npos) + { + serviceName = serviceAndEndpoint.substr(0, slash); + + if ( (slash+1) < serviceAndEndpoint.length()) + { + endpointName = serviceAndEndpoint.substr(slash+1); + } + else + { + endpointName = ""; + } + + } + else + { + // No '/' so all of it is the service name + serviceName = serviceAndEndpoint; + endpointName = ""; + + } + } + else + { + // Nothing between the () + serviceName = ""; + endpointName = ""; + } + } + else + { + // not the correct characters after the #, ignore the rest + serviceName = ""; + endpointName = ""; + } + + } + else + { + // Nothing after the hash + serviceName = ""; + endpointName = ""; + } + } + else + { + // No hash at all + wsdlNamespaceURL = endpoint; + serviceName = ""; + endpointName = ""; + } + } + + // Destructor + WSReferenceBinding::~WSReferenceBinding() + { + logentry(); + } + + void WSReferenceBinding::configure(ServiceBinding *binding) + { + logentry(); + + setTargetServiceBinding(binding); + + serviceProxy = new WSServiceProxy(getReference()); + } + + ServiceProxy* WSReferenceBinding::getServiceProxy() + { + logentry(); + + return serviceProxy; + } + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany diff --git a/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.h b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.h new file mode 100644 index 0000000000..14f17dbc3c --- /dev/null +++ b/sca-cpp/branches/cpp-contrib/contrib/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/model/WSReferenceBinding.h @@ -0,0 +1,143 @@ +/* + * 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. + */ + +/* $Rev$ $Date$ */ + +#ifndef tuscany_sca_extension_ws_model_wsreferencebinding_h +#define tuscany_sca_extension_ws_model_wsreferencebinding_h + +#include + +#include "tuscany/sca/ws/export.h" +#include "tuscany/sca/model/ReferenceBinding.h" + + +namespace tuscany +{ + namespace sca + { + namespace ws + { + /** + * Information about a web service binding for service or a reference. + */ + class WSReferenceBinding : public tuscany::sca::model::ReferenceBinding + { + public: + + /** + * Constructor. + * @param uri The uri of the binding. + * @param endpoint The definition of the endpoint to which the entrypoint + * or external service is to be bound. This is of the form + * "namespace"#endpoint("service"/"endpoint") + */ + SCA_WS_SERVICE_API WSReferenceBinding(tuscany::sca::model::Reference* reference, + const std::string&uri, const std::string& endpoint, const std::string& version); + + /** + * Destructor. + */ + SCA_WS_SERVICE_API virtual ~WSReferenceBinding(); + + /** + * Returns the type of binding. + */ + virtual std::string getType() { return "http://www.osoa.org/xmlns/sca/1.0#WebServiceBinding"; }; + + /** + * Configure this binding from a service binding. + */ + SCA_WS_SERVICE_API virtual void configure(tuscany::sca::model::ServiceBinding* serviceBinding); + + /** + * Create a proxy representing the reference to the + * client component. + */ + SCA_WS_SERVICE_API virtual ServiceProxy* getServiceProxy(); + + /** + * Return the part of the endpoint definition describing the wsdl + * namespace. + * @return The wsdl namespace. + */ + std::string getWSDLNamespaceURL() const { return wsdlNamespaceURL; }; + + /** + * Return the service part of the endpoint definition. + * @return The service to use. + */ + std::string getServiceName() const { return serviceName; }; + + /** + * Return the endpoint name part of the endpoint definition. + * @return The endpoint name to use. + */ + std::string getEndpointName() const { return endpointName; }; + + /** + * Return the SOAP version. + * @return The SOAP version to use. + */ + std::string getSOAPVersion() const { return soapVersion; }; + + private: + + /** + * Parse the endpoint specification. + */ + void parseEndpoint(); + + /** + * The full endpoint string. + */ + std::string endpoint; + + /** + * Namespace from the endpoint. + */ + std::string wsdlNamespaceURL; + + /** + * Service name from the endpoint. + */ + std::string serviceName; + + /** + * Endpoint name from the endpoint. + */ + std::string endpointName; + + /** + * SOAP version. + */ + std::string soapVersion; + + /** + * The proxy representing the reference to the client + * component. + */ + ServiceProxy* serviceProxy; + }; + + } // End namespace ws + } // End namespace sca +} // End namespace tuscany + +#endif // tuscany_sca_extension_ws_model_wsreferencebinding_h -- cgit v1.2.3