问题
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.
回答1:
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.
回答2:
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.
回答3:
Use the URL property
来源:https://stackoverflow.com/questions/2810967/what-should-be-modified-to-change-the-url-of-a-web-service-in-c