开发者

WCF consume multiple webservices dynamically

开发者 https://www.devze.com 2023-01-25 07:07 出处:网络
I need to consume multiple web services (this is the same service hosted in multiple locations) dynamically. How can I do that?

I need to consume multiple web services (this is the same service hosted in multiple locations) dynamically. How can I do that?

Thank开发者_如何学JAVAs.


If its the same service in multiple locations then the only difference between the services will be the URL.

There is an overload of the service client constructor that takes the URL as a parameter - you can supply an instance of the endpoint class or just a simple string.

This reduces the problem to supplying the appropriate string to the constructor at runtime which should be fairly straightforward (-:

As a rule I tend to explicitly specify (from separate configuration data) all my endpoint URLs when creating clients in code, this provides appropriate flexibility and allows me to easily switch between local, test, instances of services and the live instances.

0

精彩评论

暂无评论...
验证码 换一张
取 消