This sort of thing is really beyond what can be effectively supported in
a
newsgroup in the short-term. You need to know how COM works, so you can
go
off and read one of the many books on that to get a feel for what sort of
things are necessary to instantiate COM objects, call their methods, etc.
As you've found, you need to initialize COM to allow anything to work,
but
you need also to have any objects that you want to create registered in
the
device registry and implemented in DLLs or EXEs on the device. That's
what
the error you've gotten is indicating: the code that you're running there
is
trying to do a CoCreateInstance() COM call to make an object instance,
but
the ID of that object is not found in the device registry, so the call
can't
complete.
Paul T.
On Feb 25, 2:18 pm, "<ctacke/>" <ctacke[at]opennetcf[dot]com> wrote:
Then you simply need to make the SOAP calls in native code - there's
nothing
magical about it and it's documented rather well. Desktop examples
will be
relevent becasue you'll be making the same calls as you would on the
desktop.
Chris Tacke, eMVP
Join the Embedded Developer Communityhttp://community.opennetcf.com
I need to develop a dll in C++ which calls a web service for a
smart
device/WM. The reason for using C++ is because, that this dll has
to
be invoked from a non-dot-net application from the device.
I need to develop the Dll in such a way that i don't have to
install
compact framework on the device.
Any help would be appreciated.
Hi Chris,
Unfortunately I have not worked that much in C++. Could you please
forward me any link, that would help me get started that explains me
how to make a SOAP call in a unmanaged C++ code.
Thanks in advance,
Hi Chris,
I did some research and got some initial code to call the web
service.
CoInitializeEx(NULL, COINIT_MULTITHREADED);
BSTR result = NULL;
StockQuote::CStockQuoteT<CSoapSocketClientT<>> * ws = new
StockQuote::CStockQuoteT<CSoapSocketClientT<>>();
ws->SetProxy();
HRESULT hr = ws->GetQuote(CComBSTR("SY"),&result);
However when I run it, it gives me Class not registered error. I don't
have any clue why this error is coming up.
Haroon
Any help in this regard.
Hi Paul and Chris,
With little bit of effort, i have managed to run the above code as a
dll which calls a web service.
The dll returns the result of the web service called by a non dot net
application.
Everything seems to be working fine now, but with one very strange
event.
The point where i am calling the web service method in the code i.e.
HRESULT hr = proxy-
ProcessRequest(merchantId,cc,expiryDate,amount,&result);
Sometimes while calling this method, the hr variable returns FAILURE.
I assum that the web service method has not been called when this
happens.
I am also maintaining the logs at the web service side, which tells me
that the method has been called successfully even the above code
returned a failure.
And secondly this happens randomly. At one point it happens after 100
calls to the web service method and in second case, it happens in the
first attempt.
I am putting my whole function code below.
Could someone please help me where i am doing something wrong.
Secondly i am quite new to C++, in this code, is there any memory
leak, which might be shewing up the memory after every dll access.
Thanks in advance,
Haroon
extern "C" BSTR WINAPI processCC(BSTR merchantId,BSTR cc,BSTR
expiryDate,BSTR amount)
{
BSTR result = NULL;
using namespace std;
// Creating Web Service the proxy
Service::CServiceT<CSoapSocketClientT<>> * proxy = new
Service::CServiceT<CSoapSocketClientT<>>();
// If not initialized return NULL
HRESULT h = ::CoInitializeEx(NULL,COINIT_MULTITHREADED);
ofstream file;
SYSTEMTIME st;
GetLocalTime(&st);
if(FAILED(h))
{
// Uninitialize proxy object.
proxy->Uninitialize();
proxy->Cleanup();
// delete file object
delete file;
// Closes the COM library, unloads the dlls
::CoUninitialize();
return CComBSTR("CoInitializeExError");
}
try
{
// Set Proxy
proxy->SetProxy();
// Call the web service. The result is saved in result variable
HRESULT hr = proxy-
ProcessRequest(merchantId,cc,expiryDate,amount,&result);
// If not succeeded return NULL;
if (SUCCEEDED(hr))
{
file.open("payments.log",ios::app);
file << st.wHour << ":" << st.wMinute << ":" << st.wSecond <<
"\n";
file.close();
// Uninitialize proxy object.
proxy->Uninitialize();
proxy->Cleanup();
// delete file object
delete file;
// Closes the COM library, unloads the dlls
::CoUninitialize();
return result;
}
else
{
file.open("payments.log",ios::app);
file << "Failure: " << st.wHour << ":" << st.wMinute << ":" <<
st.wSecond << "\n";
file.close();
// Uninitialize proxy object.
proxy->Uninitialize();
proxy->Cleanup();
// delete file object
delete file;
// Closes the COM library, unloads the dlls
::CoUninitialize();
return CComBSTR("WebServiceCallFailed");
}
}
catch(char *error)
{
//MessageBox(0,CComBSTR("Exception Error"),CComBSTR("Exception
Error"),0);
// Uninitialize proxy object.
proxy->Uninitialize();
proxy->Cleanup();
// delete file object
delete file;
// Closes the COM library, unloads the dlls
::CoUninitialize();
return CComBSTR("ExceptionError");
}
}