从一个客户端使用多个 WCF 服务 [英] Consume multiple WCF services from one client

查看:25
本文介绍了从一个客户端使用多个 WCF 服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 10 台运行 IIS 的服务器的网络农场,在每台服务器上我都有相同的网站和相同的 WCF 服务(它公开了一些用于读取/删除缓存、会话、应用程序变量、其他内部数据的功能)

I have web farm with 10 servers running IIS, on every one of them I have the same web site together with the same WCF service (which expose some functionality for reading/deleting cache, sessions, application variables, other internal data)

在其他一些 Web 服务器上,我有一个管理"Web 应用程序,它是上述 WCF 服务的客户端.

On some other web server I have an "administration" web application which is a client to the WCF services described above.

为这种架构创建和管理代理的最佳方法是什么?

What is the best way to create and manage proxy for this kind of architecture?

如果具有 WCF 服务的新服务器可用,以不需要重新编译客户端应用程序的方式使用来自 Web 场服务器的 WCF 服务的推荐方法是什么?

What is the recommended way to consume the WCF services from the web farm servers in a way it does not require to recompile the client application if new server with WCF service is available?

你能给我指出一些显示类似设置的资源吗?

Can you point me to some resources where is shown some similar setup?

提前致谢

推荐答案

如果服务在多台服务器上是相同的,那么很简单,只需在打开连接时提供端点地址即可;

If the service is the same on multiple servers then it's easy, simply provide the endpoint address when opening the connection;

MyHelloServiceClient proxy = new MyHelloServiceClient("myServerNameorIP");

代理的构造函数中有一个可选参数(假设您使用代理生成),它采用服务器名称或 EndpointAddress.

There is an optional parameter in the constructor for the proxy (assuming you're using proxy generation) which takes a server name, or an EndpointAddress.

那么您所需要的只是一个可供您选择的服务器列表.

Then all you need to have is a list of servers somewhere which you can choose from.

这篇关于从一个客户端使用多个 WCF 服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆