Web Service Portability

When you create an application that relies upon web services, the simplest way to define the location of those web services is by specifying them at design time. The problem, of course, is when you want to deploy a development web service on one server to a live environment on another server. The answer? At design time, specify the “URL Behaviour” property of the web reference to “Dynamic”. This will add en entry to the app.config (or web.config) file for each web reference that looks like the following…

<appSettings> <add key="Full.NameSpace.Of.Web.Reference" _ value="http://servername/webservicepath/servicename.asmx"/> </appSettings>

With this in place, it is possible to move the physical location of the web services around without having to recompile your client application.

*CAVEAT* I have heard rumour that if the name of the service includes the string “static”, this can break the functionality described above. I do not know for sure if this is the case, but it is a possible place to start debugging in the event of failure.