How can I dynamically switch web service addresses in .NET without a recompile?

后端 未结 11 961
小蘑菇
小蘑菇 2020-11-28 09:11

I have code that references a web service, and I\'d like the address of that web service to be dynamic (read from a database, config file, etc.) so that it is easily changed

11条回答
  •  北海茫月
    2020-11-28 09:39

    Just a note about difference beetween static and dynamic.

    • Static: you must set URL property every time you call web service. This because base URL if web service is in the proxy class constructor.
    • Dynamic: a special configuration key will be created for you in your web.config file. By default proxy class will read URL from this key.

提交回复
热议问题