Visual Studio .NET - change the URL of the webservice refernce dynamically

Asked By mostafa hamdy on 27-May-08 11:00 AM

Hello all

I have some asp.net 2.0 web site , and I have added web services to that web site under the app_code folder and it was working correctly , but I have changed the URL of the webservice and after that I doesnt work , I want to set  the the URL of the webservice to Dynamic but there's no proprty like that for the we service

please if any body knows how to do that and can help me please send me

regards

Mostafa

change the URL of the webservice reference dynamically

Partha Mandayam replied to mostafa hamdy on 27-May-08 11:24 AM
Here's an article on setting webservice references dynamically Simply choose the properties of the web service and change the "Url Behavior" from "Static" to "Dynamic". This will automatically create an entry in the section of the Web.Config file that contains the Url string. The constructor of the Web Service proxy class is automatically changed to set the Url property to the value stored in Web.Config. http://aspalliance.com/283_Setting_Web_Service_References_Dynamically

change the URL of the webservice reference dynamically

mostafa hamdy replied to Partha Mandayam on 27-May-08 11:32 AM

hello

many thanx about ur reply , but the URL whcih u send me I have read so far and it's not suitable because when I right click the webservice there's no properties for the webservice, I dont know why , I also tried to do it at run time as mentioned in the articale u send , but also didnt work ,may be because my web services added under app_webrefernces folder?! I dont know  please again if any body know and  can help me in solving this problem please send me

regards

Mostafa

change the URL of the webservice reference dynamically

Partha Mandayam replied to mostafa hamdy on 27-May-08 12:51 PM
See if this helps http://www.knowdotnet.com/articles/dynamicwebserviceurls.html
Simple problem, simple solution:`
Peter Bromberg replied to mostafa hamdy on 27-May-08 09:52 PM

When you create an instance of your webservice proxy class, it has a .Url property.

All you need to do is set this to the appropriate Url prior to making any method calls.


check this...
Santhosh N replied to mostafa hamdy on 27-May-08 11:56 PM

Check this article on how to do this even after adding the web reference for the service...

The trick is to change the reference.cs

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

See This
Shailendrasinh Parmar replied to mostafa hamdy on 28-May-08 12:21 AM
REfer the following articles ::

http://www.knowdotnet.com/articles/dynamicwebserviceurls.html
http://aspalliance.com/283
http://dotnet.editme.com/tipDynamicallyChangeWebserviceURL