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/23 10:25:00 UTC
cvs commit: ws-axis/c/src/client/transport/axis AxisTransport.cpp Receiver.cpp Sender.cpp TransportFactory.cpp
susantha 2003/10/23 01:25:00
Modified: c/src/client Call.cpp
c/src/client/samples/interoptests/base InteropBaseClient.cpp
InteropTestPortType.cpp
c/src/client/samples/interoptests/groupB
InteropGroupBClient.cpp InteropTestPortTypeB.cpp
InteropTestPortTypeB.h
c/src/client/transport/axis AxisTransport.cpp Receiver.cpp
Sender.cpp TransportFactory.cpp
Log:
Fixed following bugs
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24027
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=24033
Revision Changes Path
1.20 +208 -1 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.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- Call.cpp 22 Oct 2003 03:40:04 -0000 1.19
+++ Call.cpp 23 Oct 2003 08:24:59 -0000 1.20
@@ -187,11 +187,17 @@
m_pIWSSZ->AddOutputParam(pchName, pObject, pSZFunct, pDelFunct);
}
+/**
+ * This function is used to set that the return type is a basic type
+ */
void Call::SetReturnType(XSDTYPE nType)
{
m_nReturnType = nType;
}
+/**
+ * This function is used to set that the return type is a complex type
+ */
void Call::SetReturnType(void *pDZFunct, void* pCreFunct, void *pDelFunct, const char* pchTypeName, const char * pchUri)
{
m_nReturnType = USER_TYPE;
@@ -238,6 +244,7 @@
Param *pParam = NULL;
if (SUCCESS == (nStatus = m_pAxisEngine->Process(&m_Soap)))
{
+ //Get return type if it returns
if (USER_TYPE == m_nReturnType)
{
/*
@@ -285,19 +292,99 @@
else
return FAIL; //CF_ZERO_ARRAY_SIZE_ERROR
}
- else //basic type
+ else if (XSD_UNKNOWN != m_nReturnType)//basic type
{
m_pReturnValue = (Param*)m_pIWSDZ->GetParam();
}
+ else if (!m_OutParams.empty()) //there are out parameters
+ {
+ OutParamHolder* pOutParam = NULL;
+ // do for each parameter.
+ for (list<OutParamHolder*>::iterator it = m_OutParams.begin(); it != m_OutParams.end(); it++)
+ {
+ pOutParam = (*it);
+ if (USER_TYPE == pOutParam->m_nOutType)
+ {
+ /*
+ 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
+ */
+ pParam = (Param*)m_pIWSDZ->GetParam();
+ /*
+ Following lines check whether the returned type is expected type or not.
+ But this type checking is optional. So commented.
+ if (pParam && (pOutParam->m_OutCplxObj.m_TypeName == pParam->GetTypeName()))
+ {
+ pOutParam->m_OutCplxObj.pDZFunct(pOutParam->m_OutCplxObj.pObject, m_pMsgData->m_pDZ);
+ }
+ else
+ {
+ return FAIL;
+ }
+ */
+ if (!pOutParam->m_OutCplxObj.pCreFunct || !pOutParam->m_OutCplxObj.pDZFunct)
+ return FAIL;
+ pOutParam->m_OutCplxObj.pObject = pOutParam->m_OutCplxObj.pCreFunct();
+ if (!pOutParam->m_OutCplxObj.pObject)
+ return FAIL;
+ pOutParam->m_OutCplxObj.pDZFunct(pOutParam->m_OutCplxObj.pObject, m_pMsgData->m_pDZ);
+
+ }
+ else if (XSD_ARRAY == pOutParam->m_nOutType)
+ {
+ IParam *param0 = m_pIWSDZ->GetParam();
+ /* now we know that this is an array. if needed we can check that too */
+ if (!pOutParam->m_pArray) return FAIL; //No array expected ?
+ pOutParam->m_pArray->m_Size = param0->GetArraySize();
+ if (pOutParam->m_pArray->m_Size < 1) return FAIL;
+ if (USER_TYPE == pOutParam->m_nArrayType)
+ {
+ pOutParam->m_pArray->m_Array = pOutParam->m_OutCplxObj.pCreFunct(true, pOutParam->m_pArray->m_Size);
+ }
+ else
+ {
+ pOutParam->m_pArray->m_Array = m_pIWSDZ->CreateArray(pOutParam->m_nArrayType, pOutParam->m_pArray->m_Size);
+ }
+ if (pOutParam->m_pArray->m_Array) //Array is allocated successfully
+ {
+ if (USER_TYPE == pOutParam->m_nArrayType)
+ param0->SetArrayElements((void*)(pOutParam->m_pArray->m_Array), pOutParam->m_OutCplxObj.pDZFunct, pOutParam->m_OutCplxObj.pDelFunct, pOutParam->m_OutCplxObj.pSizeFunct);
+ else
+ param0->SetArrayElements((void*)(pOutParam->m_pArray->m_Array));
+ m_pIWSDZ->Deserialize(param0,0);
+ }
+ else
+ return FAIL; //CF_ZERO_ARRAY_SIZE_ERROR
+ }
+ else if (XSD_UNKNOWN != pOutParam->m_nOutType)//basic type
+ {
+ pOutParam->m_pOutValue = (Param*)m_pIWSDZ->GetParam();
+ }
+ else // this is an unexpected situation
+ {
+ return FAIL;
+ }
+ }
+ }
+ else //returns void
+ {
+ //nothing to do
+ }
}
return nStatus;
}
+/**
+ * Used to get the corresponding Param when the return type is basic type
+ */
Param* Call::GetResult()
{
return m_pReturnValue;
}
+/**
+ * Used to get deserialized return object when the return type is complex type
+ */
void Call::GetResult(void** pReturn)
{
if (m_ReturnCplxObj.pObject)
@@ -364,6 +451,7 @@
m_ReturnCplxObj.pObject = NULL;
m_ReturnCplxObj.pSizeFunct = NULL;
m_ReturnCplxObj.pSZFunct = NULL;
+ m_CurItr = NULL;
}
int Call::UnInitialize()
@@ -439,3 +527,122 @@
return (NULL != m_pArray->m_Array)?SUCCESS:FAIL;
}
+Call::OutParamHolder::OutParamHolder()
+{
+ m_nOutType = XSD_UNKNOWN;
+ m_nArrayType = XSD_UNKNOWN;
+ m_pArray = NULL;
+ m_pOutValue = NULL;
+}
+
+Call::OutParamHolder::~OutParamHolder()
+{
+
+}
+
+Call::OutParamHolder* Call::AddOutParam()
+{
+ OutParamHolder* pNew = new OutParamHolder();
+ if (pNew)
+ m_OutParams.push_back(pNew);
+ return pNew;
+}
+
+/**
+ * This function is used to set that the return type is a basic type
+ */
+void Call::AddOutParamType(XSDTYPE nType)
+{
+ OutParamHolder* pOPH = AddOutParam();
+ if (pOPH)
+ {
+ pOPH->m_nOutType = nType;
+ }
+}
+
+/**
+ * This function is used to set that the return type is a complex type
+ */
+void Call::AddOutParamType(void *pDZFunct, void* pCreFunct, void *pDelFunct, const char* pchTypeName, const char * pchUri)
+{
+ OutParamHolder* pOPH = AddOutParam();
+ if (pOPH)
+ {
+ pOPH->m_nOutType = USER_TYPE;
+ pOPH->m_OutCplxObj.pObject = NULL;
+ pOPH->m_OutCplxObj.pDZFunct = (AXIS_DESERIALIZE_FUNCT)pDZFunct;
+ pOPH->m_OutCplxObj.pCreFunct = (AXIS_OBJECT_CREATE_FUNCT)pCreFunct;
+ pOPH->m_OutCplxObj.pDelFunct = (AXIS_OBJECT_DELETE_FUNCT)pDelFunct;
+ pOPH->m_OutCplxObj.m_TypeName = pchTypeName;
+ pOPH->m_OutCplxObj.m_URI = pchUri;
+ }
+}
+
+/**
+ * This function is used to set that the return type is an array of complex types
+ */
+void Call::AddOutParamType(Axis_Array* pArray, void* pDZFunct, void* pCreFunct, void* pDelFunct, void* pSizeFunct, const char* pchTypeName, const char* pchUri)
+{
+ OutParamHolder* pOPH = AddOutParam();
+ if (pOPH)
+ {
+ pOPH->m_pArray = pArray;
+ pOPH->m_nOutType = XSD_ARRAY;
+ pOPH->m_nArrayType = USER_TYPE;
+ pOPH->m_OutCplxObj.pDZFunct = (AXIS_DESERIALIZE_FUNCT)pDZFunct;
+ pOPH->m_OutCplxObj.pCreFunct = (AXIS_OBJECT_CREATE_FUNCT)pCreFunct;
+ pOPH->m_OutCplxObj.pDelFunct = (AXIS_OBJECT_DELETE_FUNCT)pDelFunct;
+ pOPH->m_OutCplxObj.pSizeFunct = (AXIS_OBJECT_SIZE_FUNCT)pSizeFunct;
+ pOPH->m_OutCplxObj.m_TypeName = pchTypeName;
+ pOPH->m_OutCplxObj.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::AddOutParamType(Axis_Array* pArray, XSDTYPE nType)
+{
+ OutParamHolder* pOPH = AddOutParam();
+ if (pOPH)
+ {
+ pOPH->m_pArray = pArray;
+ pOPH->m_nOutType = XSD_ARRAY;
+ pOPH->m_nArrayType = nType;
+ }
+}
+
+/**
+ * Used to get the corresponding Param when the out param type is basic type
+ */
+Param* Call::GetOutParam()
+{
+ if (m_CurItr == NULL) m_CurItr = m_OutParams.begin();
+ else m_CurItr++;
+ if (m_CurItr == m_OutParams.end()) return NULL; //something wrong
+ OutParamHolder* pOutParam = (*m_CurItr);
+ return pOutParam->m_pOutValue;
+}
+
+/**
+ * Used to get the deserialized object when the out param type is of complex type
+ */
+void Call::GetOutParam(void** pOut)
+{
+ if (m_CurItr == NULL) m_CurItr = m_OutParams.begin();
+ else m_CurItr++;
+ if (m_CurItr == m_OutParams.end()) return; //something wrong
+ OutParamHolder* pOutParam = (*m_CurItr);
+ if (pOutParam->m_OutCplxObj.pObject)
+ {
+ *pOut = pOutParam->m_OutCplxObj.pObject;
+ pOutParam->m_OutCplxObj.pObject = NULL; //note that returned object is handed over to the client.
+ }
+ else
+ {
+ *pOut = NULL;
+ }
+}
1.2 +12 -2 ws-axis/c/src/client/samples/interoptests/base/InteropBaseClient.cpp
Index: InteropBaseClient.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/samples/interoptests/base/InteropBaseClient.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InteropBaseClient.cpp 21 Oct 2003 15:06:37 -0000 1.1
+++ InteropBaseClient.cpp 23 Oct 2003 08:24:59 -0000 1.2
@@ -3,7 +3,7 @@
#include "InteropTestPortType.h"
-#define ARRAYSIZE 5
+#define ARRAYSIZE 2
int main(int argc, char* argv[])
{
@@ -44,12 +44,14 @@
{
arrfloat.m_Array[x] = 1.1111*x;
}
+ ws.echoFloatArray(arrfloat);
+ // testing echo Struct
SOAPStruct stct;
stct.varFloat = 12345.7346345;
stct.varInt = 5000;
stct.varString = "This is string in SOAPStruct";
ws.echoStruct(&stct);
-
+ //testing echo Array of Struct
ArrayOfSOAPStruct arrstct;
arrstct.m_Array = new SOAPStruct[ARRAYSIZE];
arrstct.m_Size = ARRAYSIZE;
@@ -60,12 +62,20 @@
sprintf(buffer, "varString of %dth element of SOAPStruct array", x);
arrstct.m_Array[x].varString = buffer;
}
+ //testing echo Struct Array
+ ws.echoStructArray(arrstct);
+ //testing echo void
ws.echoVoid();
+ //testing echo base 64 binary
ws.echoBase64("BCDF675E234242WHRTKMJDGKGUEJ898636JFJFHEJDGWTDHFJRURYGBCDHTWRSG");
// time_t tim;
// time(&tim);
// ws.echoDate(*gmtime(&tim));
+ //testing echo hex binary
ws.echoHexBinary("CCCFFA46552BC7D5A09BC5F23DE9E0FE7862AD45BC87D02FE");
+ //testing echo decimal
ws.echoDecimal(1234.567890);
+ //testing echo boolean
ws.echoBoolean(1);
+
}
1.2 +1 -1 ws-axis/c/src/client/samples/interoptests/base/InteropTestPortType.cpp
Index: InteropTestPortType.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/samples/interoptests/base/InteropTestPortType.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InteropTestPortType.cpp 21 Oct 2003 15:06:37 -0000 1.1
+++ InteropTestPortType.cpp 23 Oct 2003 08:24:59 -0000 1.2
@@ -19,7 +19,7 @@
{
m_pCall = new Call();
m_pCall->SetProtocol(APTHTTP);
- m_pCall->SetHeader("SOAPAction", "InteropTestPortType");
+ m_pCall->SetHeader("SOAPAction", "InteropBase");
m_pCall->SetEndpointURI("http://localhost/axis/InteropBase");
}
1.2 +13 -1 ws-axis/c/src/client/samples/interoptests/groupB/InteropGroupBClient.cpp
Index: InteropGroupBClient.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/samples/interoptests/groupB/InteropGroupBClient.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InteropGroupBClient.cpp 21 Oct 2003 15:06:37 -0000 1.1
+++ InteropGroupBClient.cpp 23 Oct 2003 08:24:59 -0000 1.2
@@ -10,7 +10,7 @@
InteropTestPortTypeB ws;
//we do not support multi-dimensional arrays.
//ws.echo2DStringArray
-
+/*
//testing Nested Arrays
SOAPArrayStruct sas;
sas.varFloat = 12345.67890;
@@ -38,6 +38,18 @@
//testing echo Simple types as struct
string str = "content of string passed";
ws.echoSimpleTypesAsStruct(12345.67890, 5000, str);
+*/
+ //testing echo Struct as simple types.
+ SOAPStruct ss;
+ ss.varFloat = 12345.67890;
+ ss.varInt = 5000;
+ ss.varString = "content of string passed";
+ string outStr;
+ int outInt;
+ float outFloat;
+ ws.echoStructAsSimpleTypes(&ss, &outStr, &outInt, &outFloat);
+ printf("returned by echoStructAsSimpleTypes\n");
+ printf("%s\n%d\n%f\n", outStr.c_str(), outInt, outFloat);
return 0;
}
1.2 +10 -8 ws-axis/c/src/client/samples/interoptests/groupB/InteropTestPortTypeB.cpp
Index: InteropTestPortTypeB.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/samples/interoptests/groupB/InteropTestPortTypeB.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InteropTestPortTypeB.cpp 21 Oct 2003 15:06:38 -0000 1.1
+++ InteropTestPortTypeB.cpp 23 Oct 2003 08:24:59 -0000 1.2
@@ -31,8 +31,8 @@
{
m_pCall = new Call();
m_pCall->SetProtocol(APTHTTP);
- m_pCall->SetHeader("SOAPAction", "InteropTestPortTypeB");
- m_pCall->SetEndpointURI("http://localhost/axis/InteropGroupB");
+ m_pCall->SetHeader("SOAPAction", "InteropGroupB");
+ m_pCall->SetEndpointURI("http://localhost:5555/axis/InteropGroupB");
}
InteropTestPortTypeB::~InteropTestPortTypeB()
@@ -46,22 +46,24 @@
/////////////////////////////////////////////////////////////////
// This method wrap the service methodechoStructAsSimpleTypes
//////////////////////////////////////////////////////////////////
-float InteropTestPortTypeB::echoStructAsSimpleTypes(SOAPStruct* Value0)
+void InteropTestPortTypeB::echoStructAsSimpleTypes(SOAPStruct* Value0, AXIS_OUT_PARAM string* outValue0, AXIS_OUT_PARAM int* outValue1, AXIS_OUT_PARAM float* outValue2)
{
int nStatus;
- float Ret;
- if (SUCCESS != m_pCall->Initialize()) return Ret;
+ if (SUCCESS != m_pCall->Initialize()) return;
m_pCall->SetSOAPVersion(SOAP_VER_1_1);
m_pCall->SetOperation("echoStructAsSimpleTypes", "http://soapinterop.org/");
m_pCall->AddParameter(Value0, Axis_Serialize_SOAPStruct, Axis_Delete_SOAPStruct, "inputStruct");
- m_pCall->SetReturnType(XSD_FLOAT);
+ m_pCall->AddOutParamType(XSD_STRING);
+ m_pCall->AddOutParamType(XSD_INT);
+ m_pCall->AddOutParamType(XSD_FLOAT);
nStatus = m_pCall->Invoke();
if (SUCCESS == nStatus)
{
- Ret = m_pCall->GetResult()->GetFloat();
+ *outValue0 = m_pCall->GetOutParam()->GetString();
+ *outValue1 = m_pCall->GetOutParam()->GetInt();
+ *outValue2 = m_pCall->GetOutParam()->GetFloat();
}
m_pCall->UnInitialize();
- return Ret;
}
1.2 +1 -1 ws-axis/c/src/client/samples/interoptests/groupB/InteropTestPortTypeB.h
Index: InteropTestPortTypeB.h
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/samples/interoptests/groupB/InteropTestPortTypeB.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- InteropTestPortTypeB.h 21 Oct 2003 15:06:38 -0000 1.1
+++ InteropTestPortTypeB.h 23 Oct 2003 08:24:59 -0000 1.2
@@ -25,7 +25,7 @@
public:
virtual ~InteropTestPortTypeB();
public:
- float echoStructAsSimpleTypes(SOAPStruct* Value0);
+ void echoStructAsSimpleTypes(SOAPStruct* Value0, AXIS_OUT_PARAM string* outValue0, AXIS_OUT_PARAM int* outValue1, AXIS_OUT_PARAM float* outValue2);
SOAPStruct* echoSimpleTypesAsStruct(float Value0,int Value1,string Value2);
ArrayOfString2D echo2DStringArray(ArrayOfString2D Value0);
SOAPStructStruct* echoNestedStruct(SOAPStructStruct* Value0);
1.8 +14 -4 ws-axis/c/src/client/transport/axis/AxisTransport.cpp
Index: AxisTransport.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/transport/axis/AxisTransport.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AxisTransport.cpp 20 Oct 2003 06:37:58 -0000 1.7
+++ AxisTransport.cpp 23 Oct 2003 08:24:59 -0000 1.8
@@ -64,9 +64,6 @@
#include <axis/client/transport/AxisTransport.h>
#include <axis/client/transport/axis/TransportFactory.hpp>
-#include <axis/client/transport/axis/Transport.hpp>
-#include <axis/client/transport/axis/Sender.hpp>
-#include <axis/client/transport/axis/Receiver.hpp>
AxisTransport::AxisTransport(Ax_soapstream* pSoap)
{
@@ -160,7 +157,20 @@
int AxisTransport::Send_transport_information(void* pSoapStream)
{
Ax_soapstream* pSStream = (Ax_soapstream*) pSoapStream;
- return SUCCESS;
+ if (pSStream)
+ {
+ Sender* pSender = (Sender*) pSStream->str.op_stream;
+ if (!pSender) return FAIL;
+ string sName, sValue;
+ for (int x=0; x<pSStream->so.http.ip_headercount;x++)
+ {
+ sName = pSStream->so.http.ip_headers[x].headername;
+ sValue = pSStream->so.http.ip_headers[x].headervalue;
+ pSender->SetProperty(sName, sValue);
+ }
+ return SUCCESS;
+ }
+ return FAIL;
}
int AxisTransport::Receive_transport_information(void* pSoapStream)
1.4 +0 -1 ws-axis/c/src/client/transport/axis/Receiver.cpp
Index: Receiver.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/transport/axis/Receiver.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Receiver.cpp 20 Oct 2003 06:37:58 -0000 1.3
+++ Receiver.cpp 23 Oct 2003 08:24:59 -0000 1.4
@@ -64,7 +64,6 @@
#include <axis/client/transport/axis/Platform.hpp>
#include <axis/client/transport/axis/Receiver.hpp>
-#include <axis/client/transport/axis/Transport.hpp>
#include <iostream>
1.4 +5 -2 ws-axis/c/src/client/transport/axis/Sender.cpp
Index: Sender.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/transport/axis/Sender.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Sender.cpp 20 Oct 2003 06:37:58 -0000 1.3
+++ Sender.cpp 23 Oct 2003 08:24:59 -0000 1.4
@@ -64,8 +64,6 @@
#include <axis/client/transport/axis/Platform.hpp>
#include <axis/client/transport/axis/Sender.hpp>
-#include <axis/client/transport/axis/Transport.hpp>
-
Sender::Sender(Transport *pTr)
@@ -98,6 +96,11 @@
}
return true;
+}
+
+void Sender::SetProperty(const string& sProperty, const string& sValue)
+{
+ m_pTrChannel->SetProperty(sProperty, sValue);
}
1.3 +0 -11 ws-axis/c/src/client/transport/axis/TransportFactory.cpp
Index: TransportFactory.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/client/transport/axis/TransportFactory.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- TransportFactory.cpp 20 Oct 2003 06:37:58 -0000 1.2
+++ TransportFactory.cpp 23 Oct 2003 08:24:59 -0000 1.3
@@ -68,17 +68,6 @@
#include <axis/client/transport/axis/HttpTransport.hpp>
-
-TransportFactory::TransportFactory()
-{
-
-}
-
-TransportFactory::~TransportFactory()
-{
-
-}
-
Transport* TransportFactory::GetTransport(Url& url)
{
if(url.GetProtocol() == Url::http)