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 ro...@apache.org on 2004/02/28 07:34:34 UTC
cvs commit: ws-axis/c/src/server/handlers/custom/echoStringHeaderHandler ESHHandler.cpp ESHHandler.h EchoStringHeaderHandler.cpp
roshan 2004/02/27 22:34:34
Modified: c/src/server/handlers/custom/echoStringHeaderHandler
ESHHandler.cpp ESHHandler.h
EchoStringHeaderHandler.cpp
Log:
changes made to a sample handler (echoStringHeaderHandler) to reflect the new handler api improvements
Revision Changes Path
1.8 +51 -27 ws-axis/c/src/server/handlers/custom/echoStringHeaderHandler/ESHHandler.cpp
Index: ESHHandler.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/server/handlers/custom/echoStringHeaderHandler/ESHHandler.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- ESHHandler.cpp 21 Nov 2003 12:56:00 -0000 1.7
+++ ESHHandler.cpp 28 Feb 2004 06:34:34 -0000 1.8
@@ -72,8 +72,11 @@
#include <axis/soap/HeaderBlock.h>
#include <axis/soap/SoapHeader.h>
#include <axis/soap/BasicNode.h>
+#include <axis/common/AxisTrace.h>
#include <iostream>
+#include <axis/soap/CharacterElement.h>
+
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
@@ -105,12 +108,13 @@
m_pOption = OptionList;
}
-int ESHHandler::Invoke(IMessageData *pIMsg)
+int ESHHandler::Invoke(void *pvIMsg)
{
- string strTemp;
- AxisChar* sHeaderVal;
+ IMessageData *pIMsg = (IMessageData*) pvIMsg;
+ AxisChar* pachTemp;
if(pIMsg->isPastPivot()) {
- //this is a response
+ /*this is a response*/
+
IHandlerSoapSerializer* pISZ;
pIMsg->getSoapSerializer(&pISZ);
@@ -118,46 +122,66 @@
pIHeaderBlock->setLocalName("echoMeStringResponse");
pIHeaderBlock->setUri("http://soapinterop.org/echoheader/");
- pIHeaderBlock->setPrefix("m");
- strTemp = "EchoStringHeaderHandlerPr1.id";
- size_t nSize = strlen(pIMsg->getProperty(strTemp).c_str()) + 30;
- sHeaderVal = (char*) malloc(nSize);
- strcpy(sHeaderVal, pIMsg->getProperty(strTemp).c_str());
- realloc(sHeaderVal, 30);
- strcpy(sHeaderVal," After Append by Handler");
- pIHeaderBlock->setValue(sHeaderVal);
+ pachTemp = "EchoStringHeaderHandlerPr1.id";
+
+ const AxisChar* pachHeaderVal = pIMsg->getProperty(pachTemp);
+ printf("in the ESHHandler::Invoke : %s\n",pachHeaderVal);
BasicNode* pBasicNode = pIHeaderBlock->createChild(CHARACTER_NODE);
- pBasicNode->setValue(sHeaderVal);
+ pBasicNode->setValue(pachHeaderVal);
+
pIHeaderBlock->addChild(pBasicNode);
-
- cout<<"in the header invoke"<<endl;
} else {
- //this is a request
+ /*this is a request*/
+
IHandlerSoapDeSerializer* pIHandlerSoapDeSerializer;
pIMsg->getSoapDeSerializer(&pIHandlerSoapDeSerializer);
- ISoapHeader* pISoapHeader= pIHandlerSoapDeSerializer->GetHeader();
- IHeaderBlock* pIHeaderBlock= pISoapHeader->getHeaderBlock();
- BasicNode* pBasicNode= pIHeaderBlock->getFirstChild();
+ IHeaderBlock* pIHeaderBlock= pIHandlerSoapDeSerializer->GetHeaderBlock("reservation", "http://travelcompany.example.org/reservation");
- string sHeaderValue;
- if((pBasicNode->getNodeType()) == CHARACTER_NODE) {
- sHeaderValue= pBasicNode->getValue();
- }
+ if (pIHeaderBlock != NULL) {
- strTemp = "EchoStringHeaderHandlerPr1.id";
- pIMsg->setProperty(strTemp, sHeaderValue);
- //pIMsg->setProperty(string("EchoSt"), sHeaderValue);
+ BasicNode* pBasicNode= pIHeaderBlock->getFirstChild();
+ BasicNode* pBasicNode2= pBasicNode->getFirstChild();
+
+ const AxisChar* pachHeaderValue;
+ const AxisChar* pachHeaderValue2;
+ if((pBasicNode2->getNodeType()) == CHARACTER_NODE) {
+ pachHeaderValue= pBasicNode2->getValue();
+ } else {
+ pachHeaderValue = "This was not the expected value Ros";
+ }
+
+ BasicNode* pBasicNode3= pIHeaderBlock->getLastChild();
+ BasicNode* pBasicNode4 =pBasicNode3->getFirstChild();
+ if((pBasicNode4->getNodeType()) == CHARACTER_NODE) {
+ pachHeaderValue2= pBasicNode4->getValue();
+ } else {
+ pachHeaderValue2= "This was not the expected value2 Ros";
+ }
+
+ AxisChar* pachTmpValue = (AxisChar*) malloc(strlen(pachHeaderValue)+ strlen(pachHeaderValue2) +4);
+ strcpy(pachTmpValue, pachHeaderValue);
+ strcat(pachTmpValue, " : ");
+ strcat(pachTmpValue, pachHeaderValue2);
+
+ pachTemp = "EchoStringHeaderHandlerPr1.id";
+ pIMsg->setProperty(pachTemp, pachTmpValue);
+
+ free(pachTmpValue);
+
+ } else {
+ //do some thing
+ }
}
return AXIS_SUCCESS;
}
-void ESHHandler::OnFault(IMessageData *pIMsg)
+void ESHHandler::OnFault(void *pvIMsg)
{
}
1.5 +4 -4 ws-axis/c/src/server/handlers/custom/echoStringHeaderHandler/ESHHandler.h
Index: ESHHandler.h
===================================================================
RCS file: /home/cvs/ws-axis/c/src/server/handlers/custom/echoStringHeaderHandler/ESHHandler.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ESHHandler.h 21 Oct 2003 06:04:23 -0000 1.4
+++ ESHHandler.h 28 Feb 2004 06:34:34 -0000 1.5
@@ -77,10 +77,10 @@
class ESHHandler : public Handler
{
public:
- int Fini();
- int Init();
- void OnFault(IMessageData* pIMsg);
- int Invoke(IMessageData* pIMsg);
+ int AXISCALL Fini();
+ int AXISCALL Init();
+ void AXISCALL OnFault(void* pvIMsg);
+ int AXISCALL Invoke(void* pvIMsg);
void SetOptionList(const map<string, string>* OptionList);
const string& GetOption(const string& sArg);
ESHHandler();
1.5 +15 -5 ws-axis/c/src/server/handlers/custom/echoStringHeaderHandler/EchoStringHeaderHandler.cpp
Index: EchoStringHeaderHandler.cpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/server/handlers/custom/echoStringHeaderHandler/EchoStringHeaderHandler.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- EchoStringHeaderHandler.cpp 21 Nov 2003 12:56:00 -0000 1.4
+++ EchoStringHeaderHandler.cpp 28 Feb 2004 06:34:34 -0000 1.5
@@ -80,20 +80,30 @@
//Following describes how the export function of the handler DLLs (or .so s)
STORAGE_CLASS_INFO
-int GetClassInstance(Handler **inst)
+int GetClassInstance(BasicHandler **inst)
{
- *inst = new ESHHandler();
- if (*inst)
+ printf("in the GetClassInstance of ....");
+ *inst = new BasicHandler();
+
+ ESHHandler* pESHHandler = new ESHHandler();
+ (*inst)->_functions = 0;
+ if (pESHHandler)
{
- return AXIS_SUCCESS;
+ (*inst)->_object = pESHHandler;
+ return pESHHandler->Init();
}
+
return AXIS_FAIL;
}
+
STORAGE_CLASS_INFO
-int DestroyInstance(Handler *inst)
+int DestroyInstance(BasicHandler *inst)
{
if (inst)
{
+ Handler* pH = static_cast<Handler*>(inst->_object);
+ pH->Fini();
+ delete pH;
delete inst;
return AXIS_SUCCESS;
}