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.
If you are fetching the URL from a database you can manually assign it to the web service proxy class URL property. This should be done before calling the web method. If you would like to use the config file, you can set the proxy classes URL behavior to dynamic. Save this answer.
In Solution Explorer, right-click the name of your project, and then click Add Service Reference. In the Add Service Reference dialog box, click Advanced. In the Service Reference Settings dialog box, click Add Web Reference.
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.
Use the constructor of the client that admits the uri.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With