Change WebService Proxy URL in Visual Studio .NET 2008
-
21-09-2019 - |
Question
I've created a WebService Proxy from a given URL, but at runtime a need to change this URL depending of some conditions.
How to do it?
I've searched on the web and founded that I should change the "Url" property. But, some how, this property isn't exposed in my proxy class.
I am using Visual Studio .NET 2008
Solution
If you are talking about the "classic" SOAP web service proxy (created like this: http://alexduggleby.com/2008/08/24/add-web-reference-instead-of-service-reference-in-visual-studio-2008/), it really has an URL
property.
If you are using Service references as in "new" WCF web services, take a look at this SO post: How to consume WCF web service through URL at run time?
OTHER TIPS
try
ServiceClient client = new ServiceClient();
client.Url = <new Url>
Or if you want it configurable, the classical way was: set the web service reference: URL Behavior to dynamic and set it at the config file as mentioned in :