我想在运行时更新 web.config applicationSettings 中的 Web 引用 Url
这是网络配置应用程序设置
<applicationSettings>
<ItineraryBuilder.Properties.Settings>
<setting name="ItineraryBuilder_SchedulesConnectionsService_SchedulesConnectionsService"
serializeAs="String">
<value>http://www.pathfinder-xml.com/soap/*/services/SchedulesConnections</value>
</setting>
<setting name="ItineraryBuilder_SalesForceService_SforceService"
serializeAs="String">
<value>https://login.salesforce.com/services/Soap/c/25.0/0DFd00000000Wa6</value>
</setting>
<setting name="ItineraryBuilder_OAGService_CBWSPublicService"
serializeAs="String">
<value>http://ondemand.oag.com:80/CBWebServicePublic/CBWSPubliclPort</value>
</setting>
</ItineraryBuilder.Properties.Settings>
</applicationSettings>
这是我用来更新的代码
var configuration = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
var section = (System.Configuration.ClientSettingsSection)configuration.GetSection("applicationSettings/ItineraryBuilder.Properties.Settings");
System.Configuration.SettingValueElement sv = new System.Configuration.SettingValueElement();
sv.Equals("https://test.salesforce.com/services/Soap/c/25.0/0DFd00000000Wa6");
section.Settings.Get("ItineraryBuilder_SalesForceService_SforceService").Value = sv;
configuration.Save();
但它不会更新值,而是从设置中删除值标签
早些时候我试图更新 Web 服务 url,但没有工作,所以我遵循这种方法,请你指导我如何更新 Web 服务 url?
这就是我正在做的
SforceService sf = new SforceService();
sf.Url = "test.salesforce.com/services/Soap/c/25.0/0DFd00000000Wa6";;
请帮忙。