Use the WSDL tool to generate a proxy class. This essentially does the exact same thing as when you add a Web Reference in Visual Studio -- except that you will now have the underlying .cs file.
The command line call to do this might look something like this: wsdl /out:MyWebServiceProxy.cs [url]http://localhost/blah/service.asmx[/url]This will build the "MyWebServiceProxy.cs" proxy file. Include this in your project and then open up the file. You will notice that the constructor looks like this: public Service()
{
this.Url = "http://localhost/blah/service.asmx";
}You will also notice that this is the only location where the Url is set. So I usually just modify the constructor to look something like this: public Service(string server)
{
this.Url = string.Format("http://{0}/blah/service.asmx", server);
}You can also then wrap the class in your own namespace if you want. From here you can now create an instance of the proxy class with something like the following:
MyNamespace.ServiceX service = new MyNamespace.ServiceX("localhost");
service.HelloWorld();You can then set the server reference as needed by creating new instances of the proxy class. All should work well provided that all servers share the same version of the Web Service.