Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 538
Nick Avatar asked Sep 09 '09 16:09

Nick


1 Answers

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>
like image 100
p.campbell Avatar answered Oct 04 '22 18:10

p.campbell