<分区> 分区>
我有一个使用 asmx 网络服务的 WCF 应用程序。我在应用程序中的一百万个地方使用网络服务:
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...
当然,我想在构造函数中设置服务的 url,但它在 reference.cs 中自动生成,如果我在那里更改它,它会工作,但如果我更新我的引用(我会)它丢失了,我必须再次手动执行:
/// <remarks/>
public ASMXServiceInterface()
{
this.Url =
System.Web.Configuration.WebConfigurationManager.AppSettings["RQTCSServiceURL"];
}
Web 服务 URL 需要是动态的,因为已经实现了不同的版本。我如何在我的 WCF 项目中设置我的 web 服务的 url,以便可以在 web.config 中更改服务的 url,而不必在 reference.cs 中进行?
