问题
In a fairly standard fashion, I created a Web Reference to a SOAP service in Jira for an extension that I'm building (Jira is an issue tracker for those unfamiliar with it). Visual Studio auto-generates a .Settings file and an app.config that contains the web service URL.
Since I'm developing an extension/plugin to an ALM product we're building, the consumer of the extension will be the one who ultimately decides where this web service points to, because it will be integrated with the consumer's instance of Jira. Assume that the web service URL would be stored and pulled from a database.
How can I get the auto-generated service to use a URL from a database instead of from the generated app.config?
Note: we are using v2.0 of the framework, so WCF is not an option.
回答1:
Even in the 2.0 web service you should be able to change the "Url" property of your web service proxy to the value you desire.
回答2:
Use the constructor of the client that admits the uri.
来源:https://stackoverflow.com/questions/2245792/can-you-change-the-location-endpoint-of-a-dynamic-web-reference-at-run-time-in