Hello,
I'm trying to use a web service from my MFC C++ app.
For testing purposes, I created the simple web service in VS2005:
[WebMethod]
public int Sum(int num1, int num2)
{
return (num1+num2);
}
I tested it firstly using asp.net and it worked fine. To make this test, so
I could add a web reference, I
created a web site in IIS for the web service so I could test using
http://localhost/webservice/WSTest.asmx
Following that, I created a win32 console app, added a web reference to the
above
URL (which showed my Sum() method) and coded:
int _tmain(int argc, _TCHAR* argv[])
{
if(SUCCEEDED(CoInitialize(NULL)))
{
WSTest::CWSTest obj;
HRESULT hr;
int result=0;
hr = obj.Sum(3,4,&result);
if (SUCCEEDED(hr))
cout << "result = " << result;
else
cout << "error";
return 0;
CoUninitialize();
}
The problem is the call to obj.Sum() never succeeds (hr = E_FAIL). When I
created the console app, I selected ATL support, but I'm not sure if it's
needed.
What am I doing wrong?
Jeová