Can I change a web service reference URL in the Config file?

I have an application targeting the 2.0 .NET framework. The solution is using the VS web service reference folder. A grep through the solution reveals that this URL lives in a handful of files. However in the deployed application a search shows that the URL lives in only the .config. So what happened to the .disco and .wsdl? Are they compiled into the .exe? Basically, I need to update the URL and I need to know if this requires a new build.

Thanks!


Yes, you can change the URL that's being referenced at runtime.

If it's in a .config file, IIS will your app should detect the change in the .config file and load the new value. If not, then you'd have to restart the client. Perhaps you can stop and start the Web Site in IIS.

Further, you can definitely WRITE your code to read from a .config file.

  var myWS = new MyWebService();
  myWS.Url = WebServiceURL;
  myWS.SomeMethod();                     

private static string WebServiceURL { 
   get { return ConfigurationManager.AppSettings["MyWebServiceURL"].ToString(); }           }

Meanwhile in your .config file, you have:

  <appSettings>
    <add key="MyWebServiceURL" value="http://blah/foo/bar.asmx" />
  </appSettings>

您可以更改网页配置中的网址(如果网络服务保持不变,不确定web服务是否已更改)

链接地址: http://www.djcxy.com/p/43096.html

上一篇: iPhone和服务器之间的安全通信?

下一篇: 我可以在配置文件中更改Web服务参考URL吗?