I have web service:
http://127.0.0.1/something/someWS.asmx
I am adding this as a Web Reference to my app but wont always be Localhost... it might change to http://www.something.com/something/someWS.asmx.
How do I change the URL programmatically of my Web Reference? is it as simple as:
using (var service = new MyApi.MyApi())
{
//txtUrl is the site
service.Url = "http://" + txtUrl + "something/someWS.asmx";
}
ALSO, once I change it, how do I update it programmatically? (equivalent to right-clicking and selecting "Update Web Reference")
side-note: What I am trying to ultimately accomplish is dropdowns of the available methods based on the asmx WebService available on the server (service.Url)
As John Saunders commented the way you trying to take to talk to 2 versions of a service is not technically possible. You are trying to mix compile/design time action ("update Web reference") with runtime one.
Easy approach would be to look at the problem as talking to 2 completely different data sources providing similar data. This is well researched approach with plenty of samples - data repository is one of the search terms.
Implementation:
Code:
interface IMyData
{
string GetLastName();
}
class MyDataFromOldWebService
{
MyApi.MyApiV1 service;
MyDataFromOldWebService(MyApi.MyApiV1 service)
{
this.service = service;
}
public string GetLastName()...
}
Dictionary<string, IMyData> services = new Dictionary<string, IMyData>()
{
{ "Old Service", new MyDataFromOldWebService(new MyApi.MyApiV1(url))}
};