diff options
author | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
---|---|---|
committer | dims <dims@13f79535-47bb-0310-9956-ffa450edef68> | 2008-06-17 00:23:01 +0000 |
commit | bdd0a41aed7edf21ec2a65cfa17a86af2ef8c48a (patch) | |
tree | 38a92061c0793434c4be189f1d70c3458b6bc41d /tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper |
Move Tuscany from Incubator to top level.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@668359 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper')
8 files changed, 461 insertions, 0 deletions
diff --git a/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/Makefile.am b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/Makefile.am new file mode 100644 index 0000000000..af437a64d6 --- /dev/null +++ b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/.cdtbuild b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/.cdtbuild new file mode 100644 index 0000000000..cad284f534 --- /dev/null +++ b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/.cdtbuild @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?fileVersion 3.0.0?> + +<ManagedProjectBuildInfo> +<project id="tuscany_sca_axis_wrapper.cdt.managedbuild.target.gnu.so.1184841924" name="Shared Library (Gnu)" projectType="cdt.managedbuild.target.gnu.so"> +<configuration artifactExtension="so" artifactName="tuscany_sca_axis_wrapper" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.config.gnu.so.debug.928824798" name="Debug" parent="cdt.managedbuild.config.gnu.so.debug"> +<toolChain id="cdt.managedbuild.toolchain.gnu.so.debug.1339758042" name="GCC Tool Chain" superClass="cdt.managedbuild.toolchain.gnu.so.debug"> +<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.compiler.so.debug.1154109611" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.so.debug"/> +<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug.1608382279" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.debug"> +<option id="gnu.cpp.compiler.option.preprocessor.def.1011501225" superClass="gnu.cpp.compiler.option.preprocessor.def" valueType="definedSymbols"> +<listOptionValue builtIn="false" value="_DEBUG"/> +</option> +<option id="gnu.cpp.compiler.option.include.paths.1415031933" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> +<listOptionValue builtIn="false" value="${project_loc}/../../../core/src"/> +<listOptionValue builtIn="false" value="${TUSCANY_SDOCPP}/include"/> +<listOptionValue builtIn="false" value="${AXISCPP_DEPLOY}/include"/> +</option> +</tool> +<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.linker.so.debug.1838165705" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.so.debug"/> +<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.linker.so.debug.967811729" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.so.debug"/> +<tool command="as" id="cdt.managedbuild.tool.gnu.assembler.so.debug.182811061" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.so.debug"/> +<macros/> +</toolChain> +</configuration> +<configuration artifactExtension="so" artifactName="tuscany_sca_axis_wrapper" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.GASErrorParser" id="cdt.managedbuild.config.gnu.so.release.417732635" name="Release" parent="cdt.managedbuild.config.gnu.so.release"> +<toolChain id="cdt.managedbuild.toolchain.gnu.so.release.2030957057" name="GCC Tool Chain" superClass="cdt.managedbuild.toolchain.gnu.so.release"> +<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.compiler.so.release.1306716781" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.so.release"/> +<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.compiler.so.release.1788615220" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.so.release"> +<option id="gnu.cpp.compiler.option.include.paths.425019187" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath"> +<listOptionValue builtIn="false" value="${project_loc}/../../../core/src"/> +<listOptionValue builtIn="false" value="${TUSCANY_SDOCPP}/include"/> +<listOptionValue builtIn="false" value="${AXISCPP_DEPLOY}/include"/> +</option> +</tool> +<tool command="gcc" id="cdt.managedbuild.tool.gnu.c.linker.so.release.1895133278" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.so.release"/> +<tool command="g++" id="cdt.managedbuild.tool.gnu.cpp.linker.so.release.279322021" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.so.release"/> +<tool command="as" id="cdt.managedbuild.tool.gnu.assembler.so.release.774676807" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.so.release"/> +<macros/> +</toolChain> +</configuration> +<macros/> +</project> +</ManagedProjectBuildInfo> diff --git a/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/.cdtproject b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/.cdtproject new file mode 100644 index 0000000000..48a12e6664 --- /dev/null +++ b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/.cdtproject @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse-cdt version="2.0"?>
+
+<cdtproject id="org.eclipse.cdt.managedbuilder.core.managedMake">
+<extension id="org.eclipse.cdt.managedbuilder.core.ManagedBuildManager" point="org.eclipse.cdt.core.ScannerInfoProvider"/>
+<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
+<extension id="org.eclipse.cdt.core.domsourceindexer" point="org.eclipse.cdt.core.CIndexer"/>
+<data>
+<item id="org.eclipse.cdt.core.pathentry">
+<pathentry kind="src" path=""/>
+<pathentry kind="out" path=""/>
+<pathentry kind="con" path="org.eclipse.cdt.managedbuilder.MANAGED_CONTAINER"/>
+</item>
+</data>
+</cdtproject>
diff --git a/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/.project b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/.project new file mode 100644 index 0000000000..526e05b5c0 --- /dev/null +++ b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/.project @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>tuscany_sca_axis_wrapper</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.cdt.core.cnature</nature> + <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature> + <nature>org.eclipse.cdt.core.ccnature</nature> + </natures> +</projectDescription> diff --git a/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/.settings/org.eclipse.cdt.managedbuilder.core.prefs new file mode 100644 index 0000000000..263f7d68d6 --- /dev/null +++ b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/.settings/org.eclipse.cdt.managedbuilder.core.prefs @@ -0,0 +1,9 @@ +#Thu Feb 16 14:46:12 GMT 2006 +eclipse.preferences.version=1 +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.so.debug.928824798=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n +environment/buildEnvironmentInclude/cdt.managedbuild.config.gnu.so.release.417732635=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="CPATH" operation\="remove"/>\n<variable name\="CPLUS_INCLUDE_PATH" operation\="remove"/>\n</environment>\n +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.so.debug.928824798=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="LIBRARY_PATH" operation\="remove"/>\n</environment>\n +environment/buildEnvironmentLibrary/cdt.managedbuild.config.gnu.so.release.417732635=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable name\="LIBRARY_PATH" operation\="remove"/>\n</environment>\n +environment/project=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment/>\n +environment/project/cdt.managedbuild.config.gnu.so.debug.928824798=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable delimiter\="" name\="TUSCANY_SDOCPP" operation\="replace" value\="/home/tuscany/workspace/sdo"/>\n</environment>\n +environment/project/cdt.managedbuild.config.gnu.so.release.417732635=<?xml version\="1.0" encoding\="UTF-8"?>\n<environment>\n<variable delimiter\="" name\="TUSCANY_SDOCPP" operation\="replace" value\="/home/tuscany/workspace/sdo"/>\n</environment>\n diff --git a/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/Makefile.am b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/Makefile.am new file mode 100644 index 0000000000..f3dda31d1c --- /dev/null +++ b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/Makefile.am @@ -0,0 +1,10 @@ +lib_LTLIBRARIES = libtuscany_sca_axis_wrapper.la + +libtuscany_sca_axis_wrapper_la_SOURCES = SCAWSWrapper.cpp + +libtuscany_sca_axis_wrapper_la_LIBADD = -lstdc++ -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo + +INCLUDES = -I$(top_builddir)/runtime/core/src \ + -I${TUSCANY_SDOCPP}/include \ + -I${AXISCPP_DEPLOY}/include + diff --git a/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/SCAWSWrapper.cpp b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/SCAWSWrapper.cpp new file mode 100644 index 0000000000..1ae9739117 --- /dev/null +++ b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/SCAWSWrapper.cpp @@ -0,0 +1,254 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#include "SCAWSWrapper.h" + +#include "commonj/sdo/SDO.h" +#include "tuscany/sca/util/Exceptions.h" +#include "tuscany/sca/core/SCAEntryPoint.h" + + +using namespace std; +using namespace commonj::sdo; +using namespace tuscany::sca; +AXIS_CPP_NAMESPACE_USE; + +/** Construct an SCAWSWrapper. + */ +SCAWSWrapper::SCAWSWrapper() +{ +} + +/** Destruct an SCAWSWrapper. + */ +SCAWSWrapper::~SCAWSWrapper() +{ +} + + +// +// Implementation of WrapperClassHandler interface +// + +/** Perform any necessary initialization. + */ +int SCAWSWrapper::init() +{ + return AXIS_SUCCESS; +} + +/** Perform an necessary finalization. + */ +int SCAWSWrapper::fini() +{ + return AXIS_SUCCESS; +} + +/** Invoke a web service operation. The invoke method expects SCA specific + * properties to have been set into the MessageData by the SCAWSHandler. + * Using those properties, the wrapper will invoke the correct SCA Entry + * Point. + * @param pMsg - pointer to IMessageData. + * + * @see SCAWSHandler + */ +int SCAWSWrapper::invoke(void *pMsg) +{ + + IMessageData *pIMsg = (IMessageData*)pMsg; + const AxisChar *operationName = pIMsg->getOperationName(); + + int axisReturn = invokeService(pIMsg, operationName); + return axisReturn; +} + +/** Handle Faults. + */ +void SCAWSWrapper::onFault(void *pMsg) +{ +} + + +// Invoke an operation on an SCA Entry Point. +int SCAWSWrapper::invokeService(IMessageData *pIMsg, + const AxisChar *operationName) +{ + int axisReturn = AXIS_SUCCESS; + + // Get the SoapSerializer. + IWrapperSoapSerializer* pIWSSZ; + pIMsg->getSoapSerializer(&pIWSSZ); + if (!pIWSSZ) + { + return AXIS_FAIL; + } + + // Get the SoapDeSerializer. + IWrapperSoapDeSerializer* pIWSDZ; + pIMsg->getSoapDeSerializer(&pIWSDZ); + if (!pIWSDZ) + { + return AXIS_FAIL; + } + + // Target Namespace was set into the MessageData by the SCAWSHandler. + const AxisChar *targetNamespace = (const AxisChar *)pIMsg->getProperty("targetNamespace"); + + // Make sure we have the correct message. + if (AXIS_SUCCESS != pIWSDZ->checkMessageBody(operationName, targetNamespace)) + { + return AXIS_FAIL; + } + + try + { + // + // Create the SCA EntryPoint + // + const AxisChar *scaEntryPointName = (const AxisChar *)pIMsg->getProperty("scaEntryPoint"); + SCAEntryPoint entrypoint(scaEntryPointName); + + // Get the DataFactory which has Types loaded from WSDLs + DataFactoryPtr dataFactory = entrypoint.getDataFactory(); + + // + // Get the Soap body and create an SDO request object from it. + // + AnyType *soapAny = pIWSDZ->getAnyObject(); + + // The Doc Literal soap message does not include the root element (operation name) when + // we use getAnyObject. Axis calls this element the 'soap method' but there is no + // 'getSoapMethod' method on the deserializer - we need to wrap the soap body with an + // element named for the operation name. + + string soapBody("<"); + soapBody.append(operationName); + soapBody.append(" "); + soapBody.append("xmlns"); + soapBody.append("=\""); + soapBody.append(targetNamespace); + soapBody.append("\">"); + for (int i=0; i < soapAny->_size ; i++) + { + // The soap body is stored in the _array member of AnyType. + soapBody.append(soapAny->_array[i]); + } + soapBody.append("</"); + soapBody.append(operationName); + soapBody.append(">"); + + // + // Create the SDO request object from the soap body. + // + XMLHelperPtr xmlHelper = HelperProvider::getXMLHelper(dataFactory); + XMLDocumentPtr xmlDoc = xmlHelper->load(soapBody.c_str(), targetNamespace); + DataObjectPtr requestSDO = xmlDoc->getRootDataObject(); + + // + // Invoke the operation on the SCA EntryPoint. + // + DataObjectPtr responseSDO = entrypoint.invoke(operationName, requestSDO); + + // + // Serialize the responseSDO into a SOAP response. + // + // Get the name of the response SDO. The entry point was invoked using an + // SDOStub and the stub makes sure that the response includes the root + // element (operation response name). + + const Type &responseType = responseSDO->getType(); + const char *operationResponseName = responseType.getName(); + + // Get the first child of the root element - this is the soap body + // to return in the response. The body will be wrapped with the root + // element (operation response name) when we call the Axis method + // 'createSoapmMethod'. + DataObjectPtr soapBodySDO = responseSDO->getDataObject((unsigned int)0); + const Type& soapBodyType = soapBodySDO->getType(); + const char *soapBodyName = soapBodyType.getName(); + // Convert the soap body DataObject into XML. + XMLDocumentPtr responseDoc = xmlHelper->createDocument(soapBodySDO, + targetNamespace, + soapBodyName); + responseDoc->setXMLDeclaration(false); + char *responseXML = xmlHelper->save(responseDoc); + + // + // Serialize the response + // + // Wrap the soap body with the root element (operation response name). + pIWSSZ->createSoapMethod(operationResponseName, targetNamespace); + // Add the XML response document (soap body) as an AnyType. + AnyType *soapAnyResponse = new AnyType(); + soapAnyResponse->_size = 1; + soapAnyResponse->_array = new char*[1]; + soapAnyResponse->_array[0] = strdup(responseXML); + + pIWSSZ->addOutputAnyObject(soapAnyResponse); + + } + catch(ServiceRuntimeException e) + { + axisReturn = AXIS_FAIL; + } + catch(SDORuntimeException e) + { + axisReturn = AXIS_FAIL; + } + + + return axisReturn; +} + +// +// These functions are exported from the SCAWSWrapper DLL and are called by the Axis Engine +// to create/destroy instances of the service wrapper class. +// +extern "C" +{ +STORAGE_CLASS_INFO +int GetClassInstance(BasicHandler **inst) +{ + *inst = new BasicHandler(); + WrapperClassHandler* pWCH = new SCAWSWrapper(); + (*inst)->_functions = 0; + if (pWCH) + { + (*inst)->_object = pWCH; + return pWCH->init(); + } + return AXIS_FAIL; +} +STORAGE_CLASS_INFO +int DestroyInstance(BasicHandler *inst) +{ + if (inst) + { + WrapperClassHandler* pWCH = reinterpret_cast<WrapperClassHandler*>(inst); + pWCH->fini(); + delete pWCH; + delete inst; + return AXIS_SUCCESS; + } + return AXIS_FAIL; +} +} // extern "C" + + + diff --git a/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/SCAWSWrapper.h b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/SCAWSWrapper.h new file mode 100644 index 0000000000..474c39977f --- /dev/null +++ b/tags/cpp-stable-20060304/sca/runtime/axis_binding/wrapper/src/SCAWSWrapper.h @@ -0,0 +1,110 @@ +/* + * + * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* $Rev$ $Date: 2005/12/22 11:33:21 $ */ + +#if !defined(SCAWSWRAPPER_H_INCLUDED) +#define SCAWSWRAPPER_H_INCLUDED + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "osoa/sca/export.h" +#include <axis/server/WrapperClassHandler.hpp> +#include <axis/IMessageData.hpp> +#include <axis/GDefine.hpp> +#include <axis/AxisWrapperAPI.hpp> +#include <axis/AxisUserAPI.hpp> + + +AXIS_CPP_NAMESPACE_USE + +/** The SCAWSWrapper class is an Axis WrapperClassHandler that acts as a generic service wrapper for + * invoking services using the SCARuntime. Any services defined in the deployment descriptor (server.wsdd) + * with <parameter name="className" value="<path>\SCAWSWrapper.dll"/> will be invoked by the SCAWSWrapper. + * The service must also be configured with a handler (SCAWSHandler) that sets SCA specific properties + * from the deployment descriptor into the MessageData that is passed to the wrapper's invoke method. + * The SCAWSWrapper uses the properties to configure an SCA Entry Point and invoke the requested operation + * on the service. + * + * Example: + * + * <service name="ExampleService" provider="CPP:DOCUMENT" description="Example Service"> + * <requestFlow> + * <handler name="SCAWSHandler" type="C:\Apache2.0.54\Apache2\Axis\handlers\SCAWSHandler.dll"> + * <parameter name="targetNamespace" value="http://com.exampleservice"/> + * <parameter name="scaEntryPoint" value="SubSystem1/ExampleService/ExampleService"/> + * </handler> + * </requestFlow> + * + * <parameter name="className" value="C:\Apache2.0.54\Apache2\Axis\webservices\SCAWSWrapper.dll"/> + * <parameter name="allowedMethods" value="ExampleMethod "/> + * </service> + * + * @see SCAWSHandler + */ +class SCAWSWrapper : public WrapperClassHandler +{ + public: + + /** Construct an SCAWSWrapper. + */ + SCAWSWrapper(); + + /** Destruct an SCAWSWrapper. + */ + virtual ~SCAWSWrapper(); + + // + // Axis WrapperClassHandler interface. + // + + /** Perform any necessary initialization. + */ + int AXISCALL init(); + + /** Perform any necessary finalization. + */ + int AXISCALL fini(); + + /** Invoke a web service operation. The invoke method expects SCA specific + * properties to have been set into the MessageData by the SCAWSHandler. + * Using those properties, the wrapper will invoke the correct SCA Entry + * Point. + * @param pMsg - pointer to IMessageData. + * + * @see SCAWSHandler + */ + int AXISCALL invoke(void* pMsg); + + /** Handle Faults. + */ + void AXISCALL onFault(void* pMsg); + + /** Binding Style: Document Literal. + */ + AXIS_BINDING_STYLE AXISCALL getBindingStyle() { return DOC_LITERAL; }; + + private: + + // Invoke an SCA Entry Point and return an SDO object as a result. + int invokeService(IMessageData *pIMsg, + const AxisChar *operationName); +}; + +#endif // !defined(SCAWSWRAPPER_H_INCLUDED) |