views:

67

answers:

3

Hi,

I have one problem and it is some time ago I have added a Webservice proxy class into my application by copying all the generated code (copy paste the text of the .cs content).

And it worked!

But now I need to change the URL used by this web-service proxy class and I am not sure what and where to change in the code.

I would appreciate if you can give me a clue that can guide me to find the right place so that I can update the url of the web service.

Thanks!

+2  A: 

If it´s a generated asmx webservice proxy the proxy class have a property - URL.
You can set the URL property where you create the proxy object or you can hard code it into the proxy class.
By default a generated proxy class have code in the constructor to set the URL property from application settings.

Jens Granlund
+1 This is exactly what Burak tried and It worked.
ydobonmai
@Ashish, I know, but you have a good point. It´s better to have the url in web.config or app.config than to hard code it.
Jens Granlund
+2  A: 

You should change the URL using web.config. If you go to the properties of the web reference added, you should see a property named "'URL Behavior'". Set the value of that to "dynamic" and supply the URL. That would make an entry in the web.config and whenever you change that entry, that URL will be taken. More info here.

ydobonmai
Yes, I have found the constructor method and did my changes here in the line ( this.Url = "http://myNewURL" ).Thanks!
burak ozdogan
Cool. What I was suggesting this change should go via config rather than code(constructor) so that you avoid changes in code in future again just for changing the URL. Dynamic URL is one way to achieve that.
ydobonmai
A: 

Use the URL property

KZoal