You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2006/11/19 21:36:02 UTC

svn commit: r476913 - in /incubator/tuscany/cpp/sca/runtime: core/src/tuscany/sca/util/ extensions/ws/reference/axis2c/src/tuscany/sca/ws/ extensions/ws/service/axis2c/src/ extensions/ws/service/axis2c/src/tuscany/sca/ws/

Author: jsdelfino
Date: Sun Nov 19 12:36:01 2006
New Revision: 476913

URL: http://svn.apache.org/viewvc?view=rev&rev=476913
Log:
Cleaned up logs and error reporting in Web Service binding, and the logic in Axis2Service::initTuscanyRuntime() to work in a multi-composite environment behind the Apache HTTP server for example.

Modified:
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Exceptions.cpp
    incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Exceptions.h
    incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/Makefile.am
    incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Exceptions.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Exceptions.cpp?view=diff&rev=476913&r1=476912&r2=476913
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Exceptions.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Exceptions.cpp Sun Nov 19 12:36:01 2006
@@ -23,6 +23,8 @@
 #include "tuscany/sca/util/Logging.h"
 using namespace std;
 
+#include <sstream>
+
 #if defined(WIN32)  || defined (_WINDOWS)
 #else
 #include <execinfo.h>
@@ -285,6 +287,7 @@
             return os;
         } // end ostream operator <<
         
+        
         // ========================================================================
         // ostream operator <<
         // ========================================================================
@@ -292,7 +295,20 @@
         {
             return except.PrintSelf(os);
         } // end ostream operator <<
+
+        SCA_API TuscanyRuntimeException::operator std::string() const
+        {
+            ostringstream os;
+            os << *this;
+            return os.str();
+        }
         
+        SCA_API TuscanyRuntimeException::operator const char*() const
+        {
+            ostringstream os;
+            os << *this;
+            return os.str().c_str();
+        }
         
     } // End namespace sca
 } // End namespace tuscany

Modified: incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Exceptions.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Exceptions.h?view=diff&rev=476913&r1=476912&r2=476913
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Exceptions.h (original)
+++ incubator/tuscany/cpp/sca/runtime/core/src/tuscany/sca/util/Exceptions.h Sun Nov 19 12:36:01 2006
@@ -127,6 +127,9 @@
              * Operator to send exceptions details to a stream.
              */
             SCA_API friend std::ostream& operator<< (std::ostream &os, const TuscanyRuntimeException &except);
+            
+            SCA_API operator std::string() const;
+            SCA_API operator const char*() const;
 
         protected:
             

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp?view=diff&rev=476913&r1=476912&r2=476913
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp Sun Nov 19 12:36:01 2006
@@ -53,7 +53,6 @@
 
 using namespace tuscany::sca::ws;
 
-
 using namespace commonj::sdo;
 using namespace commonj::sdo_axiom;
 
@@ -104,7 +103,6 @@
                     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;
                         throwException(SystemConfigurationException, msg.c_str());
                     }
@@ -119,7 +117,6 @@
                     }
                     catch(SystemConfigurationException& ex)
                     {   
-                        AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "SystemConfigurationException has been caught: %s\n", ex.getMessageText());
                         throw;
                     }
                     
@@ -139,7 +136,6 @@
                             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;
                                 throwException(SystemConfigurationException, msg.c_str());
                             }
@@ -150,7 +146,6 @@
                             }
                             catch(SystemConfigurationException& ex)
                             {   
-                                AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "SystemConfigurationException has been caught: %s\n", ex.getMessageText());
                                 throw;
                             }
                         }
@@ -239,11 +234,10 @@
                 axis2_svc_client_t* svc_client = axis2_svc_client_create(env, client_home);
                 if (!svc_client)
                 {
-                    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "invoke FAILED: Error code:"
-                        " %d :: %s", env->error->error_number,
-                        AXIS2_ERROR_GET_MESSAGE(env->error));
-                    
-                    throwException(SystemConfigurationException, "axis2_svc_client_create failed");
+                    ostringstream msg;
+                    msg << "Axis2 svc_client_create failed, error: " << env->error->error_number <<
+                    ", " << AXIS2_ERROR_GET_MESSAGE(env->error);
+                    throwException(SystemConfigurationException, msg.str().c_str());
                 }
                 
                 /* Set service client options */
@@ -257,10 +251,10 @@
                 }
                 else
                 {
-                    AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Invoke failed: Error code:"
-                        " %d :: %s", env->error->error_number,
-                        AXIS2_ERROR_GET_MESSAGE(env->error));
-                    throwException(ServiceInvocationException, "Web Service invoke failed");
+                    ostringstream msg;
+                    msg << "Axis2 client_send_received failed, error: " << env->error->error_number <<
+                    ", " << AXIS2_ERROR_GET_MESSAGE(env->error);
+                    throwException(ServiceInvocationException, msg.str().c_str());
                 }
                 
                 loginfo("Have not freed Axis2C service client memory due to Jira AXIS2C-209");
@@ -404,7 +398,11 @@
                                         break;
                                     }
                                 default:
-                                   throwException(SystemConfigurationException, "Unsupported parameter type");
+                                    {
+                                        ostringstream msg;
+                                        msg << "Unsupported parameter type: " << parm.getType();
+                                        throwException(ServiceDataException, msg.str().c_str());
+                                    }
                                 }
                             }
                         }
@@ -483,7 +481,9 @@
                                     break;
                                 }
                             default:
-                                throwException(ServiceDataException, "Unsupported parameter type");
+                                ostringstream msg;
+                                msg << "Unsupported parameter type: " << parm.getType();
+                                throwException(ServiceDataException, msg.str().c_str());
                             }
                         }
                     }
@@ -500,7 +500,7 @@
                 }
                 
                 char* str =  AXIOM_NODE_TO_STRING(request_node, env);
-                loginfo("Sending OM node: %s ",  str); 
+                loginfo("Sending Axis2 OM: %s ",  str); 
                 
                 return request_node;
              }
@@ -525,11 +525,9 @@
                     str = AXIOM_NODE_TO_STRING(body, env);
                     if (str)
                     {
-                        AXIS2_LOG_INFO((env)->log, "Axis2Client invoke has response OM: %s\n", str);
+                        loginfo("Received Axis2 OM: %s ",  str); 
                     }
                     
-                    //cout << "response body = " << str << endl;
-
                     // Convert the SOAP body to an SDO DataObject
                     AxiomHelper* axiomHelper = AxiomHelper::getHelper();
                     DataObjectPtr outputBodyDataObject = axiomHelper->toSdo(body, dataFactory);
@@ -537,9 +535,8 @@
                     
                     if(!outputBodyDataObject)
                     {
-                        AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service invoke: Could not convert received Axiom node to SDO");
-                        /** TODO: return a SOAP fault here */
-                        return;
+                        string msg = "Could not convert Axis2 OM node to SDO";
+                        throwException(ServiceInvocationException, msg.c_str());
                     }
                     
                     XMLHelperPtr xmlHelper = compositeReference->getComposite()->getXMLHelper();
@@ -561,8 +558,8 @@
                     }
                     if (outputDataObject == NULL)
                     {
-                        AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Client invoke: Could not convert body part to SDO");
-                        return;
+                        string msg = "Could not convert Axis2 body part to SDO";
+                        throwException(ServiceInvocationException, msg.c_str());
                     }
 
                     PropertyList pl = outputDataObject->getType().getProperties();
@@ -588,9 +585,6 @@
                                     {
                                         loginfo("Null DataObject return value");
                                     }
-                                    
-                                    cout << "ReturnValue " << *dataObjectData << endl;
-                                    
                                     operation.setReturnValue(dataObjectData);
                                 }
                             }

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=476913&r1=476912&r2=476913
==============================================================================
--- 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 Nov 19 12:36:01 2006
@@ -55,6 +55,8 @@
 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 \

Modified: 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=diff&rev=476913&r1=476912&r2=476913
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Dispatcher.cpp Sun Nov 19 12:36:01 2006
@@ -35,6 +35,8 @@
 #include <axiom_soap_envelope.h>
 #include <axiom_soap_body.h>
 
+#include "tuscany/sca/util/Logging.h"
+
 extern "C"
 {                                                                                   
 
@@ -55,6 +57,7 @@
     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) 
@@ -97,8 +100,7 @@
             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");
+                loginfo("Service found using target endpoint address");
             }
         }
     }                    
@@ -125,8 +127,7 @@
     AXIS2_QNAME_FREE(op_qname, env);
     if (op)
     {
-        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, 
-            "TuscanyService execute operation found");
+        loginfo("TuscanyService execute operation found");
     }
     return op;
 }

Modified: 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=diff&rev=476913&r1=476912&r2=476913
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Service.cpp Sun Nov 19 12:36:01 2006
@@ -39,6 +39,7 @@
 using commonj::sdo_axiom::AxiomHelper;
 
 #include "tuscany/sca/util/Exceptions.h"
+#include "tuscany/sca/util/Logging.h"
 #include "WSServiceProxy.h"
 #include "model/WSReferenceBinding.h"
 #include "tuscany/sca/model/Composite.h"
@@ -142,7 +143,9 @@
 
 void initTuscanyRuntime(const axis2_env_t *env, const char* root, const char *component, const char* service)
 {
-    AXIS2_LOG_INFO((env)->log, "Axis2Service init, root: %s, component: %s, service: %s\n", root, component, service);
+    logentry();
+    loginfo("Root: %s, component: %s, service: %s", root, component, service);
+    
     try
     {
 
@@ -170,13 +173,21 @@
         
         if (tuscanyRuntime == NULL)
         {
-            AXIS2_LOG_INFO((env)->log, "Creating new Tuscany runtime\n");
+            loginfo("Creating new Tuscany runtime");
             tuscanyRuntime = new TuscanyRuntime(componentName, systemRoot);
             tuscanyRuntime->start();
         }
-        else if (tuscanyRuntime != NULL && restart)
+        else if (restart)
+        {
+            loginfo("Restarting Tuscany runtime");
+            tuscanyRuntime->stop();
+            tuscanyRuntime->setDefaultComponentName(componentName);
+            tuscanyRuntime->setSystemRoot(systemRoot);
+            tuscanyRuntime->start();
+        }
+        else if (resolve)
         {
-            AXIS2_LOG_INFO((env)->log, "Restarting Tuscany runtime\n");
+            loginfo("Refreshing Tuscany runtime");
             tuscanyRuntime->stop();
             tuscanyRuntime->setDefaultComponentName(componentName);
             tuscanyRuntime->setSystemRoot(systemRoot);
@@ -185,21 +196,50 @@
 
         if (compositeService == NULL)
         {
-            Composite* composite = (Composite*)SCARuntime::getInstance()->getDefaultComponent()->getType();
+            loginfo("Resolving composite: %s, service: %s", componentName.c_str(), serviceName.c_str());
+            Component* component = SCARuntime::getInstance()->getDefaultComponent();
+            if (component == NULL)
+            {
+                string msg = "Component not found " + componentName;
+                throwException(SystemConfigurationException, msg.c_str());
+            }
+            Composite* composite = (Composite*)component->getType();
             compositeService = (CompositeService*)composite->findComponent(serviceName);
+            if (compositeService == NULL)
+            {
+                string msg = "Composite service not found " + serviceName;
+                throwException(SystemConfigurationException, msg.c_str());
+            }
         }
         else
         {
             if (resolve)
             {
-                Composite* composite = SCARuntime::getInstance()->getDefaultComponent()->getComposite();
+                loginfo("Switching to composite: %s, service: %s", componentName.c_str(), serviceName.c_str());
+                Component* component = SCARuntime::getInstance()->getDefaultComponent();
+                if (component == NULL)
+                {
+                    string msg = "Component not found " + componentName;
+                    throwException(SystemConfigurationException, msg.c_str());
+                }
+                Composite* composite = (Composite*)component->getType();
                 compositeService = (CompositeService*)composite->findComponent(serviceName);
+                if (compositeService == NULL)
+                {
+                    string msg = "Composite service not found " + serviceName;
+                    throwException(SystemConfigurationException, msg.c_str());
+                }
+            }
+            else
+            {
+                loginfo("Reusing composite: %s, service: %s", componentName.c_str(), serviceName.c_str());
             }
         }
     }
     catch(TuscanyRuntimeException &ex)
-    {   
-        AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI,  "%s has been caught: %s\n", ex.getEClassName(), ex.getMessageText());
+    {
+        logerror("Failed to initialize Tuscany runtime: %s", (const char*)ex);
+        throw;
     }  
 }
 
@@ -213,279 +253,280 @@
             axiom_node_t *node,
             axis2_msg_ctx_t *msg_ctx)
 {
-    if (node)
-    {
-        if (AXIOM_NODE_GET_NODE_TYPE(node, env) == AXIOM_ELEMENT)
+    logentry();
+
+    try
+    {    
+        if (node)
         {
-            axiom_element_t *element = NULL;
-            element = (axiom_element_t *)AXIOM_NODE_GET_DATA_ELEMENT(node, env);
-            if (element)
+            if (AXIOM_NODE_GET_NODE_TYPE(node, env) == AXIOM_ELEMENT)
             {
-                string op_name = "";
-                
-                axis2_bool_t rest = AXIS2_MSG_CTX_GET_DOING_REST(msg_ctx, env);
-                if (rest)
+                axiom_element_t *element = NULL;
+                element = (axiom_element_t *)AXIOM_NODE_GET_DATA_ELEMENT(node, env);
+                if (element)
                 {
-                    axis2_endpoint_ref_t *endpoint_ref = AXIS2_MSG_CTX_GET_FROM(msg_ctx, env);
-                    if (endpoint_ref)
+                    string op_name = "";
+                    
+                    axis2_bool_t rest = AXIS2_MSG_CTX_GET_DOING_REST(msg_ctx, env);
+                    if (rest)
                     {
-                        const axis2_char_t *addr = AXIS2_ENDPOINT_REF_GET_ADDRESS(endpoint_ref, env);
-                        if (addr)
+                        axis2_endpoint_ref_t *endpoint_ref = AXIS2_MSG_CTX_GET_FROM(msg_ctx, env);
+                        if (endpoint_ref)
                         {
-                            // 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);
+                            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 != "")
-				{
-                    // Get the Tuscany system root and composite service name from the Axis2
-                    // service parameters 
-                    char* rootParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanySystemRoot");
-                    if (rootParam == NULL)
-                        rootParam = "";
-                    
-                    char* serviceParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyService");
-                    if (serviceParam != NULL)
+                    else
                     {
-                        AXIS2_LOG_INFO((env)->log, "Axis2Service invoke called with 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);
-                
-                        initTuscanyRuntime(env, rootParam, component.c_str(), service.c_str());
+                        // 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);
                     }
-                    else {
-                        
-                        // Use the default 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);
+                    
+                    if (op_name != "")
+    				{
+                        // Get the Tuscany system root and composite service name from the Axis2
+                        // service parameters 
+                        char* rootParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanySystemRoot");
+                        if (rootParam == NULL)
+                            rootParam = "";
                         
-                        axis2_bool_t isrest = AXIS2_MSG_CTX_GET_DOING_REST(msg_ctx, env);
-                        string path;
-                        if (isrest)
+                        char* serviceParam = Axis2Utils::getAxisServiceParameterValue(env, msg_ctx, "TuscanyService");
+                        if (serviceParam != NULL)
                         {
-                            string op;
-                            Utils::rTokeniseString("/", address, path, op);
+                            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);
+                    
+                            initTuscanyRuntime(env, rootParam, component.c_str(), service.c_str());
                         }
-                        else
-                        {
-                            path = address;
+                        else {
+                            
+                            // Use the default 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());
+                            
+                            initTuscanyRuntime(env, rootParam, component.c_str(), service.c_str());
                         }
-
-                        string path2;                        
-                        string service;
-                        Utils::rTokeniseString("/", path, path2, service);
-                        
-                        string path3;
-                        string component;
-                        Utils::rTokeniseString("/", path2, path3, component);
-                        if (component == "services")
+    
+                        if(!compositeService)
                         {
-                            component = "";
-                        }
-                        
-                        AXIS2_LOG_INFO((env)->log, "Axis2Service invoke called with system root: %s, component name: %s, service name: %s, operation name: %s",
-                            rootParam, component.c_str(), service.c_str(), op_name.c_str());
-                        
-                        initTuscanyRuntime(env, rootParam, component.c_str(), service.c_str());
-                    }
-
-                    if(!compositeService)
-                    {
-               		    AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: Tuscany initialisation failed");
-                        return 0;
-                    }
-
-                    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;
-                    }
-
-                    // 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;
-                            throwException(SystemConfigurationException, msg.c_str());
+                   		    logerror("Failed to initialize Tuscany runtime, could not initialize CompositeService");
+                            return 0;
                         }
-                        
-                        // Find the target operation in the wsdl port type.
-                        try {
-                            wsdlOperation =  wsdlDefinition->findOperation(
-                                binding->getServiceName(),
-                                binding->getEndpointName(),
-                                op_name.c_str());
-                        }
-                        catch(SystemConfigurationException& ex)
-                        {   
-                            AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "SystemConfigurationException has been caught: %s\n", ex.getMessageText());
-                            throw;
+    
+                        DataFactoryPtr dataFactory = compositeService->getComposite()->getDataFactory();
+                        if (dataFactory == 0)
+                        {
+                            logerror("Failed to initialize Tuscany runtime, could not get DataFactory");
+                            return 0;
                         }
-                        
-                    }
-                    else
-                    {
-                        Interface* iface = reference->getType()->getInterface();
-                        if (iface != NULL &&
-                            iface->getInterfaceTypeQName() == WSDLInterface::typeQName)
+    
+                        // 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 != "")
                         {
-                            WSDLInterface* wsdlInterface = (WSDLInterface*)iface;
-                            wsdlNamespace = wsdlInterface->getNamespaceURI();
                             
-                            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)
+                            {
+                                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& ex)
+                            {   
+                                throw;
+                            }
+                            
+                        }
+                        else
+                        {
+                            Interface* iface = reference->getType()->getInterface();
+                            if (iface != NULL &&
+                                iface->getInterfaceTypeQName() == WSDLInterface::typeQName)
                             {
+                                WSDLInterface* wsdlInterface = (WSDLInterface*)iface;
+                                wsdlNamespace = wsdlInterface->getNamespaceURI();
                                 
-                                WSDLDefinition* wsdl = composite->findWSDLDefinition(wsdlNamespace);
-                                if (wsdl == 0)
+                                if (wsdlNamespace != "")
                                 {
-                                    AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "WSDL description %s not found\n", wsdlNamespace.c_str());
-                                    string msg = "WSDL not found for " + wsdlNamespace;
-                                    throwException(SystemConfigurationException, msg.c_str());
+                                    
+                                    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& ex)
+                                    {   
+                                        throw;
+                                    }
                                 }
+                            }
+                        }
                         
-                                try
-                                {
-                                    wsdlOperation = wsdl->findOperation(wsdlInterface->getName(), op_name.c_str());
-                                }
-                                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.c_str());
+                            wsdlOperation.setSoapAction(wsdlNamespace+ "#" +op_name);
+                            wsdlOperation.setEndpoint("");
+                            wsdlOperation.setSoapVersion(WSDLOperation::SOAP11);
+                            wsdlOperation.setDocumentStyle(true);
+                            wsdlOperation.setWrappedStyle(true);
+                            wsdlOperation.setEncoded(false);
+                            wsdlOperation.setInputType(string("http://tempuri.org") + "#" + op_name);
+                            wsdlOperation.setOutputType(string("http://tempuri.org") + "#" + op_name + "Response");
+                        }
+    
+                        // 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
+                        AxiomHelper* axiomHelper = AxiomHelper::getHelper();
+                        DataObjectPtr inputBodyDataObject = NULL;
+    
+                        try
+                        {
+                            inputBodyDataObject = axiomHelper->toSdo(body, dataFactory);
+                        }
+                        catch(SDORuntimeException &ex)
+                        {
+                            throw;
+                        }
+    
+                        if(!inputBodyDataObject)
+                        {
+                            string msg = "Could not convert request Axis2 OM to SDO";
+                            throwException(ServiceInvocationException, msg.c_str());
+                        }                    
+    
+                        // Get the first body part representing the doc-lit-wrapped wrapper element
+                        DataObjectPtr inputDataObject = NULL; 
+                        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 (wsdlNamespace == "")
-                    {
-                        // Create a default document literal wrapped WSDL operation
-                        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.setEncoded(false);
-                        wsdlOperation.setInputType(string("http://tempuri.org") + "#" + op_name);
-                        wsdlOperation.setOutputType(string("http://tempuri.org") + "#" + op_name + "Response");
-                    }
-
-                    // 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)
-                    {
-                        AXIS2_LOG_INFO((env)->log, "Axis2Service invoke has request OM: %s\n", str);
-                    }
-
-                    // Convert the SOAP body to an SDO DataObject
-                    AxiomHelper* axiomHelper = AxiomHelper::getHelper();
-                    DataObjectPtr inputBodyDataObject = NULL;
-
-                    try
-                    {
-                        inputBodyDataObject = axiomHelper->toSdo(body, dataFactory);
-                    }
-                    catch(SDORuntimeException &ex)
-                    {
-                        AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: SDORuntimeException thrown: %s", ex.getMessageText());
-                    }
-
-                    if(!inputBodyDataObject)
-                    {
-                        AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: Could not convert received Axiom node to SDO");
-                        /** TODO: return a SOAP fault here */
-                        return 0;
-                    }                    
-
-                    // Get the first body part representing the doc-lit-wrapped wrapper element
-                    DataObjectPtr inputDataObject = NULL; 
-                    PropertyList bpl = inputBodyDataObject->getInstanceProperties();
-                    if (bpl.size()!=0)
-                    {
-                        if (bpl[0].isMany())
+                        if (inputDataObject == NULL)
                         {
-                            DataObjectList& parts = inputBodyDataObject->getList((unsigned int)0);
-                            inputDataObject = parts[0];
+                            string msg = "Could not convert Axis2 body part to SDO";
+                            throwException(ServiceInvocationException, msg.c_str());
                         }
-                        else
+    
+                        //  Dispatch to the WS proxy
+                        WSServiceProxy* proxy = (WSServiceProxy*)binding->getServiceProxy();
+    
+                        DataObjectPtr outputDataObject = proxy->invoke(wsdlOperation, inputDataObject);
+                        
+                        if(!outputDataObject)
                         {
-                            inputDataObject = inputBodyDataObject->getDataObject(bpl[0]);
+                            return 0;
                         }
-                    }
-                    if (inputDataObject == NULL)
-                    {
-                        AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: Could not convert body part to SDO");
-                        return 0;
-                    }
-
-                    //  Dispatch to the WS proxy
-                    WSServiceProxy* proxy = (WSServiceProxy*)binding->getServiceProxy();
-
-                    DataObjectPtr outputDataObject = proxy->invoke(wsdlOperation, inputDataObject);
-                    
-                    if(!outputDataObject)
-                    {
-                		AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: Failure whilst invoking CompositeService");
-
-                        /** TODO: return a SOAP fault here */
-                        return 0;
-                    }
-                    
-                    // Convert the output DataObject to an Axiom node
-                    axiom_node_t* outputNode = axiomHelper->toAxiomNode(outputDataObject,
-                        wsdlOperation.getOutputTypeUri().c_str(), wsdlOperation.getOutputTypeName().c_str());
-
-                    AxiomHelper::releaseHelper(axiomHelper);                                                
-                    
-                    str = AXIOM_NODE_TO_STRING(outputNode, env);
-                    if (str)
-                    {
-                        AXIS2_LOG_INFO((env)->log, "Axis2Service invoke has response OM : %s\n", str);
-                    }
                         
-					return outputNode;
+                        // Convert the output DataObject to an Axiom node
+                        axiom_node_t* outputNode = axiomHelper->toAxiomNode(outputDataObject,
+                            wsdlOperation.getOutputTypeUri().c_str(), wsdlOperation.getOutputTypeName().c_str());
+    
+                        AxiomHelper::releaseHelper(axiomHelper);                                                
+                        
+                        str = AXIOM_NODE_TO_STRING(outputNode, env);
+                        if (str)
+                        {
+                            loginfo("Sending response Axis2 OM : %s", str);
+                        }
+                            
+    					return outputNode;
+                    }
                 }
             }
         }
+        
+    	string msg = "Invalid parameters in Axis2 request OM";
+        throwException(ServiceInvocationException, msg.c_str());
+
     }
-    
-	AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Service_invoke: invalid OM parameters in request");
-    
-    /** TODO: return a SOAP fault here */
+    catch(TuscanyRuntimeException& ex)
+    {
+        logerror("Failed to process Web service invocation: %s", (const char*)ex);
+    }        
     return 0;
 }
 

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp?view=diff&rev=476913&r1=476912&r2=476913
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/Axis2Utils.cpp Sun Nov 19 12:36:01 2006
@@ -23,50 +23,55 @@
 #pragma warning(disable: 4786)
 #pragma warning(disable: 4091)
 #endif
-#include "Axis2Utils.h"
 
 #include <axis2_svc_ctx.h>
 #include <axis2_defines.h>
 
 #include "tuscany/sca/util/Logging.h"
+#include "Axis2Utils.h"
 
 using namespace tuscany::sca;
 using namespace tuscany::sca::ws;
 
-
-/* Static utility method to retrieve service parameters from the service.xml file
- * Get an odd linking error if this method (or the header's it requires) are in
- * a different class.
- */
-char* Axis2Utils::getAxisServiceParameterValue(const axis2_env_t *env, axis2_msg_ctx_t *msg_ctx, char* parameterName)
+namespace tuscany
 {
-    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)
+    namespace sca
     {
-        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;
-}
+        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
 

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp?view=diff&rev=476913&r1=476912&r2=476913
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/service/axis2c/src/tuscany/sca/ws/WSServiceProxy.cpp Sun Nov 19 12:36:01 2006
@@ -38,6 +38,8 @@
 #include "tuscany/sca/model/WSDLOperation.h"
 #include "model/WSReferenceBinding.h"
 
+#include <sstream>
+
 #include "commonj/sdo/SDO.h"
 using namespace commonj::sdo;
 
@@ -472,9 +474,9 @@
                             }
                         default:
                             {
-                                string msg = "Unsupported parameter type";
-                                msg += resultType;
-                                throwException(SystemConfigurationException, msg.c_str());
+                                ostringstream msg;
+                                msg << "Unsupported result type: " << resultType;
+                                throwException(SystemConfigurationException, msg.str().c_str());
                             }
                         }
                     }
@@ -576,9 +578,9 @@
                             }
                         default:
                             {
-                                string msg = "Unsupported parameter type";
-                                msg += resultType;
-                                throwException(SystemConfigurationException, msg.c_str());
+                                ostringstream msg;
+                                msg << "Unsupported result type: " << resultType;
+                                throwException(SystemConfigurationException, msg.str().c_str());
                             }
                         }
                     }



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