Daniel Silveira
Daniel Silveira

Reputation: 42553

Change WebService Proxy URL in Visual Studio .NET 2008

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

Upvotes: 0

Views: 2181

Answers (2)

sandyiit
sandyiit

Reputation: 1705

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 :

http://www.codeproject.com/KB/XML/wsdldynamicurl.aspx

Upvotes: 0

naivists
naivists

Reputation: 33541

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?

Upvotes: 1

Related Questions