I have a .net web application which has a reference to a web service.
I published the web service to http://myTestServer/service1.asmx and then added a reference to the .net application.
The web service accesses a test datebase which is on myTestServer.
When I want to publish the web application to myLiveServer – having already published a version of my webservice that accesses ‘the live database’ to http://myLiveServer/service1.asmx – how can I change it so the web application references the correct web service – depending on whether I am publishing to the test, or live, server?
For things like connection strings it is easy to change a key in to reference the right server/database. But how do you do this for a web service reference?
You change it the same way you would connection strings — that is, in the web.config, or programmatically if you prefer. In the web.config the address sits under system.serviceModel/client/endpoint.
Programmatically, you can modify your client proxy class’ Endpoint.Address property.