路由协定

路由协定定义路由服务可处理的消息模式。每个协定都是无类型协定,允许服务在不了解消息架构或操作的情况下接收消息。这样,路由服务就可以按照通常方式来路由消息,而不必对路由的基础消息的细节进行额外配置。

路由协定

由于路由服务接受泛型 WCF 消息对象,因此,在选择协定时,首先需要考虑与客户端和服务通信时将采用的通道的形状。路由服务在处理消息时使用对称消息泵,因此,入站协定的形状通常必须与出站协定的形状匹配。但是,在一些情况中,服务模型的调度程序可以修改这些形状。例如下面的情况:调度程序将双工通道转换为请求-答复通道,或者在不需要且未使用会话支持时从通道中删除此支持(即,在启用 SessionMode.Allowed 的情况下将 IInputSessionChannel 转换为 IInputChannel 时)。

为了支持这些消息泵,路由服务在 System.ServiceModel.Routing 命名空间中提供了一些协定,当定义路由服务使用的服务终结点时,必须使用这些协定。这些协定都是无类型协定,允许接收任何消息类型或操作,并允许路由服务在不了解特定消息架构的情况下处理消息。有关路由服务使用的协定的更多信息,请参见路由协定

路由服务提供的协定位于 System.ServiceModel.Routing 命名空间中,下表对这些协定进行了说明。

协定 形状 通道形状

ISimplexDatagramRouter

SessionMode = SessionMode.Allowed

AsyncPattern = true

IsOneWay = true

IInputChannel -> IOutputChannel

ISimplexSessionRouter

SessionMode = SessionMode.Required

AsyncPattern = true

IsOneWay = true

IInputSessionChannel -> IOutputSessionChannel

IRequestReplyRouter

SessionMode = SessionMode.Allowed

AsyncPattern = true

IReplyChannel -> IRequestChannel

IDuplexSessionRouter

SessionMode=SessionMode.Required

CallbackContract=typeof(ISimplexSession)

AsyncPattern = true

IsOneWay = true

TransactionFlow(TransactionFlowOption.Allowed)

IDuplexSessionChannel -> IDuplexSessionChannel

另请参见

概念

路由简介

其他资源

Routing Service