I want to be able to switch between a local test Web Service and a server
based live Web Service.
When testing numerous web forms I need to switch their Web Service reference between a local development service and the live one.
At the moment this involves replacing the declaration 'TestWebService' with 'LiveWebService' in each form.
What I would like to do is have a utilities class that has a static function
that returns a reference to the appropriate web service depending upon a key
in web.config.
I would be able to do this if I knew how to declare the return value of the
function:
internal static ???? GetWebService()
{
string lstrWebService =
ConfigurationSettings.AppSetting["WebService"].ToString();
if(lstrWebService == "Test")
{
return ????;
}
else
{
return ????;
}
}
Anyone know what the ???s should be or if what I want is not possible.What do you mean by returning a "a reference to the appropriate web service"? Can you show me an example?
What do you mean by returning a "a reference to the appropriate web service"? Can you show me an example?
I've got 2 Web Services referenced and I wanted to switch between them, but I now realise that this is totally the wrong way to do it!!!
I'm going to have only one service referenced and change its URL when necessary. All I need to do is ensure that the services maintain the same contracts.
A real blonde moment, or moments 'cos I've been doing it wrong for ages. :blush:
I was thinking along the same lines but your initial post confused me (with the Return values). The only thing that did require changing, as you've seen, was the .URL property...
0 comments:
Post a Comment