configuration file, rather than a hardcoded value. To change the location,
simply change the config file with no recompile.
Here’s how to do it:
Add your web reference. Go to "Solution Explorer", right click on the web
reference name (eg. "localhost") and choose properties. In the property
window change "Url Behavior" from "Static" to "Dynamic".
If the web service client is a non-web application, this will automatically
create a file name app.config with the URL to the web service.
After you comiple your client app, the configuration file of it (such as
something.exe.config) will have the same content as the app.config.
Now, you can deploy the configuration along with the client executable. If
you ever need to change the web service location, you can open the
something.exe.config file in notepad and change the value attribute.
If the web service client is a web application such as asp.net web form,
changing "Url Behavior" from "Static" to "Dynamic" will automatically add
the same appsettings to web.config. Now, if you ever need to change the web
service location, you can open web.config file in notepad and change the
For Service URLs that change more often or at runtime, you can write custom
code to change the URL property off of the proxy class.
ws.Url = CompatibleCustomerServices(2) //bind to a the next compatible
service in the list
Outside VS.NET, you can use "wsdl.exe /urlkey:
automatically checks in the
When using "wsdl.exe /urlkey:myapplication.mywebservice.service1
able to use the following configuration file to read the URL without any
further manual changes needed: