views:

31

answers:

1

I have a Visual C++ application that communicates with an ASP.NET web service via ATL Soap. The client application uses an sproxy-generated proxy class for the communication. Looking at the generated proxy class, I noticed that the url for the web service is hard-coded in numerous places.

It would be preferable for the url to be configurable at run-time (e.g. stored in a config file). Could anyone recommend a method for doing this? It doesn't look like the class generated by sproxy is amenable to hand-editing.

A: 

The hard-coded URL seen in the generated proxy code is just the default. An alternate URL for the service can be specified at run-time by calling the SetUrl method on the proxy object.

int _tmain(int argc, _TCHAR* argv[])
{
    CoInitialize(NULL);
    {
        TestService::CTestService ws;
        BSTR input = _bstr_t(_T("This is my input"));
        BSTR result;
        ws.SetUrl(_T("http://dummyUrl/dummyservice.asmx"));
        ws.Echo(input, &result);
    }
    CoUninitialize();

    return 0;
}
Odrade