This question already has an answer here:
- What should be modified to change the URL of a web service in C#? 3 answers
I have a WCF app that consumes an asmx web service. I use the web service in a million places in the app:
public string LogOnUser(string username, string password, string db)
{
var wsi = new ASMXServiceInterface();
return wsi.LogIn();
}
public string GetNotes(string username, string password, string db)
{
var wsi = new ASMXServiceInterface();
return wsi.GetNotes();
}
etc, etc etc...
Of course i want to set the url of the service in the contructor, but its auto generated in reference.cs and if i change it there, it works but if i update my reference ( and i will) its lost and i have to manually do it again:
/// <remarks/>
public ASMXServiceInterface()
{
this.Url =
System.Web.Configuration.WebConfigurationManager.AppSettings["RQTCSServiceURL"];
}
The web service url will need to be dynamic because different versions of it have been implemented. How can i set the url of my web service once in my WCF project so the url of the service can be changed in the web.config without having to do it in reference.cs?