diff options
Diffstat (limited to 'sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src')
9 files changed, 625 insertions, 0 deletions
diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/.cdtbuild b/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/.cdtbuild new file mode 100644 index 0000000000..cad284f534 --- /dev/null +++ b/sca-cpp/tags/cpp-sca-20060405/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/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/.cdtproject b/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/.cdtproject new file mode 100644 index 0000000000..48a12e6664 --- /dev/null +++ b/sca-cpp/tags/cpp-sca-20060405/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/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/.project b/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/.project new file mode 100644 index 0000000000..526e05b5c0 --- /dev/null +++ b/sca-cpp/tags/cpp-sca-20060405/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/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/.settings/org.eclipse.cdt.managedbuilder.core.prefs b/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/.settings/org.eclipse.cdt.managedbuilder.core.prefs new file mode 100644 index 0000000000..263f7d68d6 --- /dev/null +++ b/sca-cpp/tags/cpp-sca-20060405/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/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/AxisServiceException.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/AxisServiceException.cpp new file mode 100755 index 0000000000..d23689ad9d --- /dev/null +++ b/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/AxisServiceException.cpp @@ -0,0 +1,105 @@ +/* + * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws) + * This file contains implementations of the Exception class of the web service. + */ + +#include "AxisServiceException.h" + +#include <axis/AxisWrapperAPI.hpp> + +AxisServiceException::AxisServiceException() +{ +/* This only serves the purpose of indicating that the + * service has thrown an excpetion + */ + m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION; + processException(m_iExceptionCode); +} + +AxisServiceException::AxisServiceException(ISoapFault* pFault) +{ + m_iExceptionCode = AXISC_SERVICE_THROWN_EXCEPTION; + m_pISoapFault = pFault; + processException(pFault);} + +AxisServiceException::AxisServiceException(int iExceptionCode) +{ + + m_iExceptionCode = iExceptionCode; + processException (iExceptionCode); +} + +AxisServiceException::AxisServiceException(exception* e) +{ + processException (e); +} + +AxisServiceException::AxisServiceException(exception* e,int iExceptionCode) +{ + + processException (e, iExceptionCode); +} + +AxisServiceException::AxisServiceException(string sMessage) +{ + m_sMessage =sMessage; +} + +AxisServiceException::~AxisServiceException() throw () +{ + m_sMessage =""; +} + +void AxisServiceException:: processException(exception* e, int iExceptionCode) +{ + m_sMessage = getMessage (e) + getMessage (iExceptionCode); +} + +void AxisServiceException::processException (ISoapFault* pFault) +{ + /*User can do something like deserializing the struct into a string*/ +} + +void AxisServiceException::processException(exception* e) +{ + m_sMessage = getMessage (e); +} + +void AxisServiceException::processException(int iExceptionCode) +{ + m_sMessage = getMessage (iExceptionCode); +} + +const string AxisServiceException::getMessage (exception* objException) +{ + string sMessage = objException->what(); + return sMessage; +} + +const string AxisServiceException::getMessage (int iExceptionCode) +{ + string sMessage; + switch(iExceptionCode) + { + case AXISC_SERVICE_THROWN_EXCEPTION: + sMessage = "The service has thrown an exception. see details"; + break; + default: + sMessage = "Unknown Exception has occured in the service"; + } +return sMessage; +} + +const char* AxisServiceException::what() throw () +{ + return m_sMessage.c_str (); +} + +const int AxisServiceException::getExceptionCode(){ + return m_iExceptionCode; +} + +const ISoapFault* AxisServiceException::getFault(){ + return m_pISoapFault; +} + diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/AxisServiceException.h b/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/AxisServiceException.h new file mode 100755 index 0000000000..7684740b88 --- /dev/null +++ b/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/AxisServiceException.h @@ -0,0 +1,44 @@ +/* + * This file was auto-generated by the Axis C++ Web Service Generator (WSDL2Ws) + * This file contains an Exception class of the web service. + */ + +#if !defined(__AXISSERVICEEXCEPTION_EXCEPTION_H__INCLUDED_) +#define __AXISSERVICEEXCEPTION_EXCEPTION_H__INCLUDED_ + +#include <string> +#include <exception> +#include <axis/AxisException.hpp> +#include <axis/ISoapFault.hpp> + +using namespace std; +AXIS_CPP_NAMESPACE_USE + +class AxisServiceException: public AxisException +{ +public: + STORAGE_CLASS_INFO AxisServiceException(); + STORAGE_CLASS_INFO AxisServiceException(ISoapFault* pFault); + STORAGE_CLASS_INFO AxisServiceException(int iExceptionCode); + STORAGE_CLASS_INFO AxisServiceException(exception* e); + STORAGE_CLASS_INFO AxisServiceException(exception* e, int iExceptionCode); + STORAGE_CLASS_INFO AxisServiceException(string sMessage); + STORAGE_CLASS_INFO virtual ~AxisServiceException() throw(); + STORAGE_CLASS_INFO const char* what() throw(); + STORAGE_CLASS_INFO const int getExceptionCode(); + STORAGE_CLASS_INFO const string getMessage(exception* e); + STORAGE_CLASS_INFO const string getMessage(int iExceptionCode); + STORAGE_CLASS_INFO const ISoapFault* getFault(); + +private: + void processException(exception* e); + void processException(ISoapFault* pFault); + void processException(exception* e, int iExceptionCode); + void processException(int iExceptionCode); + string m_sMessage; + int m_iExceptionCode; + ISoapFault* m_pISoapFault; + +}; + +#endif /* !defined(__AXISSERVICEEXCEPTION_EXCEPTION_H__INCLUDED_)*/ diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/Makefile.am b/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/Makefile.am new file mode 100644 index 0000000000..ec6e6eccdf --- /dev/null +++ b/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/Makefile.am @@ -0,0 +1,12 @@ +lib_LTLIBRARIES = libtuscany_sca_axis_wrapper.la + +libtuscany_sca_axis_wrapper_la_SOURCES = SCAWSWrapper.cpp AxisServiceException.cpp + +libtuscany_sca_axis_wrapper_la_LIBADD = -L$(top_builddir)/runtime/core/src -ltuscany_sca \ + -L${TUSCANY_SDOCPP}/lib -ltuscany_sdo -lxml2 -lstdc++ \ + -L${AXISCPP_DEPLOY}/lib -laxis_client + +INCLUDES = -I$(top_builddir)/runtime/core/src \ + -I${TUSCANY_SDOCPP}/include \ + -I${AXISCPP_DEPLOY}/include + diff --git a/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/SCAWSWrapper.cpp b/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/SCAWSWrapper.cpp new file mode 100644 index 0000000000..57f3f40148 --- /dev/null +++ b/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/SCAWSWrapper.cpp @@ -0,0 +1,268 @@ +/* + * + * 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" + +#include "axis/GDefine.h" +#include "AxisServiceException.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) + { + + // Throw a useful fault + string faultCode = string("Server.TuscanySCA.") + string(e.getEClassName()); + string faultString = string(e.getEClassName()) + string(":") + string (e.getMessageText()); + + pIWSSZ->createSoapFault("ServiceRuntimeException","tempURI", faultCode.c_str(), faultString.c_str()); + throw AxisServiceException(); + } + catch(SDORuntimeException e) + { + // Throw a useful fault + string faultCode = string("Server.TuscanySDO.") + string(e.getEClassName()); + string faultString = string(e.getEClassName()) + string(":") + string (e.getMessageText()); + + pIWSSZ->createSoapFault("SDORuntimeException","tempURI", faultCode.c_str(), faultString.c_str()); + throw AxisServiceException(); + } + + + 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/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/SCAWSWrapper.h b/sca-cpp/tags/cpp-sca-20060405/runtime/axis_binding/wrapper/src/SCAWSWrapper.h new file mode 100644 index 0000000000..474c39977f --- /dev/null +++ b/sca-cpp/tags/cpp-sca-20060405/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) |