You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by su...@apache.org on 2003/10/01 14:47:40 UTC
cvs commit: ws-axis/c/src/server/samples/cppservicewrapper CPPServiceWrapper.cpp CPPServiceWrapper.hpp
susantha 2003/10/01 05:47:40
Modified: c/src/client Call.cpp Call.h
c/src/client/samples/Calculator Calculator.cpp Calculator.h
Point.cpp Point.h
c/src/client/samples/CalculatorC Calculator.cpp Calculator.h
Point.cpp Point.h
c/src/common IArrayBean.h IParam.h Param.cpp
c/src/server/samples/cppservice PPService.cpp PPService.h
c/src/server/samples/cppservicewrapper CPPServiceWrapper.cpp
CPPServiceWrapper.hpp
Log:
Improved the Call class so that it supports passing and returning arrays by the
client applications. Changed few places in the code base too as required.
Revision Changes Path
1.10 +178 -19 ws-axis/c/src/client/Call.cpp
Index: Call.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/Call.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- Call.cpp 29 Sep 2003 03:33:52 -0000 1.9
+++ Call.cpp 1 Oct 2003 12:47:40 -0000 1.10
@@ -83,6 +83,8 @@
m_Soap.so.http.ip_headers = NULL;
initialize_module(0, WSDDFILEPATH);
m_pTransport = NULL;
+ m_nReturnType = XSD_UNKNOWN;
+ m_nArrayType = XSD_UNKNOWN;
}
Call::~Call()
@@ -176,10 +178,14 @@
pRetParam->SetName(pchName);
}
-void Call::AddParameter(IArrayBean *pArrayBean, const char* pchName)
+void Call::AddParameter(Axis_Array* pArray, void* pSZFunct, void* pDelFunct, void* pSizeFunct, const char* pchTypeName)
{
- IParam* pRetParam = m_pIWSSZ->AddOutputParam(pArrayBean);
- pRetParam->SetName(pchName);
+ IArrayBean* pAb = m_pIWSSZ->makeArrayBean((void*)(pArray->m_Array), pSZFunct, pDelFunct, pDelFunct);
+ pAb->AddDimension(pArray->m_Size);
+ pAb->SetItemName("item");
+ pAb->SetTypeName(pchTypeName);
+ IParam* pRetParam = m_pIWSSZ->AddOutputParam(pAb);
+ pRetParam->SetName(pchTypeName);
}
void Call::AddParameter(void *pObject, void *pSZFunct, void *pDelFunct, const char* pchName)
@@ -193,45 +199,100 @@
m_nReturnType = nType;
}
-void Call::SetReturnType(void *pObject, void *pDZFunct, void *pDelFunct, const char* pchTypeName, const char * pchUri)
+void Call::SetReturnType(void *pDZFunct, void* pCreFunct, void *pDelFunct, const char* pchTypeName, const char * pchUri)
{
m_nReturnType = USER_TYPE;
- m_ReturnCplxObj.pObject = pObject;
+ m_ReturnCplxObj.pObject = NULL;
+ m_ReturnCplxObj.pDZFunct = (AXIS_DESERIALIZE_FUNCT)pDZFunct;
+ m_ReturnCplxObj.pCreFunct = (AXIS_OBJECT_CREATE_FUNCT)pCreFunct;
+ m_ReturnCplxObj.pDelFunct = (AXIS_OBJECT_DELETE_FUNCT)pDelFunct;
+ m_ReturnCplxObj.m_TypeName = pchTypeName;
+ m_ReturnCplxObj.m_URI = pchUri;
+}
+
+/**
+ * This function is used to set that the return type is an array of complex types
+ */
+void Call::SetReturnType(Axis_Array* pArray, void* pDZFunct, void* pCreFunct, void* pDelFunct, const char* pchTypeName, const char* pchUri)
+{
+ m_pArray = pArray;
+ m_nReturnType = XSD_ARRAY;
+ m_nArrayType = USER_TYPE;
m_ReturnCplxObj.pDZFunct = (AXIS_DESERIALIZE_FUNCT)pDZFunct;
+ m_ReturnCplxObj.pCreFunct = (AXIS_OBJECT_CREATE_FUNCT)pCreFunct;
m_ReturnCplxObj.pDelFunct = (AXIS_OBJECT_DELETE_FUNCT)pDelFunct;
m_ReturnCplxObj.m_TypeName = pchTypeName;
m_ReturnCplxObj.m_URI = pchUri;
}
+/**
+ * This function is used to set that the return type is an array of basic types.
+ * @param pArray Array to which the deserialized object array is set an returned
+ * to the client application.
+ * @param nType Basic type of the array elements
+ */
+void Call::SetReturnType(Axis_Array* pArray, XSDTYPE nType)
+{
+ m_pArray = pArray;
+ m_nReturnType = XSD_ARRAY;
+ m_nArrayType = nType;
+}
+
int Call::Invoke()
{
int nStatus;
Param *pParam = NULL;
if (SUCCESS == (nStatus = m_pAxisEngine->Process(&m_Soap)))
{
- if (m_nReturnType == USER_TYPE)
+ if (USER_TYPE == m_nReturnType)
{
/*
- The first element of the soap message (after the soap
- body element) is taken as a parameter itself so that
- the return type can be checked. So need to call GetParam
+ The second element of the soap message (after the method element)
+ is taken as a parameter. But if it is a custom type remove the
+ wrapper element that describes the type. Optionally you can check
+ whether the returned type is of expected type.
on the deserializer before getting the actual params
*/
pParam = (Param*)m_pIWSDZ->GetParam();
-
-// if (pParam && (m_ReturnCplxObj.m_TypeName == pParam->GetTypeName()))
-// {
+ /*
+ Following lines check whether the returned type is expected type or not.
+ But this type checking is optional. So commented.
+ if (pParam && (m_ReturnCplxObj.m_TypeName == pParam->GetTypeName()))
+ {
m_ReturnCplxObj.pDZFunct(m_ReturnCplxObj.pObject, m_pMsgData->m_pDZ);
-// }
-// else
-// {
-// return FAIL;
-// }
+ }
+ else
+ {
+ return FAIL;
+ }
+ */
+ if (!m_ReturnCplxObj.pCreFunct || !m_ReturnCplxObj.pDZFunct)
+ return FAIL;
+ m_ReturnCplxObj.pObject = m_ReturnCplxObj.pCreFunct();
+ if (!m_ReturnCplxObj.pObject)
+ return FAIL;
+ m_ReturnCplxObj.pDZFunct(m_ReturnCplxObj.pObject, m_pMsgData->m_pDZ);
}
- else if (m_nReturnType == XSD_ARRAY)
+ else if (XSD_ARRAY == m_nReturnType)
{
-
+ IParam *param0 = m_pIWSDZ->GetParam();
+ /* now we know that this is an array. if needed we can check that too */
+ if (!m_pArray) return FAIL; //No array expected ?
+ m_pArray->m_Size = param0->GetArraySize();
+ if (m_pArray->m_Size > 0)
+ {
+ if (SUCCESS == MakeArray()) //Array is allocated successfully
+ {
+ if (USER_TYPE == m_nArrayType)
+ param0->SetArrayElements((void*)(m_pArray->m_Array), m_ReturnCplxObj.pDZFunct, m_ReturnCplxObj.pDelFunct, m_ReturnCplxObj.pSizeFunct);
+ else
+ param0->SetArrayElements((void*)(m_pArray->m_Array));
+ m_pIWSDZ->Deserialize(param0,0);
+ }
+ }
+ else
+ return FAIL; //CF_ZERO_ARRAY_SIZE_ERROR
}
else //basic type
{
@@ -247,8 +308,26 @@
return m_uReturnValue;
}
+void Call::GetResult(void** pReturn)
+{
+ if (m_ReturnCplxObj.pObject)
+ {
+ *pReturn = m_ReturnCplxObj.pObject;
+ m_ReturnCplxObj.pObject = NULL; //note that returned object is handed over to the client.
+ }
+ else
+ {
+ *pReturn = NULL;
+ }
+}
+
int Call::Initialize()
{
+ /*
+ Initialize re-usable objects of this instance (objects may have been populated by
+ the previous call.
+ */
+ InitializeObjects();
m_Soap.sessionid = "somesessionid1234";
if (SUCCESS != OpenConnection()) return FAIL;
if (m_pAxisEngine) delete m_pAxisEngine;
@@ -271,6 +350,20 @@
return FAIL;
}
+void Call::InitializeObjects()
+{
+ m_nReturnType = XSD_UNKNOWN;
+ m_pArray = NULL;
+ m_nArrayType = XSD_UNKNOWN;
+ m_ReturnCplxObj.m_TypeName = "";
+ m_ReturnCplxObj.m_URI = "";
+ m_ReturnCplxObj.pCreFunct = NULL;
+ m_ReturnCplxObj.pDelFunct = NULL;
+ m_ReturnCplxObj.pObject = NULL;
+ m_ReturnCplxObj.pSizeFunct = NULL;
+ m_ReturnCplxObj.pSZFunct = NULL;
+}
+
int Call::UnInitialize()
{
if (m_pAxisEngine)
@@ -322,3 +415,69 @@
{
m_pIWSSZ->setSoapVersion(version);
}
+
+/**
+ * This function will create (allocate memory) to an array of objects depending on
+ * the information available in m_pArray and m_nArrayType. Basically it gets the
+ * array size from m_pArray->m_Size and element type from m_nArrayType. In case of
+ * complex types it uses the Create function provided in m_ReturnCplxObj structure
+ */
+int Call::MakeArray()
+{
+ if (USER_TYPE == m_nArrayType)
+ {
+ m_pArray->m_Array = m_ReturnCplxObj.pCreFunct(true, m_pArray->m_Size);
+ }
+ else
+ {
+ switch (m_nArrayType)
+ {
+ case XSD_INT:
+ case XSD_UNSIGNEDINT:
+ m_pArray->m_Array = new int[m_pArray->m_Size];
+ break;
+ case XSD_FLOAT:
+ m_pArray->m_Array = new float[m_pArray->m_Size];
+ break;
+ case XSD_STRING:
+ case XSD_HEXBINARY:
+ case XSD_BASE64BINARY:
+ case XSD_ANYURI:
+ case XSD_QNAME:
+ case XSD_NOTATION:
+ m_pArray->m_Array = new AxisString[m_pArray->m_Size];
+ break;
+ case XSD_LONG:
+ case XSD_UNSIGNEDLONG:
+ case XSD_INTEGER:
+ case XSD_DURATION:
+ m_pArray->m_Array = new long[m_pArray->m_Size];
+ break;
+ case XSD_SHORT:
+ case XSD_UNSIGNEDSHORT:
+ m_pArray->m_Array = new short[m_pArray->m_Size];
+ break;
+ case XSD_BYTE:
+ case XSD_UNSIGNEDBYTE:
+ m_pArray->m_Array = new char[m_pArray->m_Size];
+ break;
+ case XSD_DOUBLE:
+ case XSD_DECIMAL:
+ m_pArray->m_Array = new double[m_pArray->m_Size];
+ break;
+ case XSD_DATETIME:
+ case XSD_TIME:
+ case XSD_DATE:
+ case XSD_YEARMONTH:
+ case XSD_YEAR:
+ case XSD_MONTHDAY:
+ case XSD_DAY:
+ case XSD_MONTH:
+ m_pArray->m_Array = new tm[m_pArray->m_Size];
+ break;
+ default:
+ return FAIL;
+ }
+ }
+ return SUCCESS;
+}
\ No newline at end of file
1.8 +46 -3 ws-axis/c/src/client/Call.h
Index: Call.h
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/Call.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Call.h 29 Sep 2003 03:33:52 -0000 1.7
+++ Call.h 1 Oct 2003 12:47:40 -0000 1.8
@@ -81,13 +81,24 @@
int UnInitialize();
int Initialize();
uParamValue GetResult();
+ void GetResult(void** pReturn);
int Invoke();
- void SetReturnType(void* pObject, void* pDZFunct, void* pDelFunct, const char * theType, const char * uri);
+
+ /* Method to set that the return type is complex type */
+ void SetReturnType(void* pDZFunct, void* pCreFunct, void* pDelFunct, const char* pchTypeName, const char* pchUri);
+ /* Method to set that the return type is an array of complex types */
+ void SetReturnType(Axis_Array* pArray, void* pDZFunct, void* pCreFunct, void* pDelFunct, const char* pchTypeName, const char* pchUri);
+ /* Method to set that the return type is an array of basic types */
+ void SetReturnType(Axis_Array* pArray, XSDTYPE nType);
+ /* Method to set that the return type is basic type */
void SetReturnType(XSDTYPE nType);
+ /* Method for adding complex parameters */
void AddParameter(void* pObject, void* pSZFunct, void* pDelFunct, const char* pchName);
- void AddParameter(IArrayBean* pArrayBean, const char* pchName);
+ /* Method for adding array parameters */
+ void AddParameter(Axis_Array* pArray, void* pSZFunct, void* pDelFunct, void* pSizeFunct, const char* pchTypeName);
+ /* Methods for adding parameters of basic types */
void AddParameter(int nValue,const char* pchName);
void AddParameter(unsigned int unValue,const char* pchName);
void AddParameter(short sValue,const char* pchName);
@@ -101,24 +112,56 @@
void AddParameter(struct tm tValue,const char* pchName);
void AddParameter(const AxisChar* pStrValue,const char* pchName);
+ /* Method that set the remote method name */
void SetOperation(const char* pchOperation, const char* pchNamespace);
- void SetOperation(const char* pchOperation, const char* pchNamespace,const char* pchName);
int SetEndpointURI(const char* pchEndpointURI);
Call();
virtual ~Call();
private:
int OpenConnection();
void CloseConnection();
+ void InitializeObjects();
+ int MakeArray();
+
private:
ClientAxisEngine* m_pAxisEngine;
uParamValue m_uReturnValue;
+ /*
+ Following are pointers to relevant objects of the ClientAxisEngine instance
+ So they do not belong to this object and are not created or deleted
+ */
MessageData* m_pMsgData;
SoapSerializer* m_pIWSSZ;
SoapDeSerializer* m_pIWSDZ;
+ /*
+ Return type of the remote method being called
+ */
XSDTYPE m_nReturnType;
+ /*
+ m_ReturnCplxObj is populated with the relevant function pointers to manipulate
+ a custom type when the return type of a method call is a custom type or an array
+ of custom types.
+ */
ComplexObjectHandler m_ReturnCplxObj;
+ /*
+ m_Soap contains transport related information and function pointers to manipulate
+ transport layer.
+ */
Ax_soapstream m_Soap;
+ /*
+ Transport object
+ */
AxisTransport* m_pTransport;
+ /*
+ m_pArray will hold the Array object passed by the client application and will be
+ populated with deserialized elements when the response arrives.
+ */
+ Axis_Array* m_pArray;
+ /*
+ m_nArrayType will contain the type of an array element when the called method returns
+ and array.
+ */
+ XSDTYPE m_nArrayType;
};
#endif // !defined(AFX_CALL_H__D13E5626_0A9B_43EA_B606_364B98CEDAA8__INCLUDED_)
1.13 +28 -9 ws-axis/c/src/client/samples/Calculator/Calculator.cpp
Index: Calculator.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/samples/Calculator/Calculator.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Calculator.cpp 30 Sep 2003 09:04:54 -0000 1.12
+++ Calculator.cpp 1 Oct 2003 12:47:40 -0000 1.13
@@ -10,6 +10,7 @@
#include <IParam.h>
extern int Axis_DeSerialize_Point(Point* param, IWrapperSoapDeSerializer *pDZ);
+extern void* Axis_Create_Point(bool bArray = false, int nSize=0);
extern void Axis_Delete_Point(Point* param, bool bArray = false, int nSize=0);
extern int Axis_Serialize_Point(Point* param, IWrapperSoapSerializer& pSZ, bool bArray = false);
extern int Axis_GetSize_Point(Point* param);
@@ -30,8 +31,7 @@
/* The value for SOAPAction is specified in the binding section of the WSDL */
m_pCall->SetHeader("SOAPAction", "servicename");
/* End point URI too can be taken from WSDL */
- //m_pCall->SetEndpointURI("http://192.168.101.10:80/axis/Calculator");
- m_pCall->SetEndpointURI("http://192.168.101.4:5555/axis/Calculator");
+ m_pCall->SetEndpointURI("http://192.168.101.10/axis/Calculator");
}
Calculator::~Calculator()
@@ -42,16 +42,16 @@
int Calculator::Add(int a, int b)
{
int nStatus;
+ int ret = 0;
/* Following will establish the connections with the server too */
if (SUCCESS != m_pCall->Initialize())
- return 0;
+ return ret;
m_pCall->SetSOAPVersion(SOAP_VER_1_1);
/* This should be done before adding parameters or return type */
m_pCall->SetOperation("Add", "http://www.opensource.lk/");
m_pCall->AddParameter(a, "a");
m_pCall->AddParameter(b, "b");
m_pCall->SetReturnType(XSD_INT);
- int ret = 0;
nStatus = m_pCall->Invoke();
if (SUCCESS == nStatus)
{
@@ -68,19 +68,38 @@
Point* Calculator::AddPoint(Point* p1, Point* p2)
{
int nStatus;
+ Point* pReturn = NULL;
if (SUCCESS != m_pCall->Initialize()) return NULL;
m_pCall->SetSOAPVersion(SOAP_VER_1_1);
m_pCall->SetOperation("AddPoint", "http://www.opensource.lk/");//this should be done before adding parameters or return type
m_pCall->AddParameter(p1, (void*) Axis_Serialize_Point, (void*) Axis_Delete_Point, "p1");
m_pCall->AddParameter(p2, (void*) Axis_Serialize_Point, (void*) Axis_Delete_Point, "p2");
- Point* pReturn = new Point();
- m_pCall->SetReturnType(pReturn, (void*) Axis_DeSerialize_Point, (void*) Axis_Delete_Point, Axis_TypeName_Point, Axis_URI_Point);
+ m_pCall->SetReturnType((void*) Axis_DeSerialize_Point, (void*) Axis_Create_Point, (void*) Axis_Delete_Point, Axis_TypeName_Point, Axis_URI_Point);
nStatus = m_pCall->Invoke();
- if (SUCCESS != nStatus)
+ if (SUCCESS == nStatus)
{
- delete pReturn;
- pReturn = NULL;
+ m_pCall->GetResult((void**)&pReturn);
}
m_pCall->UnInitialize();
return pReturn;
}
+
+Axis_Point_Array Calculator::EchoPointArray(Axis_Point_Array Array)
+{
+ int nStatus;
+ Axis_Point_Array RetArray = {NULL, 0};
+ if (SUCCESS != m_pCall->Initialize()) return RetArray;
+ m_pCall->SetSOAPVersion(SOAP_VER_1_1);
+ m_pCall->SetOperation("EchoPointArray", "http://www.opensource.lk/");//this should be done before adding parameters or return type
+ m_pCall->AddParameter((Axis_Array*)(&Array), (void*) Axis_Serialize_Point, (void*) Axis_Delete_Point, (void*) Axis_GetSize_Point, Axis_TypeName_Point);
+ m_pCall->SetReturnType((Axis_Array*)(&RetArray), (void*) Axis_DeSerialize_Point, (void*) Axis_Create_Point, (void*) Axis_Delete_Point, Axis_TypeName_Point, Axis_URI_Point);
+ nStatus = m_pCall->Invoke();
+ if (SUCCESS != nStatus)
+ {
+ delete RetArray.m_Array;
+ RetArray.m_Array = NULL;
+ RetArray.m_Size = 0;
+ }
+ m_pCall->UnInitialize();
+ return RetArray;
+}
\ No newline at end of file
1.3 +1 -0 ws-axis/c/src/client/samples/Calculator/Calculator.h
Index: Calculator.h
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/samples/Calculator/Calculator.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Calculator.h 26 Sep 2003 04:33:02 -0000 1.2
+++ Calculator.h 1 Oct 2003 12:47:40 -0000 1.3
@@ -17,6 +17,7 @@
virtual ~Calculator();
int Add(int a, int b);
Point* AddPoint(Point* p1, Point* p2);
+ Axis_Point_Array EchoPointArray(Axis_Point_Array Array);
};
#endif // !defined(AFX_CALCULATOR_H__B5394466_ACFF_4962_B259_B0891BBB4775__INCLUDED_)
1.3 +8 -0 ws-axis/c/src/client/samples/Calculator/Point.cpp
Index: Point.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/samples/Calculator/Point.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Point.cpp 29 Sep 2003 03:33:52 -0000 1.2
+++ Point.cpp 1 Oct 2003 12:47:40 -0000 1.3
@@ -15,6 +15,14 @@
return SUCCESS;
}
+void* Axis_Create_Point(bool bArray = false, int nSize=0)
+{
+ if (bArray && (nSize > 0))
+ return new Point[nSize];
+ else
+ return new Point;
+}
+
void Axis_Delete_Point(Point* p, bool bArray = false, int nSize=0)
{
if (bArray)
1.2 +6 -0 ws-axis/c/src/client/samples/Calculator/Point.h
Index: Point.h
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/samples/Calculator/Point.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Point.h 26 Sep 2003 04:33:02 -0000 1.1
+++ Point.h 1 Oct 2003 12:47:40 -0000 1.2
@@ -8,4 +8,10 @@
int y;
};
+typedef struct Axis_Point_ArrayTag
+{
+ Point* m_Array;
+ int m_Size;
+} Axis_Point_Array;
+
#endif //__POINT_PARAM_H__INCLUDED_
1.3 +32 -10 ws-axis/c/src/client/samples/CalculatorC/Calculator.cpp
Index: Calculator.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/samples/CalculatorC/Calculator.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Calculator.cpp 29 Sep 2003 03:33:52 -0000 1.2
+++ Calculator.cpp 1 Oct 2003 12:47:40 -0000 1.3
@@ -10,6 +10,7 @@
#include <IParam.h>
extern int Axis_DeSerialize_Point(Point* param, IWrapperSoapDeSerializer *pDZ);
+extern void* Axis_Create_Point(bool bArray = false, int nSize=0);
extern void Axis_Delete_Point(Point* param, bool bArray = false, int nSize=0);
extern int Axis_Serialize_Point(Point* param, IWrapperSoapSerializer& pSZ, bool bArray = false);
extern int Axis_GetSize_Point(Point* param);
@@ -30,7 +31,7 @@
/* The value for SOAPAction is specified in the binding section of the WSDL */
m_pCall->SetHeader("SOAPAction", "servicename");
/* End point URI too can be taken from WSDL */
- m_pCall->SetEndpointURI("http://localhost:8080/axis/Calculator");
+ m_pCall->SetEndpointURI("http://192.168.101.10/axis/Calculator");
}
Calculator::~Calculator()
@@ -41,15 +42,16 @@
int Calculator::Add(int a, int b)
{
int nStatus;
+ int ret = 0;
/* Following will establish the connections with the server too */
if (SUCCESS != m_pCall->Initialize())
- return 0;
+ return ret;
+ m_pCall->SetSOAPVersion(SOAP_VER_1_1);
/* This should be done before adding parameters or return type */
m_pCall->SetOperation("Add", "http://www.opensource.lk/");
m_pCall->AddParameter(a, "a");
m_pCall->AddParameter(b, "b");
m_pCall->SetReturnType(XSD_INT);
- int ret = 0;
nStatus = m_pCall->Invoke();
if (SUCCESS == nStatus)
{
@@ -66,18 +68,38 @@
Point* Calculator::AddPoint(Point* p1, Point* p2)
{
int nStatus;
+ Point* pReturn = NULL;
if (SUCCESS != m_pCall->Initialize()) return NULL;
+ m_pCall->SetSOAPVersion(SOAP_VER_1_1);
m_pCall->SetOperation("AddPoint", "http://www.opensource.lk/");//this should be done before adding parameters or return type
- m_pCall->AddParameter(p1, Axis_Serialize_Point, Axis_Delete_Point, "p1");
- m_pCall->AddParameter(p2, Axis_Serialize_Point, Axis_Delete_Point, "p2");
- Point* pReturn = new Point();
- m_pCall->SetReturnType(pReturn, Axis_DeSerialize_Point, Axis_Delete_Point, Axis_TypeName_Point, Axis_URI_Point);
+ m_pCall->AddParameter(p1, (void*) Axis_Serialize_Point, (void*) Axis_Delete_Point, "p1");
+ m_pCall->AddParameter(p2, (void*) Axis_Serialize_Point, (void*) Axis_Delete_Point, "p2");
+ m_pCall->SetReturnType((void*) Axis_DeSerialize_Point, (void*) Axis_Create_Point, (void*) Axis_Delete_Point, Axis_TypeName_Point, Axis_URI_Point);
nStatus = m_pCall->Invoke();
- if (SUCCESS != nStatus)
+ if (SUCCESS == nStatus)
{
- delete pReturn;
- pReturn = NULL;
+ m_pCall->GetResult((void**)&pReturn);
}
m_pCall->UnInitialize();
return pReturn;
}
+
+Axis_Point_Array Calculator::EchoPointArray(Axis_Point_Array Array)
+{
+ int nStatus;
+ Axis_Point_Array RetArray = {NULL, 0};
+ if (SUCCESS != m_pCall->Initialize()) return RetArray;
+ m_pCall->SetSOAPVersion(SOAP_VER_1_1);
+ m_pCall->SetOperation("EchoPointArray", "http://www.opensource.lk/");//this should be done before adding parameters or return type
+ m_pCall->AddParameter((Axis_Array*)(&Array), (void*) Axis_Serialize_Point, (void*) Axis_Delete_Point, (void*) Axis_GetSize_Point, Axis_TypeName_Point);
+ m_pCall->SetReturnType((Axis_Array*)(&RetArray), (void*) Axis_DeSerialize_Point, (void*) Axis_Create_Point, (void*) Axis_Delete_Point, Axis_TypeName_Point, Axis_URI_Point);
+ nStatus = m_pCall->Invoke();
+ if (SUCCESS != nStatus)
+ {
+ delete RetArray.m_Array;
+ RetArray.m_Array = NULL;
+ RetArray.m_Size = 0;
+ }
+ m_pCall->UnInitialize();
+ return RetArray;
+}
\ No newline at end of file
1.2 +2 -1 ws-axis/c/src/client/samples/CalculatorC/Calculator.h
Index: Calculator.h
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/samples/CalculatorC/Calculator.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Calculator.h 26 Sep 2003 04:33:02 -0000 1.1
+++ Calculator.h 1 Oct 2003 12:47:40 -0000 1.2
@@ -5,8 +5,8 @@
#if !defined(AFX_CALCULATOR_H__B5394466_ACFF_4962_B259_B0891BBB4775__INCLUDED_)
#define AFX_CALCULATOR_H__B5394466_ACFF_4962_B259_B0891BBB4775__INCLUDED_
-#include "Point.h"
#include "../../Call.h"
+#include "Point.h"
class Calculator
{
@@ -17,6 +17,7 @@
virtual ~Calculator();
int Add(int a, int b);
Point* AddPoint(Point* p1, Point* p2);
+ Axis_Point_Array EchoPointArray(Axis_Point_Array Array);
};
#endif // !defined(AFX_CALCULATOR_H__B5394466_ACFF_4962_B259_B0891BBB4775__INCLUDED_)
1.2 +9 -1 ws-axis/c/src/client/samples/CalculatorC/Point.cpp
Index: Point.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/samples/CalculatorC/Point.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Point.cpp 26 Sep 2003 04:33:02 -0000 1.1
+++ Point.cpp 1 Oct 2003 12:47:40 -0000 1.2
@@ -15,6 +15,14 @@
return SUCCESS;
}
+void* Axis_Create_Point(bool bArray = false, int nSize=0)
+{
+ if (bArray && (nSize > 0))
+ return new Point[nSize];
+ else
+ return new Point;
+}
+
void Axis_Delete_Point(Point* p, bool bArray = false, int nSize=0)
{
if (bArray)
@@ -33,7 +41,7 @@
{
const AxisChar* sPrefix = pSZ.getNewNamespacePrefix();
pSZ << "<" << Axis_TypeName_Point << " xsi:type=\"" << sPrefix <<":"
- << Axis_TypeName_Point << " xmlns:" << sPrefix << "=\""
+ << Axis_TypeName_Point << "\" xmlns:" << sPrefix << "=\""
<< Axis_URI_Point << "\">";
}
pSZ << pSZ.SerializeBasicType("x", p->x);
1.2 +6 -0 ws-axis/c/src/client/samples/CalculatorC/Point.h
Index: Point.h
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/samples/CalculatorC/Point.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Point.h 26 Sep 2003 04:33:02 -0000 1.1
+++ Point.h 1 Oct 2003 12:47:40 -0000 1.2
@@ -9,4 +9,10 @@
int y;
} Point;
+typedef struct Axis_Point_ArrayTag
+{
+ Point* m_Array;
+ int m_Size;
+} Axis_Point_Array;
+
#endif //__POINT_PARAM_H__INCLUDED_
1.4 +6 -0 ws-axis/c/src/common/IArrayBean.h
Index: IArrayBean.h
===================================================================
RCS file: /home/cvs/ws-axis/c/src/common/IArrayBean.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IArrayBean.h 1 Sep 2003 07:28:28 -0000 1.3
+++ IArrayBean.h 1 Oct 2003 12:47:40 -0000 1.4
@@ -79,4 +79,10 @@
virtual void SetUri(const AxisChar* sURI)=0;
};
+typedef struct Axis_ArrayTag
+{
+ void* m_Array;
+ int m_Size;
+} Axis_Array;
+
#endif // !defined(AFX_IARRAYBEAN_H__6E27008D_DCA0_4F28_AC82_FEEBE1A1CBBB__INCLUDED_)
1.8 +20 -2 ws-axis/c/src/common/IParam.h
Index: IParam.h
===================================================================
RCS file: /home/cvs/ws-axis/c/src/common/IParam.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- IParam.h 19 Sep 2003 14:56:33 -0000 1.7
+++ IParam.h 1 Oct 2003 12:47:40 -0000 1.8
@@ -75,11 +75,28 @@
#include <string>
using namespace std;
+/**
+ * Function that deserializes a custom type
+ */
typedef int (* AXIS_DESERIALIZE_FUNCT)(void*, IWrapperSoapDeSerializer*);
-//bArray is true if void* is a pointer to an array. Then nSize is the size of that array.
+/**
+ * Function used to create a custom type. bArray is true if array of objects to be
+ * created. Then nSize is the size of that array.
+ */
+typedef void* (* AXIS_OBJECT_CREATE_FUNCT)(bool bArray=false, int nSize=0);
+/**
+ * Function used to delete a custom type. bArray is true if void* is a pointer to an array.
+ * Then nSize is the size of that array.
+ */
typedef void (* AXIS_OBJECT_DELETE_FUNCT)(void*, bool bArray=false, int nSize=0);
-//bArray indicates that the object in void* is an element of an array (note that void* is not itself an array).
+/**
+ * Function that serializes a custom type. bArray indicates that the object in void* is
+ * an element of an array (note that void* is not itself an array).
+ */
typedef int (* AXIS_SERIALIZE_FUNCT)(void*, IWrapperSoapSerializer&, bool bArray=false);
+/**
+ * Function that is used to get the size of an object of a custom type.
+ */
typedef int (* AXIS_OBJECT_SIZE_FUNCT)(void);
class ComplexObjectHandler
@@ -87,6 +104,7 @@
public:
void* pObject;
AXIS_SERIALIZE_FUNCT pSZFunct;
+ AXIS_OBJECT_CREATE_FUNCT pCreFunct;
AXIS_OBJECT_DELETE_FUNCT pDelFunct;
AXIS_DESERIALIZE_FUNCT pDZFunct;
AXIS_OBJECT_SIZE_FUNCT pSizeFunct;
1.18 +0 -1 ws-axis/c/src/common/Param.cpp
Index: Param.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/common/Param.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Param.cpp 22 Sep 2003 05:12:22 -0000 1.17
+++ Param.cpp 1 Oct 2003 12:47:40 -0000 1.18
@@ -639,7 +639,6 @@
break;
case XSD_UNSIGNEDLONG:
pSZ << m_BTSZ.serialize(m_sName.c_str(), m_Value.ulValue);
-
break;
case XSD_FLOAT:
pSZ << m_BTSZ.serialize(m_sName.c_str(), m_Value.fValue);
1.2 +12 -1 ws-axis/c/src/server/samples/cppservice/PPService.cpp
Index: PPService.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/server/samples/cppservice/PPService.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PPService.cpp 1 Sep 2003 13:36:06 -0000 1.1
+++ PPService.cpp 1 Oct 2003 12:47:40 -0000 1.2
@@ -44,4 +44,15 @@
peri += sqrt(pow((pTri->p3->x - pTri->p2->x),2) + pow((pTri->p3->y - pTri->p2->y),2));
peri += sqrt(pow((pTri->p1->x - pTri->p3->x),2) + pow((pTri->p1->y - pTri->p3->y),2));
return peri;
-}
\ No newline at end of file
+}
+
+//Array Variables always passed and returned by value.
+Axis_Point_Array CPPService::EchoPointArray(Axis_Point_Array Array)
+{
+ //business logic
+ Axis_Point_Array newArray;
+ newArray.m_Size = Array.m_Size*2;
+ newArray.m_Array = new Point[newArray.m_Size];
+ //copy contents to the returning array.
+ return newArray;
+}
1.3 +6 -6 ws-axis/c/src/server/samples/cppservice/PPService.h
Index: PPService.h
===================================================================
RCS file: /home/cvs/ws-axis/c/src/server/samples/cppservice/PPService.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PPService.h 22 Sep 2003 05:12:22 -0000 1.2
+++ PPService.h 1 Oct 2003 12:47:40 -0000 1.3
@@ -16,12 +16,11 @@
int y;
};
-class Axis_Point_Array
+typedef struct Axis_Point_ArrayTag
{
-public:
Point* m_Array;
int m_Size;
-};
+} Axis_Point_Array;
class Triangle
{
@@ -31,18 +30,19 @@
Point* p3;
};
-class Axis_Triangle_Array
+typedef struct Axis_Triangle_ArrayTag
{
-public:
Triangle* m_Array;
int m_Size;
-};
+} Axis_Triangle_Array;
class CPPService
{
public:
double Distance(Point* p1, Point* p2);
Point* AddPoint(Point* p1, Point* p2);
+ //Array Variables always passed and returned by value.
+ Axis_Point_Array EchoPointArray(Axis_Point_Array Array);
int Add(int a, int b);
double Perimeter(const Triangle* pTri);
1.7 +34 -1 ws-axis/c/src/server/samples/cppservicewrapper/CPPServiceWrapper.cpp
Index: CPPServiceWrapper.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/server/samples/cppservicewrapper/CPPServiceWrapper.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CPPServiceWrapper.cpp 15 Sep 2003 07:14:06 -0000 1.6
+++ CPPServiceWrapper.cpp 1 Oct 2003 12:47:40 -0000 1.7
@@ -139,7 +139,9 @@
return Add(mc);
else if (0 == strcmp(method, "Perimeter"))
return Perimeter(mc);
- else return FAIL;
+ else if (0 == strcmp(method, "EchoPointArray"))
+ return EchoPointArray(mc);
+ else return FAIL; //CF_METHOD_NOT_FOUND_IN_LIBRARY
}
void CPPServiceWrapper::OnFault(IMessageData* pMsg)
@@ -276,4 +278,35 @@
return SUCCESS;
}
+int CPPServiceWrapper::EchoPointArray(IMessageData* mc)
+{
+ IWrapperSoapSerializer* pIWSSZ = NULL;
+ mc->getSoapSerializer(&pIWSSZ);
+ if (!pIWSSZ) return FAIL;
+ IWrapperSoapDeSerializer* pIWSDZ = NULL;
+ mc->getSoapDeSerializer(&pIWSDZ);
+ if (!pIWSDZ) return FAIL;
+ SetResponseMethod(mc, "EchoPointArrayResponse");
+
+ IParam *param0 = pIWSDZ->GetParam(); //now we know that this is an array.
+ Axis_Point_Array inArray;
+ inArray.m_Size = param0->GetArraySize();
+ if (inArray.m_Size > 0)
+ inArray.m_Array = new Point[inArray.m_Size];
+ else
+ return FAIL; //CF_ZERO_ARRAY_SIZE_ERROR
+ param0->SetArrayElements((void*)(inArray.m_Array), (AXIS_DESERIALIZE_FUNCT)Axis_DeSerialize_Point, (AXIS_OBJECT_DELETE_FUNCT)Axis_Delete_Point, (AXIS_OBJECT_SIZE_FUNCT)Axis_GetSize_Point);
+ pIWSDZ->Deserialize(param0,0);
+ Axis_Point_Array outArray = pWs->EchoPointArray(inArray);
+
+ IArrayBean* pAb = pIWSSZ->makeArrayBean((void*)(outArray.m_Array), (void*) Axis_Serialize_Point, (void*) Axis_Delete_Point, (void*) Axis_GetSize_Point);
+ pAb->AddDimension(outArray.m_Size);
+ pAb->SetItemName("item");
+ pAb->SetTypeName("Point");
+ pAb->SetUri("http://www.opensource.lk/Point");
+ IParam* pRetParam = pIWSSZ->AddOutputParam(pAb);
+ pRetParam->SetName("EchoPointArrayReturn");
+
+ return SUCCESS;
+}
\ No newline at end of file
1.3 +2 -0 ws-axis/c/src/server/samples/cppservicewrapper/CPPServiceWrapper.hpp
Index: CPPServiceWrapper.hpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/server/samples/cppservicewrapper/CPPServiceWrapper.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- CPPServiceWrapper.hpp 3 Sep 2003 05:21:25 -0000 1.2
+++ CPPServiceWrapper.hpp 1 Oct 2003 12:47:40 -0000 1.3
@@ -10,6 +10,7 @@
#include "../../../common/IWrapperSoapSerializer.h"
#include "../../../common/ISoapMethod.h"
#include "../../../common/IParam.h"
+#include "../../../common/IArrayBean.h"
class CPPServiceWrapper : public WrapperClassHandler
{
@@ -27,6 +28,7 @@
int AddPoint(IMessageData* mc);
int Add(IMessageData* mc);
int Perimeter(IMessageData* mc);
+ int EchoPointArray(IMessageData* mc);
private:// Actual web service object
CPPService *pWs;
};