tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r447082 - in /incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src: Makefile.am tuscany/sca/ws/Axis2Dispatcher.cpp tuscany/sca/ws/Axis2Service.cpp tuscany/sca/ws/Axis2Service_skeleton.cpp
Date Sun, 17 Sep 2006 16:05:01 GMT
Author: jsdelfino
Date: Sun Sep 17 09:05:00 2006
New Revision: 447082

URL: http://svn.apache.org/viewvc?view=rev&rev=447082
Log:
Beginning of an Axis2 custom dispatcher that will handle the dispatching of all requests to
SCA services, so we don't need to declare them in services.xml anymore

Added:
    incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp
  (with props)
    incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp
  (with props)
Removed:
    incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service_skeleton.cpp
Modified:
    incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/Makefile.am

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/Makefile.am
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/Makefile.am?view=diff&rev=447082&r1=447081&r2=447082
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/Makefile.am (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/Makefile.am Sun Sep
17 09:05:00 2006
@@ -1,16 +1,37 @@
 libdir=$(prefix)/extensions/ws/service/lib
-lib_LTLIBRARIES = libtuscany_sca_ws_service.la
+lib_LTLIBRARIES = \
+libtuscany_sca_ws_service.la \
+libtuscany_sca_ws_dispatcher.la
 
-noinst_HEADERS = tuscany/sca/ws/*.h tuscany/sca/ws/model/*.h
+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_skeleton.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 \
+                    -laxis2_http_sender \
+                    -laxis2_http_receiver
+
+libtuscany_sca_ws_dispatcher_la_SOURCES = \
+tuscany/sca/ws/Axis2Dispatcher.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 \

Added: incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp?view=auto&rev=447082
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp
(added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp
Sun Sep 17 09:05:00 2006
@@ -0,0 +1,244 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.
+ */
+#if defined(WIN32)  || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#pragma warning(disable: 4091)
+#endif
+
+#include <axis2_disp.h>
+#include <axis2_handler_desc.h>
+#include <axis2_qname.h>
+#include <axis2_relates_to.h>
+#include <axis2_svc.h>
+#include <axis2_const.h>
+#include <axis2_conf_ctx.h>
+#include <axis2_addr.h>
+#include <axis2_utils.h>
+#include <axiom_soap_envelope.h>
+#include <axiom_soap_body.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_disp_t *AXIS2_CALL 
+Axis2Dispatcher_create(
+    const axis2_env_t *env) 
+{
+    axis2_disp_t *disp = NULL;
+    axis2_handler_t *handler = NULL;
+    axis2_qname_t *qname = NULL;
+    
+    AXIS2_ENV_CHECK(env, NULL);
+
+    qname = axis2_qname_create(env, "tuscany_dispatcher", 
+                                                "http://tuscany.ws.apache.org",
+                                                NULL);
+    
+    disp = axis2_disp_create(env, qname);
+    if (!disp)
+    { 
+        return NULL;        
+    }
+    
+    handler = AXIS2_DISP_GET_BASE(disp, env);
+    if (!handler)
+    {
+        return NULL;        
+    }
+
+    handler->ops->invoke = Axis2Dispatcher_invoke;
+    
+    AXIS2_QNAME_FREE(qname, env);
+    
+    return disp;
+}
+
+axis2_svc_t *AXIS2_CALL 
+Axis2Dispatcher_find_svc(
+    axis2_msg_ctx_t *msg_ctx, 
+    const axis2_env_t *env) 
+{    
+    axis2_endpoint_ref_t *endpoint_ref = NULL;
+    axis2_svc_t *svc = NULL;
+    
+    AXIS2_ENV_CHECK(env, NULL);    
+    
+    endpoint_ref = AXIS2_MSG_CTX_GET_TO(msg_ctx, env);
+    
+    if (endpoint_ref)
+    {
+        axis2_char_t *address = NULL;        
+
+        address = AXIS2_ENDPOINT_REF_GET_ADDRESS(endpoint_ref, env);
+        if (address)
+        {
+            
+            axis2_char_t **url_tokens = NULL;
+            AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+                "Checking for TuscanyService using target endpoint address : %s", address);
+            
+            url_tokens = axis2_parse_request_url_for_svc_and_op(env, address);
+            
+            if (url_tokens)
+            {                
+                if (url_tokens[0])
+                {                    
+                    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)
+                            {
+                                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+                                    "Service found using target endpoint address");
+                                    
+                                // TODO store the URL token in the message context
+                                // url_tokens[0]
+                            }
+                        }
+                    }                    
+                }
+            }
+        }
+    }
+        
+    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)
+{
+    axiom_soap_envelope_t *soap_envelope = NULL;
+    axis2_op_t *op = NULL;
+    
+    AXIS2_ENV_CHECK(env, NULL); 
+    //AXIS2_PARAM_CHECK(env->error, svc, NULL);
+
+    soap_envelope = AXIS2_MSG_CTX_GET_SOAP_ENVELOPE(msg_ctx, env);
+    if (soap_envelope)
+    {
+        axiom_soap_body_t *soap_body = AXIOM_SOAP_ENVELOPE_GET_BODY(soap_envelope, env);
+        if (soap_body)
+        {
+            axiom_node_t *body_node = AXIOM_SOAP_BODY_GET_BASE_NODE(soap_body, env);
+            if (body_node)
+            {
+                axiom_node_t *body_first_child_node = 
+                    AXIOM_NODE_GET_FIRST_CHILD(body_node, env);
+                if (body_first_child_node)
+                {                    
+                    if (AXIOM_NODE_GET_NODE_TYPE(body_first_child_node, env) == AXIOM_ELEMENT)
+                    {
+                        axiom_element_t *element = NULL;                        
+                        element = (axiom_element_t *)AXIOM_NODE_GET_DATA_ELEMENT(body_first_child_node,
env);
+                        if (element)
+                        {
+                            axis2_char_t *element_name = AXIOM_ELEMENT_GET_LOCALNAME(element,
env);
+                            if (element_name)
+                            {
+                                axis2_qname_t *op_qname = NULL;
+                                AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+                                    "Checking for operation using SOAP message body's first
child's local name : %s", 
+                                        element_name);
+                                        
+                                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)
+                                    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
+                                        "Operation found using SOAP message body's first
child's local name");
+                                
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+    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);    
+    
+    msg_ctx->ops->find_svc = Axis2Dispatcher_find_svc;
+    msg_ctx->ops->find_op = Axis2Dispatcher_find_op;
+    
+    return axis2_disp_invoke(handler, env, msg_ctx);
+}
+
+/**
+ * Following block distinguish the exposed part of the dll.
+ */
+
+AXIS2_EXPORT int axis2_get_instance(axis2_disp_t **inst,
+                        axis2_env_t *env)
+{
+    *inst = Axis2Dispatcher_create(env);
+    if(!(*inst))
+    {
+        return AXIS2_FAILURE;
+    }
+
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT int axis2_remove_instance(axis2_disp_t *inst,
+                            axis2_env_t *env)
+{
+    axis2_status_t status = AXIS2_FAILURE;
+	if (inst)
+	{
+        status = AXIS2_HANDLER_FREE(inst, env);
+    }
+    return status;
+}
+}

Propchange: incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp?view=auto&rev=447082
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp
(added)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp
Sun Sep 17 09:05:00 2006
@@ -0,0 +1,425 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.
+ */
+#if defined(WIN32)  || defined (_WINDOWS)
+#pragma warning(disable: 4786)
+#pragma warning(disable: 4091)
+#endif
+
+#include <axis2_svc_skeleton.h>
+#include <axis2_array_list.h>
+#include <axis2_log_default.h>
+#include <axis2_error_default.h>
+#include <axiom.h>
+#include <stdio.h>
+
+#include <sdo_axiom.h>
+using commonj::sdo::DataObjectPtr;
+using commonj::sdo::DataFactoryPtr;
+using commonj::sdo_axiom::AxiomHelper;
+
+#include "tuscany/sca/util/Exceptions.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/WSDLInterface.h" 
+#include "tuscany/sca/model/Interface.h" 
+#include "tuscany/sca/core/TuscanyRuntime.h"
+#include "tuscany/sca/core/SCARuntime.h"
+#include "tuscany/sca/util/Utils.h"
+#include "Axis2Utils.h"
+
+using namespace tuscany::sca;
+using namespace tuscany::sca::ws;
+using namespace tuscany::sca::model;
+
+
+int AXIS2_CALL
+Axis2Service_free(axis2_svc_skeleton_t *svc_skeleton,
+          const axis2_env_t *env);
+
+/*
+ * This method invokes the right 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);
+
+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->func_array)
+    {
+        AXIS2_ARRAY_LIST_FREE(svc_skeleton->func_array, env);
+        svc_skeleton->func_array = NULL;
+    }*/
+
+    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 Tuscany runtime
+ */
+ 
+static string systemRoot = "";
+static string serviceName = "";
+static TuscanyRuntime* tuscanyRuntime = NULL;
+static CompositeService* compositeService = NULL;
+
+void initTuscanyRuntime(const axis2_env_t *env, const char* root, const char* service)
+{
+    AXIS2_LOG_INFO((env)->log, "Axis2Service init : %s $s\n", root, service);
+    try
+    {
+
+        bool newInitParams = false;
+
+        if(systemRoot != root)
+        {
+            systemRoot = root;
+            newInitParams = true;
+        }
+
+        if(serviceName != service)
+        {
+            serviceName = service;
+            newInitParams = true;
+        }
+        
+        // service is of the form "component name"/"composite service name"
+        string defaultComponentName, compositeServiceName;
+        Utils::rTokeniseString("/", service, defaultComponentName, compositeServiceName);
+
+        if(tuscanyRuntime == NULL)
+        {
+            AXIS2_LOG_INFO((env)->log, "Creating new Tuscany runtime\n");
+            tuscanyRuntime = new TuscanyRuntime(defaultComponentName, systemRoot);
+            tuscanyRuntime->start();
+        }
+        else if(tuscanyRuntime != NULL && newInitParams)
+        {
+            AXIS2_LOG_INFO((env)->log, "Restarting Tuscany runtime\n");
+            tuscanyRuntime->stop();
+            tuscanyRuntime->setDefaultComponentName(defaultComponentName);
+            tuscanyRuntime->setSystemRoot(systemRoot);
+            tuscanyRuntime->start();
+        }
+
+        if(compositeService == NULL)
+        {
+            Composite* composite = (Composite*)SCARuntime::getInstance()->getDefaultComponent()->getType();
+            compositeService = (CompositeService*)composite->findComponent(compositeServiceName);
+        }
+        else
+        {
+            if(newInitParams)
+            {
+                Composite* composite = SCARuntime::getInstance()->getDefaultComponent()->getComposite();
+                compositeService = (CompositeService*)composite->findComponent(compositeServiceName);
+            }
+        }
+    }
+    catch(TuscanyRuntimeException &ex)
+    {   
+        AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI,  "%s has been caught: %s\n", ex.getEClassName(),
ex.getMessageText());
+    }  
+}
+
+
+/*
+ * This method invokes the right 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)
+{
+	axiom_node_t *returnNode = node;
+
+    /* Depending on the function name invoke the
+     *  corresponding Axis2Service method
+     */
+    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)
+            {
+                // This gets the operation name from the root element name - this is correct
for DocLit Wrapped style
+                axis2_char_t *op_name = AXIOM_ELEMENT_GET_LOCALNAME(element, env);
+                if (op_name)
+				{
+                    char* root = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanySystemRoot");
+                    char* service = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx,
"TuscanyService");
+                    
+                    AXIS2_LOG_INFO((env)->log, "Axis2Service invoke called with system
root: %s entrypoint name: %s operation name: %s", root, service, op_name);
+
+                    //LOGINFO_2(4, "Axis2Service invoke called with system root: %s and entrypoint
name: %s", systemRoot, fullCompositeServiceName);
+                    //LOGINFO_1(4, "Axis2Service invoke called with operation", op_name);
+                    initTuscanyRuntime(env, root, service);
+
+                    //Utils::printTypes(compositeServiceProxy->getDataFactory());
+
+                    DataFactoryPtr dataFactory = compositeService->getComposite()->getDataFactory();
+                    if (dataFactory == 0)
+                    {
+                		AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: CompositeService
has no SCA implementation");
+                        return 0;
+                    }
+
+                    AxiomHelper* axiomHelper = AxiomHelper::getHelper();
+                    char* om_str = NULL;
+                    om_str = AXIOM_NODE_TO_STRING(node, env);
+                    if (om_str)
+                    {
+                        AXIS2_LOG_INFO((env)->log, "Axis2Service invoke has request OM:
%s\n", om_str);
+                    }
+
+                    // Get the WS binding and the WSDL operation
+                    Composite* composite = compositeService->getComposite();
+                    Reference* reference = compositeService->getReference();
+                    WSReferenceBinding* binding = (WSReferenceBinding*)reference->getBinding();
+                    WSDLOperation wsdlOperation;
+                     
+                    string wsdlNamespace = binding->getWSDLNamespaceURL();
+                    if (wsdlNamespace != "")
+                    {
+                        
+                        // Lookup the WSDL model from the composite, keyed on the namespace

+                        // (the wsdl will have been loaded at startup)
+                        WSDLDefinition* wsdlDefinition = composite->findWSDLDefinition(wsdlNamespace);
+                        if (wsdlDefinition == 0)
+                        {
+                            AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI,  "WSDL description
%s not found\n", wsdlNamespace.c_str());
+                            string msg = "WSDL not found for " + wsdlNamespace;
+                            throw SystemConfigurationException(msg.c_str());
+                        }
+                        
+                        // Find the target operation in the wsdl port type.
+                        try {
+                            wsdlOperation =  wsdlDefinition->findOperation(
+                                binding->getServiceName(),
+                                binding->getPortName(),
+                                op_name);
+                        }
+                        catch(SystemConfigurationException &ex)
+                        {   
+                            AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "SystemConfigurationException
has been caught: %s\n", ex.getMessageText());
+                            throw;
+                        }
+                        
+                    }
+                    else
+                    {
+                        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)
+                                {
+                                    AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "WSDL description
%s not found\n", wsdlNamespace.c_str());
+                                    string msg = "WSDL not found for " + wsdlNamespace;
+                                    throw SystemConfigurationException(msg.c_str());
+                                }
+                        
+                                try
+                                {
+                                    wsdlOperation = wsdl->findOperation(wsdlInterface->getName(),
op_name);
+                                }
+                                catch(SystemConfigurationException &ex)
+                                {   
+                                    AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "SystemConfigurationException
has been caught: %s\n", ex.getMessageText());
+                                    throw;
+                                }
+                            }
+                        }
+                    }
+                    
+                    if (wsdlNamespace == "")
+                    {
+                        
+                        // Create a default document literal wrapped WSDL operation
+                        wsdlNamespace = compositeService->getName();
+                        wsdlOperation = WSDLOperation();
+                        wsdlOperation.setOperationName(op_name);
+                        wsdlOperation.setSoapAction(wsdlNamespace+ "#" +op_name);
+                        wsdlOperation.setEndpoint("");
+                        wsdlOperation.setSoapVersion(WSDLOperation::SOAP11);
+                        wsdlOperation.setDocumentStyle(true);
+                        wsdlOperation.setWrappedStyle(true);
+                        wsdlOperation.setEncoded(false);
+                        wsdlOperation.setInputType(wsdlNamespace + "#" + op_name);
+                        wsdlOperation.setOutputType(wsdlNamespace + "#" + op_name + "Response");
+                    }
+
+                    // Convert the input AXIOM node to an SDO DataObject
+                    DataObjectPtr inputDataObject = axiomHelper->toSdo(
+                            node, dataFactory, wsdlOperation.getInputTypeUri().c_str());
+
+                    //printf("Axis2ServiceType inputDataObject: (%d)\n", inputDataObject);
+
+                    if(!inputDataObject)
+                    {
+                        AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke:
Could not convert received Axiom node to SDO");
+                        //LOGERROR(0, "Axis2Service_invoke: Failure whilst invoking CompositeService");
+                        /** TODO: return a SOAP fault here */
+                        return 0;
+                    }                    
+                    //std::cout << "Axis2ServiceType inputDataObject:" << inputDataObject;
+                    //Utils::printDO(inputDataObject);			
+                    //std::cout << "Axis2ServiceType inputDataObject printed\n";
+                    
+                    //
+                    //  Dispatch to the WS proxy
+                    //
+                    
+                    WSServiceProxy* proxy = (WSServiceProxy*)binding->getServiceProxy();
+                    DataObjectPtr outputDataObject = proxy->invoke(wsdlOperation, inputDataObject);
+
+                    //std::cout << "Axis2ServiceType outputDataObject:" << outputDataObject;
+                    //Utils::printDO(outputDataObject);			
+                    //std::cout << "Axis2ServiceType outputDataObject printed\n";
+                    
+                    if(!outputDataObject)
+                    {
+                		AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: Failure
whilst invoking CompositeService");
+                        //LOGERROR(0, "Axis2Service_invoke: Failure whilst invoking CompositeService");
+                        /** TODO: return a SOAP fault here */
+                        return 0;
+                    }
+
+					returnNode = axiomHelper->toAxiomNode(outputDataObject);
+						
+                    om_str = NULL;
+                    om_str = AXIOM_NODE_TO_STRING(returnNode, env);
+                    if (om_str)
+                    {
+                        AXIS2_LOG_INFO((env)->log, "Axis2Service invoke has response OM
: %s\n", om_str);
+                    }
+                        
+					AxiomHelper::releaseHelper(axiomHelper);												
+
+                	//LOGEXIT(1, "Axis2Service_invoke");						
+					return returnNode;
+                }
+            }
+        }
+    }
+    
+	AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: invalid OM parameters
in request");
+    //LOGERROR(0, "Axis2Service service ERROR: invalid OM parameters in request\n");
+    
+    /** TODO: return a SOAP fault here */
+    return node;
+}
+
+
+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 = axis2_Axis2Service_create(env);
+    /*if(NULL != *inst)
+    {
+        status = *inst->init();
+    }*/
+    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;
+}
+}

Propchange: incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message