What should be modified to change the URL of a web service in C#?

☆樱花仙子☆ 提交于 2019-12-28 04:27:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!