WCF扩展之实现ZeroMQ绑定和protocolBuffer消息编码(一)概要设计
- 客户端调用的方式是一致的
- 服务端处理请求的方式是一致的
- 服务的实例管理的方式是一致的
- 设计服务的操作模式的方式是一致的
- 如果将自定义数据作为服务的参数,数据的定义是一致的
- 处理异常的方式是一致的
- 如果连接的通信技术支持事物,事物的处理是一致的
WCF可以隔离业务层和技术层,体现在:
- 当客户端调用服务时,可以不需要知道服务端的实现语言和平台
- 当服务端处理请求时,可以不需要知道客户端的实现语言和平台
- 实现WCF的服务端时,只需要考虑业务接口的实现,另外接口和方法添加少量的属性、在配置中添加服务的地址
- 实现WCF的客户端时,只需要按照协议调用服务,另外在配置中添加服务的地址






虽然ZMQBinding和ProtocolBufferMessageExtension的做了很多转换工作,但是一旦将它们注册到WCF中,应用开发人员的工作量很小。
- 当把WCF作为服务端,ZMQ作为客户端时,WCF服务端需要如下步骤:
[ServiceContract]
public interface IService1
{
[OperationContract]
string UpdatePatients(WCF_Client_ZMQBinding.iStationMovementPos move);
}
public class Service1 : IService1
{
public string UpdatePatients(WCF_Client_ZMQBinding.iStationMovementPos move)
{
return "wcf response";
}
}
自定义数据编码是采用了反射的方式,把iStationMovementPos转成protocolBuffer的可序列化的类类型。
public class iStationMovementPos
{
public int IhMaxPos{get;set;}
public int IhPos {get;set;}
public int IhMinPos{get;set;} public int IvMaxPos{get;set;}
public int IvPos {get;set;}
public int IvMinPos{get;set;} public int IaMaxPos{get;set;}
public int IaPos {get;set;}
public int IaMinPos{get;set;} public bool LaserStatus {get;set;}
public int CouchMarkPos { get; set; }
}
ServiceHost host = new ServiceHost(typeof(Service1));
host.Open();
- 当把ZMQ作为服务端,WCF作为客户端时,WCF客户端需要如下步骤:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName = "ServiceReference1.IService1")]
public interface IService1
{ [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IService1/DoWork", ReplyAction = "http://tempuri.org/IService1/DoWorkResponse")]
[ProtocolBufferMessageExtension.Formatter.PBFormatMessage]
string DoWork(iStationMovementPos move); [System.ServiceModel.OperationContractAttribute(Action = "http://tempuri.org/IService1/DoWork", ReplyAction = "http://tempuri.org/IService1/DoWorkResponse")]
System.Threading.Tasks.Task<string> DoWorkAsync(iStationMovementPos move);
} [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface IService1Channel : Client.ServiceReference1.IService1, System.ServiceModel.IClientChannel
{
} [System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class Service1Client : System.ServiceModel.ClientBase<Client.ServiceReference1.IService1>, Client.ServiceReference1.IService1
{ public Service1Client()
{
} public Service1Client(string endpointConfigurationName) :
base(endpointConfigurationName)
{
} public Service1Client(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress)
{
} public Service1Client(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
base(endpointConfigurationName, remoteAddress)
{
} public Service1Client(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress)
{
}
public string DoWork(iStationMovementPos move)
{
return base.Channel.DoWork(move);
}
public System.Threading.Tasks.Task<string> DoWorkAsync(iStationMovementPos move)
{
return base.Channel.DoWorkAsync(move);
}
}
iStationMovementPos move = new iStationMovementPos()
{
IhMaxPos = ,
IhMinPos = ,
IaPos = ,
IaMaxPos = ,
IaMinPos = ,
IhPos = ,
IvMaxPos = ,
IvMinPos = ,
IvPos = ,
LaserStatus = true,
CouchMarkPos =
};
Service1Client client = new Service1Client();
string res = client.DoWork(move);
WCF扩展之实现ZeroMQ绑定和protocolBuffer消息编码(一)概要设计的更多相关文章
- WCF扩展之实现ZeroMQ绑定和protocolBuffer消息编码(二)实现IRequestChannel(2016-03-15 12:35)
这是这个系列的第二篇,其他的文章请点击下列目录 WCF扩展之实现ZeroMQ绑定和protocolBuffer消息编码(一)概要设计 WCF扩展之实现ZeroMQ绑定和protocolBuffer消息 ...
- WCF扩展之实现ZeroMQ绑定和protocolBuffer消息编码(三)实现ReplyChannel(2016-03-15 12:35)
这是这个系列的第三篇,其他的文章请点击下列目录 WCF扩展之实现ZeroMQ绑定和protocolBuffer消息编码(一)概要设计 WCF扩展之实现ZeroMQ绑定和protocolBuffer消息 ...
- WCF扩展系列 - 行为扩展(Behaviors)
原文地址:http://www.cnblogs.com/Creator/archive/2011/05/21/2052687.html 这个系列的第一部分将会重点关注WCF行为(behaviors), ...
- 【转】WCF扩展系列 - 行为扩展(Behaviors)
原文:https://www.cnblogs.com/Creator/archive/2011/05/21/2052687.html 这个系列的第一部分将会重点关注WCF行为(behaviors),W ...
- 真实世界:使用WCF扩展记录服务调用时间
WCF 可扩展性 WCF 提供了许多扩展点供开发人员自定义运行时行为. WCF 在 Channel Layer 之上还提供了一个高级运行时,主要是针对应用程序开发人员.在 WCF 文档中,它常被称为服 ...
- WCF 服务的ABC之绑定(六)
绑定 Binding 绑定是开发人员控制WCF程序与其他消息交互的主要手段.从功能上看,绑定创建了通道工厂惑通道侦听器的堆栈对象.绑定直接惑间接创建的对象是WCF实现各种消息功能(例如,传输.安全性. ...
- WCF扩展
WCF 可扩展性 WCF 提供了许多扩展点供开发人员自定义运行时行为. WCF 在 Channel Layer 之上还提供了一个高级运行时,主要是针对应用程序开发人员.在 WCF 文档中,它常被称为服 ...
- 扩展SpringMVC以支持绑定JSON格式的请求参数
此方案是把请求参数(JSON字符串)绑定到java对象,,@RequestBody是绑定内容体到java对象的. 问题描述: <span style="font-size: x-sma ...
- WCF 项目应用连载[8] - 绑定、服务、行为 大数据传输与限流 - 下 (ServiceThrottlingAttribute)
因为ORM的原因,对Attribute编程有一种情节..所以这节的出现,完全是因为在WCF对自定义Attribute的一种应用. WCF 项目应用连载[7] - 绑定.服务.行为 大数据传输与限流 - ...
随机推荐
- [Django实战] 第5篇 - 用户认证(修改密码)
上一篇我们实现了用户认证系统的登录模块,这一篇实现修改密码模块. 同样地,我们首先得给修改密码创建表单(forms.py): class ChangepwdForm(forms.Form): oldp ...
- Delphi XE中类成员的访问权限(新增了strict private和strict protected,还有automated)
Delphi XE中类成员的访问权限共提供了6个关键词来用于限定访问权限:public.private.protected.published.automated strict private . s ...
- Unity3D游戏开发之开发游戏带来的问题
昨日曾就某投资人把移动团队失败原因之中的一个归于选择Unity引擎进行了一番评论,工具本身无罪,但怎样理解工具.正确使用Unity引擎确实须要讨论,在选择Unity之前你也许须要了解下这个引擎实际开发 ...
- Linux SSH常用总结(转)
一.连接到远程主机 格式: ssh name@remoteserver 例如: ssh ickes@192.168.27.211 二.连接到远程主机指定的端口 格式: ssh name@remotes ...
- OCP读书笔记(9) - 诊断数据库
数据库恢复顾问 Data Recovery Advisor的命令行选项 1. 启动 RMAN 进程并连接到目标$ rman target=/ 2. 假设发生了某个错误,希望找出原因,使用 list f ...
- POJ 4003 Bob’s Race && HDU4123 Bob’s Race (dfs+rmq)
Bob’s Race Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 378 Accepted: 119 Descript ...
- Leetcode_num13_Climbing Stairs
称号: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either cl ...
- 在gem5的full system下运行 alpha编译的测试程序 running gem5 on ubuntu in full system mode in alpha
背景 先需要在full system下运行gem5,通过网上查找资料以及向别人请教,终于成功运行,网上大多是关于alpha指令集的,且都是英文的,为了方便大家学习,现在总结一下,希望对大家有所帮助. ...
- 提领NULL指针
通常之中导致程序崩溃的最重要的原因是试图取消引用NULL指针.正如在以前的文章中指出,智能指针RefCountPtr和ScopedPtr它提供了一个诊断的执行时间. 但,并不是所有的指针是所有的对象都 ...
- MVC之文件上传1
MVC之文件上传 前言 这一节我们来讲讲在MVC中如何进行文件的上传,我们逐步深入,一起来看看. Upload File(一) 我们在默认创建的项目中的Home控制器下添加如下: public Act ...