WCF服务管理
例如,我有一个为客户端提供服务的 WCF 服务。有时我应该向该服务发送一些命令以获得一些结果。例如,如果需要禁止某些客户端,我会发送一些命令,例如“禁止 John Doe”,并且服务会将名为“John Doe”的用户添加到禁止列表中。我怎样才能实现它?我应该使用命名管道或类似的东西吗?也许我应该从运行服务的机器上管理服务。服务托管在独立的控制台应用程序中。 提前致谢!
For instance, I have a WCF service that serve clients. Sometimes I should send some commands to that service to get some results. For example, if it's necessary to ban some client I would send some command like "ban John Doe" and service will add user named "John Doe" to ban list. How can I implement that? Should I use named pipes or something like that? Probably I should manage service from machine where service is running. Service is hosted in standalone console application.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可以使用
Code
执行此操作,只需执行以下步骤:Notify self
服务(将属性添加到所有方法作为名称或 Id)ClientList
ban Client
client 列表中不存在
,仅返回无值对于任何方法It's possible with do this with
Code
just you Need to do these step`s:Notify self
on service(add property to all method as Name or Id)ClientList
ban Client
From That Listclient Doesn't exist
in list, simply return none value for any Method创建访问同一数据存储的多个服务。一份用于客户,一份用于管理。
为什么?
请参阅:http://en.wikipedia.org/wiki/Interface_segregation_principle
如何?
使用数据库,并从两个服务连接到该数据库。 如果您还没有数据库,那么像 SqLite 这样占用空间小的东西可能会起作用。
绑定:
命名管道可能是您的绑定的好主意,因为它们无法通过网络访问。这是一个教程:
但在迈出这一步之前请先检查一下这个问题:
如果这看起来风险太大,您可以使用 net-tcp 代替:
Create multiple services that access the same datastore. One for clients, and one for administration.
Why?
See: http://en.wikipedia.org/wiki/Interface_segregation_principle
How?
Use a database, and connect to it from both services. Something with a small footprint like SqLite might work if you don't already have a DB.
Bindings:
Named pipes might be a good idea for your binding since they aren't network accessible. Here is a tutorial:
But check out this question before you make the leap:
If that seems too risky, you could use net-tcp instead: