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/09/24 00:58:03 UTC

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

Author: jsdelfino
Date: Sat Sep 23 15:58:02 2006
New Revision: 449327

URL: http://svn.apache.org/viewvc?view=rev&rev=449327
Log:
Completed support for open content. Incomingoopen content is now deserialized correctly (to do this without running into JIRA TUSCANY-747 we pass the SOAP body to the Axiom Helper instead of the Body part). Outgoing open content is represented as OpenDataObjects and we pass the correct SOAP body part element name to the Axiom Helper to get it serialized under the correct element name.

Modified:
    incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/Axis2Client.cpp
    incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.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/WSServiceProxy.cpp

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=449327&r1=449326&r2=449327
==============================================================================
--- 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 Sat Sep 23 15:58:02 2006
@@ -253,14 +253,14 @@
             }
             
             axiom_node_t* Axis2Client::createPayload(Operation& operation, 
-                const WSDLOperation& wsdlOp,
+                const WSDLOperation& wsdlOperation,
                 axis2_env_t* env)
             {	
                 LOGENTRY(1, "Axis2Client::createPayload");
-                axiom_node_t* requestOM = NULL;
+                axiom_node_t* request_node = NULL;
                 
                 // map the operation request to the wsdl
-                if (wsdlOp.isDocumentStyle())
+                if (wsdlOperation.isDocumentStyle())
                 {
                     // Document style 
                     // only support single part messages - WS-I compliant
@@ -269,15 +269,28 @@
                     
                     // Get the data factory for the composite (it will already have the typecreates loaded for the xsds)
                     DataFactoryPtr dataFactory = compositeReference->getComposite()->getDataFactory();
-                    DataObjectPtr requestDO = dataFactory->create(wsdlOp.getInputTypeUri().c_str(), 
-                        wsdlOp.getInputTypeName().c_str());
-
+                    
+                    DataObjectPtr inputDataObject;
+                    try
+                    {
+                        
+                        // Create the output wrapper
+                        const Type& inputType = dataFactory->getType(wsdlOperation.getInputTypeUri().c_str(), 
+                            wsdlOperation.getInputTypeName().c_str());
+                        inputDataObject = dataFactory->create(inputType);
+                    }
+                    catch (SDORuntimeException e)
+                    {
+                        // The input wrapper type is not known, create an open DataObject 
+                        inputDataObject = dataFactory->create(Type::SDOTypeNamespaceURI, "OpenDataObject");
+                    }
+                            
                     // Go through data object to set the input parameters
-                    PropertyList pl = requestDO->getType().getProperties();
+                    PropertyList pl = inputDataObject->getType().getProperties();
                 
                     if(pl.size() == 0)
                     {
-                        if(requestDO->getType().isOpenType() && requestDO->getType().isDataObjectType())
+                        if(inputDataObject->getType().isOpenType() && inputDataObject->getType().isDataObjectType())
                         {
                             /*
                              * This code deals with sending xsd:any elements
@@ -285,7 +298,7 @@
                             for (int i=0; i<operation.getNParms(); i++)
                             {
                                 string pname = "param" + (i+1);
-                                DataObjectList& l = requestDO->getList(pname);
+                                DataObjectList& l = inputDataObject->getList(pname);
                                 
                                 Operation::Parameter& parm = operation.getParameter(i);
                                 switch(parm.getType())
@@ -370,67 +383,67 @@
                             {
                             case Operation::BOOL: 
                                 {
-                                    requestDO->setBoolean(i, *(bool*)parm.getValue());
+                                    inputDataObject->setBoolean(i, *(bool*)parm.getValue());
                                     break;
                                 }
                             case Operation::SHORT: 
                                 {
-                                    requestDO->setShort(i, *(short*)parm.getValue());
+                                    inputDataObject->setShort(i, *(short*)parm.getValue());
                                     break;
                                 }
                             case Operation::INT: 
                                 {
-                                    requestDO->setInteger(i, *(int*)parm.getValue());
+                                    inputDataObject->setInteger(i, *(int*)parm.getValue());
                                     break;
                                 }
                             case Operation::LONG: 
                                 {
-                                    requestDO->setLong(i, *(long*)parm.getValue());
+                                    inputDataObject->setLong(i, *(long*)parm.getValue());
                                     break;
                                 }
                             case Operation::USHORT: 
                                 {
-                                    requestDO->setInteger(i, *(unsigned short*)parm.getValue());
+                                    inputDataObject->setInteger(i, *(unsigned short*)parm.getValue());
                                     break;
                                 }
                             case Operation::UINT: 
                                 {
-                                    requestDO->setInteger(i, *(unsigned int*)parm.getValue());
+                                    inputDataObject->setInteger(i, *(unsigned int*)parm.getValue());
                                     break;
                                 }
                             case Operation::ULONG: 
                                 {
-                                    requestDO->setInteger(i, *(unsigned long*)parm.getValue());
+                                    inputDataObject->setInteger(i, *(unsigned long*)parm.getValue());
                                     break;
                                 }
                             case Operation::FLOAT: 
                                 {
-                                    requestDO->setFloat(i, *(float*)parm.getValue());
+                                    inputDataObject->setFloat(i, *(float*)parm.getValue());
                                     break;
                                 }
                             case Operation::DOUBLE: 
                                 {
-                                    requestDO->setDouble(i, *(double*)parm.getValue());
+                                    inputDataObject->setDouble(i, *(double*)parm.getValue());
                                     break;
                                 }
                             case Operation::LONGDOUBLE: 
                                 {
-                                    requestDO->setDouble(i, *(long double*)parm.getValue());
+                                    inputDataObject->setDouble(i, *(long double*)parm.getValue());
                                     break;
                                 }
                             case Operation::CHARS: 
                                 {
-                                    requestDO->setCString(i, *(char**)parm.getValue());
+                                    inputDataObject->setCString(i, *(char**)parm.getValue());
                                     break;
                                 }
                             case Operation::STRING: 
                                 {
-                                    requestDO->setCString(i, (*(string*)parm.getValue()).c_str());
+                                    inputDataObject->setCString(i, (*(string*)parm.getValue()).c_str());
                                     break;
                                 }
                             case Operation::DATAOBJECT: 
                                 {
-                                    requestDO->setDataObject(i, *(DataObjectPtr*)parm.getValue());
+                                    inputDataObject->setDataObject(i, *(DataObjectPtr*)parm.getValue());
                                     break;
                                 }
                             default: throw "unsupported parameter type";
@@ -439,59 +452,80 @@
                     }
                     
                     // Create the Axiom object from the request dataobject
-                    AxiomHelper myHelper;
-                    requestOM = myHelper.toAxiomNode(requestDO);
+                    AxiomHelper* axiomHelper = AxiomHelper::getHelper();
+                    request_node = axiomHelper->toAxiomNode(inputDataObject,
+                        wsdlOperation.getInputTypeUri().c_str(), wsdlOperation.getInputTypeName().c_str());
+                    AxiomHelper::releaseHelper(axiomHelper);
                 }
                 else
                 {
                     // RPC
                 }
                 
-                // Logging start
-                axiom_xml_writer_t* xml_writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_FALSE, AXIS2_FALSE, AXIS2_XML_PARSER_TYPE_BUFFER);
-                axiom_output_t* om_output = axiom_output_create( env, xml_writer);
-                
-                AXIOM_NODE_SERIALIZE(requestOM, env, om_output);
-                axis2_char_t* buffer = (axis2_char_t*)AXIOM_XML_WRITER_GET_XML(xml_writer, env);         
-                LOGINFO_1(3, "Sending this OM node in XML : %s \n",  buffer); 
-                
-                AXIOM_OUTPUT_FREE(om_output, env);
-                AXIS2_FREE((env)->allocator, buffer);
-                // Logging end
+                char* str =  AXIOM_NODE_TO_STRING(request_node, env);
+                LOGINFO_1(3, "Sending this OM node in XML : %s \n",  str); 
                 
                 LOGEXIT(1, "Axis2Client::createPayload");
-                
-                return requestOM;
+                return request_node;
              }
              
              void Axis2Client::setReturn(axiom_node_t* ret_node,
                  Operation& operation, 
-                 const WSDLOperation& wsdlOp,
+                 const WSDLOperation& wsdlOperation,
                  axis2_env_t* env)
              {	
                  LOGENTRY(1, "Axis2Client::setReturn");
-                 /* Get the response value from the SOAP message */
-                 
-                 // logging start
-                 axiom_xml_writer_t* writer = axiom_xml_writer_create_for_memory(env, NULL, AXIS2_TRUE, 0, AXIS2_XML_PARSER_TYPE_BUFFER);
-                 axiom_output_t* om_output = axiom_output_create (env, writer);
-                 AXIOM_NODE_SERIALIZE (ret_node, env, om_output);
-                 axis2_char_t* buffer = (axis2_char_t*)AXIOM_XML_WRITER_GET_XML(writer, env);
-                 LOGINFO_1(3,"Received OM node in XML : %s\n", buffer);
-                 AXIOM_OUTPUT_FREE(om_output, env);
-                 AXIS2_FREE((env)->allocator, buffer);
-                 // Logging end
-                 
                  
-                 if (wsdlOp.isDocumentStyle())
+                 if (wsdlOperation.isDocumentStyle())
                  {
                      // Document style 
+                    DataFactoryPtr dataFactory = compositeReference->getComposite()->getDataFactory();
+
+                    // Get the AXIOM node representing the SOAP Body 
+                    axiom_node_t* body = AXIOM_NODE_GET_PARENT(ret_node, env);
                      
-                     DataFactoryPtr dataFactory = compositeReference->getComposite()->getDataFactory();
-                     AxiomHelper myHelper;
-                     DataObjectPtr returnDO = myHelper.toSdo(ret_node, dataFactory);
+                    // Convert the AXIOM node to an SDO DataObject
+                    char* str = NULL;
+                    str = AXIOM_NODE_TO_STRING(body, env);
+                    if (str)
+                    {
+                        AXIS2_LOG_INFO((env)->log, "Axis2Client invoke has response OM: %s\n", str);
+                    }
+
+                    // Convert the SOAP body to an SDO DataObject
+                    AxiomHelper* axiomHelper = AxiomHelper::getHelper();
+                    DataObjectPtr outputBodyDataObject = axiomHelper->toSdo(body, dataFactory);
+                    AxiomHelper::releaseHelper(axiomHelper);
+
+                    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;
+                    }                    
+
+                    // Get the first body part representing the doc-lit-wrapped wrapper element
+                    DataObjectPtr outputDataObject = NULL; 
+                    PropertyList bpl = outputBodyDataObject->getInstanceProperties();
+                    if (bpl.size()!=0)
+                    {
+                        if (bpl[0].isMany())
+                        {
+                            DataObjectList& parts = outputBodyDataObject->getList((unsigned int)0);
+                            outputDataObject = parts[0];
+                        }
+                        else
+                        {
+                            outputDataObject = outputBodyDataObject->getDataObject(bpl[0]);
+                        }
+                    }
+                    if (outputDataObject == NULL)
+                    {
+                        AXIS2_LOG_ERROR((env)->log, AXIS2_LOG_SI, "Axis2Client invoke: Could not convert body part to SDO");
+                        return;
+                    }
                      
-                    PropertyList pl = returnDO->getInstanceProperties();
+                    PropertyList pl = outputDataObject->getInstanceProperties();
                     unsigned int i = 0;
                      
                     switch(pl[i].getTypeEnum())
@@ -499,24 +533,22 @@
                     case Type::BooleanType:
                         {
                             bool* boolData = new bool;
-                            *boolData = returnDO->getBoolean(pl[i]);
-                            //printf("returnDO has BooleanType named %s with value %d\n", name, boolData);
+                            *boolData = outputDataObject->getBoolean(pl[i]);
                             operation.setReturnValue(boolData);
                         }
                         break;
                     case Type::ByteType:
                         {
                             char* byteData = new char;
-                            //printf("returnDO has ByteType named %s\n", name);
-                            *byteData = returnDO->getByte(pl[i]);
+                            *byteData = outputDataObject->getByte(pl[i]);
                             operation.setReturnValue(byteData);
                         }
                         break;
                     case Type::BytesType:
                         {
-                            int len = returnDO->getLength(pl[i]);
+                            int len = outputDataObject->getLength(pl[i]);
                             char* bytesData = new char[len+1];
-                            int bytesWritten = returnDO->getBytes(pl[i], bytesData, len);
+                            int bytesWritten = outputDataObject->getBytes(pl[i], bytesData, len);
                             // Ensure the bytes end with the null char. Not sure if this is neccessary
                             if(bytesWritten <= len)
                             {
@@ -526,7 +558,7 @@
                             {
                                 bytesData[len] = 0;
                             }
-                            //printf("returnDO has BytesType named %s with length %d\n", name, bytesWritten);
+                            //printf("outputDataObject has BytesType named %s with length %d\n", name, bytesWritten);
                             operation.setReturnValue(&bytesData);
                         }
                         break;
@@ -534,57 +566,49 @@
                         {
                             // This code should work but won't be used as there is no mapping from an XSD type to the SDO CharacterType
                             wchar_t* charData = new wchar_t;
-                            //printf("returnDO has CharacterType named %s\n", name);
-                            *charData = returnDO->getCharacter(pl[i]);
+                            *charData = outputDataObject->getCharacter(pl[i]);
                             operation.setReturnValue(charData);
                         }
                         break;
                     case Type::DoubleType:
                         {
                             long double* doubleData = new long double;
-                            *doubleData = returnDO->getDouble(pl[i]);
-                            //printf("returnDO has DoubleType named %s\n", name);            
+                            *doubleData = outputDataObject->getDouble(pl[i]);
                             operation.setReturnValue(doubleData);
                         }
                         break;
                     case Type::FloatType:
                         {
                             float* floatData = new float;
-                            *floatData = returnDO->getFloat(pl[i]);
-                            //printf("returnDO has FloatType named %s with value %f\n", name, *floatData);
+                            *floatData = outputDataObject->getFloat(pl[i]);
                             operation.setReturnValue(floatData); 
                         }
                         break;
                     case Type::IntegerType:
                         {
                             long* intData = new long;
-                            //printf("returnDO has IntegerType named %s\n", name);
-                            *intData = returnDO->getInteger(pl[i]);
+                            *intData = outputDataObject->getInteger(pl[i]);
                             operation.setReturnValue(intData);
                         }
                         break;
                     case Type::ShortType:
                         {
                             short* shortData = new short;
-                            //printf("returnDO has ShortType named %s\n", name);
-                            *shortData = returnDO->getShort(pl[i]);
+                            *shortData = outputDataObject->getShort(pl[i]);
                             operation.setReturnValue(shortData);
                         }
                         break;
                     case Type::StringType:
                         {
                             const char** stringData = new const char*; 
-                            string* str = new string(returnDO->getCString(pl[i]));
+                            string* str = new string(outputDataObject->getCString(pl[i]));
                             *stringData = str->c_str();
-                            //printf("returnDO has StringType named %s with value %s\n", name, stringData);
                             operation.setReturnValue(stringData);
                         }
                         break;
                     case Type::DataObjectType:
                         {
-                            DataObjectPtr dataObjectData = returnDO->getDataObject(pl[i]);
-                            //printf("returnDO has DataObjectType named %s (#%d)\n", name, dataObjectData);
-            
+                            DataObjectPtr dataObjectData = outputDataObject->getDataObject(pl[i]);
                             if(!dataObjectData)
                             {
                                 LOGINFO(4, "SDO DataObject return value was null");
@@ -599,8 +623,7 @@
                              * Get each element as a DataObject and add in to the parameter list
                              */
             
-                            //printf("returnDO has OpenDataObjectType named %s\n", name);
-                            DataObjectList& dataObjectList = returnDO->getList(pl[i]);
+                            DataObjectList& dataObjectList = outputDataObject->getList(pl[i]);
                             
                             for(int j=0; j<dataObjectList.size(); j++)
                             {

Modified: incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.cpp?view=diff&rev=449327&r1=449326&r2=449327
==============================================================================
--- incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.cpp (original)
+++ incubator/tuscany/cpp/sca/runtime/extensions/ws/reference/axis2c/src/tuscany/sca/ws/WSServiceWrapper.cpp Sat Sep 23 15:58:02 2006
@@ -25,8 +25,13 @@
 #include "WSServiceWrapper.h"
 #include "tuscany/sca/core/Operation.h"
 #include "tuscany/sca/model/Service.h"
+#include "tuscany/sca/model/Component.h"
+#include "tuscany/sca/model/Composite.h"
 #include "tuscany/sca/model/ServiceType.h"
 
+#include "commonj/sdo/SDO.h"
+using namespace commonj::sdo;
+
 using namespace tuscany::sca;
 using namespace tuscany::sca::model;
 
@@ -39,6 +44,29 @@
             
             WSServiceWrapper::WSServiceWrapper(Service* service) : ServiceWrapper(service)
             {
+                // Define the SOAP Body type and element to allow a SOAP body to
+                // be loaded in a DataObject
+                DataFactoryPtr dataFactory = service->getComponent()->getComposite()->getDataFactory();
+                try {
+                    const Type& bodyType = dataFactory->getType("http://www.w3.org/2003/05/soap-envelope", "Body");
+                } catch (SDORuntimeException e)
+                {
+                    dataFactory->addType("http://www.w3.org/2003/05/soap-envelope", "RootType", false, false, false);                
+                    dataFactory->addType("http://www.w3.org/2003/05/soap-envelope", "Body", false, true, false);                
+                    dataFactory->addPropertyToType(
+                        "http://www.w3.org/2003/05/soap-envelope", "RootType",
+                        "Body",
+                        "http://www.w3.org/2003/05/soap-envelope", "Body",
+                        false, false, true);
+    
+                    dataFactory->addType("http://schemas.xmlsoap.org/soap/envelope/", "RootType", false, false, false);
+                    dataFactory->addType("http://schemas.xmlsoap.org/soap/envelope/", "Body", false, true, false);
+                    dataFactory->addPropertyToType(
+                        "http://schemas.xmlsoap.org/soap/envelope/", "RootType",
+                        "Body",
+                        "http://schemas.xmlsoap.org/soap/envelope/", "Body",
+                        false, false, true);
+                }
             }
             
             WSServiceWrapper::~WSServiceWrapper()

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=449327&r1=449326&r2=449327
==============================================================================
--- 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 Sat Sep 23 15:58:02 2006
@@ -28,6 +28,8 @@
 #include <sdo_axiom.h>
 using commonj::sdo::DataObjectPtr;
 using commonj::sdo::DataFactoryPtr;
+using commonj::sdo::DataObjectList;
+using commonj::sdo::PropertyList;
 using commonj::sdo_axiom::AxiomHelper;
 
 #include "tuscany/sca/util/Exceptions.h"
@@ -196,7 +198,7 @@
 
 
 /*
- * This method invokes the right service method 
+ * This method invokes the target service method 
  */
 axiom_node_t* AXIS2_CALL
 Axis2Service_invoke(axis2_svc_skeleton_t *svc_skeleton,
@@ -204,11 +206,6 @@
             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)
@@ -264,14 +261,6 @@
                         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();
@@ -357,26 +346,51 @@
                     }
 
                     // Convert the input AXIOM node to an SDO DataObject
-                    DataObjectPtr inputDataObject = axiomHelper->toSdo(
-                            node, dataFactory, wsdlOperation.getInputTypeUri().c_str());
+                    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);
+                    }
 
-                    //printf("Axis2ServiceType inputDataObject: (%d)\n", inputDataObject);
+                    // Convert the SOAP body to an SDO DataObject
+                    AxiomHelper* axiomHelper = AxiomHelper::getHelper();
+                    
+                    DataObjectPtr inputBodyDataObject = axiomHelper->toSdo(body, dataFactory);
 
-                    if(!inputDataObject)
+                    if(!inputBodyDataObject)
                     {
                         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;
                     }                    
 
-                    //
+                    // 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 (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");
@@ -384,20 +398,22 @@
                         /** 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());
 
-					returnNode = axiomHelper->toAxiomNode(outputDataObject);
-						
-                    om_str = NULL;
-                    om_str = AXIOM_NODE_TO_STRING(returnNode, env);
-                    if (om_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", om_str);
+                        AXIS2_LOG_INFO((env)->log, "Axis2Service invoke has response OM : %s\n", str);
                     }
                         
-					AxiomHelper::releaseHelper(axiomHelper);												
 
                 	//LOGEXIT(1, "Axis2Service_invoke");						
-					return returnNode;
+					return outputNode;
                 }
             }
         }
@@ -407,7 +423,7 @@
     //LOGERROR(0, "Axis2Service service ERROR: invalid OM parameters in request\n");
     
     /** TODO: return a SOAP fault here */
-    return node;
+    return 0;
 }
 
 

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=449327&r1=449326&r2=449327
==============================================================================
--- 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 Sat Sep 23 15:58:02 2006
@@ -60,6 +60,33 @@
                 WSReferenceBinding* referenceBinding = (WSReferenceBinding*)reference->getBinding();
                 serviceWrapper = referenceBinding->getTargetServiceBinding()->getServiceWrapper();
                 
+                // Define the SOAP Body type and element to allow a SOAP body to
+                // be loaded in a DataObject
+                DataFactoryPtr dataFactory = reference->getComponent()->getComposite()->getDataFactory();
+                try {
+                    const Type& bodyType = dataFactory->getType("http://www.w3.org/2003/05/soap-envelope", "Body");
+                } catch (SDORuntimeException e)
+                {
+                    
+                    // Define the SOAP 1.2 Body type
+                    dataFactory->addType("http://www.w3.org/2003/05/soap-envelope", "RootType", false, false, false);                
+                    dataFactory->addType("http://www.w3.org/2003/05/soap-envelope", "Body", false, true, false);                
+                    dataFactory->addPropertyToType(
+                        "http://www.w3.org/2003/05/soap-envelope", "RootType",
+                        "Body",
+                        "http://www.w3.org/2003/05/soap-envelope", "Body",
+                        false, false, true);
+    
+                    // Define the SOAP 1.1 Body type
+                    dataFactory->addType("http://schemas.xmlsoap.org/soap/envelope/", "RootType", false, false, false);
+                    dataFactory->addType("http://schemas.xmlsoap.org/soap/envelope/", "Body", false, true, false);
+                    dataFactory->addPropertyToType(
+                        "http://schemas.xmlsoap.org/soap/envelope/", "RootType",
+                        "Body",
+                        "http://schemas.xmlsoap.org/soap/envelope/", "Body",
+                        false, false, true);
+                }
+                
                 LOGEXIT(1,"WSServiceProxy::constructor");
             }
             
@@ -79,10 +106,6 @@
             {
                 LOGENTRY(1,"WSServiceProxy::invoke");
     
-                //printf("inputDataObject %s#%s\n", inputDataObject->getType().getURI(), inputDataObject->getType().getName());
-                //Utils::printType(inputDataObject->getType());
-                //Utils::printDO(inputDataObject);
-            
                 Reference* reference = getReference();
                 Component* component = reference->getComponent();
                 Composite* composite = component ->getComposite();
@@ -114,7 +137,7 @@
                         // Create new Operation object and set parameters and return value
                         Operation operation(wsdlOperation.getOperationName().c_str());
                     
-                        // Go through input data object to set the operation parameters
+                        // Go through the input data object to set the operation parameters
                         PropertyList pl = inputDataObject->getInstanceProperties();
                     
                         for(int i=0; i<pl.size(); i++)
@@ -127,14 +150,12 @@
                                 {
                                     bool* boolData = new bool;
                                     *boolData = inputDataObject->getBoolean(pl[i]);
-                                    //printf("inputDataObject has BooleanType named %s with value %d\n", name, boolData);
                                     operation.addParameter(boolData);
                                 }
                                 break;
                             case Type::ByteType:
                                 {
                                     char* byteData = new char;
-                                    //printf("inputDataObject has ByteType named %s\n", name);
                                     *byteData = inputDataObject->getByte(pl[i]);
                                     operation.addParameter(byteData);
                                 }
@@ -153,7 +174,6 @@
                                     {
                                         bytesData[len] = 0;
                                     }
-                                    //printf("inputDataObject has BytesType named %s with length %d\n", name, bytesWritten);
                                     operation.addParameter(&bytesData);
                                 }
                                 break;
@@ -161,7 +181,6 @@
                                 {
                                     // This code should work but won't be used as there is no mapping from an XSD type to the SDO CharacterType
                                     wchar_t* charData = new wchar_t;
-                                    //printf("inputDataObject has CharacterType named %s\n", name);
                                     *charData = inputDataObject->getCharacter(pl[i]);
                                     operation.addParameter(charData);
                                 }
@@ -170,7 +189,6 @@
                                 {
                                     long double* doubleData = new long double;
                                     *doubleData = inputDataObject->getDouble(pl[i]);
-                                    //printf("inputDataObject has DoubleType named %s\n", name);            
                                     operation.addParameter(doubleData);
                                 }
                                 break;
@@ -185,7 +203,6 @@
                             case Type::IntegerType:
                                 {
                                     long* intData = new long;
-                                    //printf("inputDataObject has IntegerType named %s\n", name);
                                     *intData = inputDataObject->getInteger(pl[i]);
                                     operation.addParameter(intData);
                                 }
@@ -193,7 +210,6 @@
                             case Type::ShortType:
                                 {
                                     short* shortData = new short;
-                                    //printf("inputDataObject has ShortType named %s\n", name);
                                     *shortData = inputDataObject->getShort(pl[i]);
                                     operation.addParameter(shortData);
                                 }
@@ -202,14 +218,12 @@
                                 {
                                     const char** stringData = new const char*; 
                                     *stringData = inputDataObject->getCString(pl[i]);
-                                    //printf("inputDataObject has StringType named %s with value %s\n", name, stringData);
                                     operation.addParameter(stringData);
                                 }
                                 break;
                             case Type::DataObjectType:
                                 {
                                     DataObjectPtr dataObjectData = inputDataObject->getDataObject(pl[i]);
-                                    //printf("inputDataObject has DataObjectType named %s (#%d)\n", name, dataObjectData);
                     
                                     if(!dataObjectData)
                                     {
@@ -308,17 +322,21 @@
                             serviceWrapper->invoke(operation);
                     
                             // Set the data in the outputDataObject to be returned
-                            DataObjectPtr outputDataObject = dataFactoryPtr->create(outputTypeURI, outputTypeName);
+                            DataObjectPtr outputDataObject;
+                            try
+                            {
+                                
+                                // Create the output wrapper
+                                const Type& outputType = dataFactoryPtr->getType(outputTypeURI, outputTypeName);
+                                outputDataObject = dataFactoryPtr->create(outputType);
+                            }
+                            catch (SDORuntimeException e)
+                            {
+                                // The output wrapper type is not known, create an open DataObject 
+                                outputDataObject = dataFactoryPtr->create(Type::SDOTypeNamespaceURI, "OpenDataObject");
+                            }
                             
-                            //const Type& rootType = dataFactoryPtr->getType(outputDataObject->getType().getURI(), "RootType");
-                            //printf("rootType %s#%s\n", rootType.getURI(), rootType.getName());
-                            //Utils::printType(rootType);
-                            //printf("outputDataObject %s#%s\n", outputDataObject->getType().getURI(), outputDataObject->getType().getName());
-                            //Utils::printType(outputDataObject->getType());
-
                             setOutputData(operation, outputDataObject, dataFactoryPtr);                            
-
-                            Utils::printDO(outputDataObject);
 
                             LOGEXIT(1,"WSServiceProxy::invoke");
                         



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