Return String array from C++ ATL Server Web Service
-
Hi, I want to be able to pass back an array of CString's from an ATL Server Web Service to a C# web Form's application. Any ideas on how to do this? e.g. here is example code on returning a single string (a BSTR): namespace MyLabService { // all struct, enum, and typedefs for your webservice should go inside the namespace // IMyLabService - web service interface declaration // [ uuid("911E5A7B-194B-4070-B080-36234B341D15"), object ] __interface IMyLabService { // HelloWorld is a sample ATL Server web service method. It shows how to // declare a web service method and its in-parameters and out-parameters [id(1)] HRESULT HelloWorld([out, retval]BSTR *bstrOutput); }; // MyLabService - web service implementation // [ request_handler(name="Default", sdl="GenMyLabWSDL"), soap_handler( name="MyLabService", namespace="urn:MyLabService", protocol="soap" ) ] class CMyLabService : public IMyLabService { public: // This is a sample web service method that shows how to use the // soap_method attribute to expose a method as a web method [ soap_method ] HRESULT HelloWorld(/*[out, retval]*/ BSTR *bstrOutput) { CComBSTR bstrOut(L"Hello World"); *bstrOutput = bstrOut.Detach(); return S_OK; } }; // class CMyLabService } // namespace MyLabService Instead of: [id(1)] HRESULT HelloWorld([out, retval]BSTR *bstrOutput); I would like something like: [id(1)] HRESULT HelloWorld([out, retval]vector *Output); I would really appreciate help on this one!!!! Cheers, Tony.
-
Hi, I want to be able to pass back an array of CString's from an ATL Server Web Service to a C# web Form's application. Any ideas on how to do this? e.g. here is example code on returning a single string (a BSTR): namespace MyLabService { // all struct, enum, and typedefs for your webservice should go inside the namespace // IMyLabService - web service interface declaration // [ uuid("911E5A7B-194B-4070-B080-36234B341D15"), object ] __interface IMyLabService { // HelloWorld is a sample ATL Server web service method. It shows how to // declare a web service method and its in-parameters and out-parameters [id(1)] HRESULT HelloWorld([out, retval]BSTR *bstrOutput); }; // MyLabService - web service implementation // [ request_handler(name="Default", sdl="GenMyLabWSDL"), soap_handler( name="MyLabService", namespace="urn:MyLabService", protocol="soap" ) ] class CMyLabService : public IMyLabService { public: // This is a sample web service method that shows how to use the // soap_method attribute to expose a method as a web method [ soap_method ] HRESULT HelloWorld(/*[out, retval]*/ BSTR *bstrOutput) { CComBSTR bstrOut(L"Hello World"); *bstrOutput = bstrOut.Detach(); return S_OK; } }; // class CMyLabService } // namespace MyLabService Instead of: [id(1)] HRESULT HelloWorld([out, retval]BSTR *bstrOutput); I would like something like: [id(1)] HRESULT HelloWorld([out, retval]vector *Output); I would really appreciate help on this one!!!! Cheers, Tony.
SAFEARRAY
Don't have a clue how they are handled in C# though. Sorry. -
Hi, I want to be able to pass back an array of CString's from an ATL Server Web Service to a C# web Form's application. Any ideas on how to do this? e.g. here is example code on returning a single string (a BSTR): namespace MyLabService { // all struct, enum, and typedefs for your webservice should go inside the namespace // IMyLabService - web service interface declaration // [ uuid("911E5A7B-194B-4070-B080-36234B341D15"), object ] __interface IMyLabService { // HelloWorld is a sample ATL Server web service method. It shows how to // declare a web service method and its in-parameters and out-parameters [id(1)] HRESULT HelloWorld([out, retval]BSTR *bstrOutput); }; // MyLabService - web service implementation // [ request_handler(name="Default", sdl="GenMyLabWSDL"), soap_handler( name="MyLabService", namespace="urn:MyLabService", protocol="soap" ) ] class CMyLabService : public IMyLabService { public: // This is a sample web service method that shows how to use the // soap_method attribute to expose a method as a web method [ soap_method ] HRESULT HelloWorld(/*[out, retval]*/ BSTR *bstrOutput) { CComBSTR bstrOut(L"Hello World"); *bstrOutput = bstrOut.Detach(); return S_OK; } }; // class CMyLabService } // namespace MyLabService Instead of: [id(1)] HRESULT HelloWorld([out, retval]BSTR *bstrOutput); I would like something like: [id(1)] HRESULT HelloWorld([out, retval]vector *Output); I would really appreciate help on this one!!!! Cheers, Tony.
Use of SOAP 3 will save you a lot of time. Go MSDN and download the kit, look into the sample. String array can be a comma separated, Recordset, XML format. SAFEARRAY is in fact not more than a struct, why must you stuck with it? Be more creative in solving the problem. :)