Hi,
I need to return the string data from the RPC function that i am calling. String will be very dynamic so i am interested in using stl string inside the idl.
I tried dynamic arrays but i am unable to persist the pointer from heap corruption... e.g. here is my idl code
Code:interface myinterface { void RPC_GetGroupStatusEx([out] char ** szXMLString); }
server implemented code
Code:void RPC_GetGroupStatusEx(unsigned char ** szXMLString) { CString strXmlRawData = GetSomeXmlData(); //it return xml string unsigned char* dyn = new unsigned char[strXmlRawData.GetLength()]; sprintf((char*)dyn,"%s", strXmlRawData.GetBuffer()); *szXMLString =dyn; }
client caller code
Code:unsigned char *ms = NULL; //i have tried even initialized pointer by sending it to the server but it also gave me heap corruption , also i have used address of pointer but same result RpcTryExcept { RPC_GetGroupStatusEx(&ms); } RpcExcept(1) { int a = RpcExceptionCode(); std::cerr << "Runtime reported exception " << RpcExceptionCode() << std::endl; } RpcEndExcept
it always crash at the server side code after leaving that function , one more thing is RPC server is on the different machine. Every other functions with data types works fine except string.
Please guide me what i am doing wrong in the code? How can i use stl string inside the idl file ?
Regards




Reply With Quote