WCF—Binding

本文深入探讨了WCF绑定机制,包括事务、信赖、安全、编码、传输等层面的信息,提供了各种预设绑定的选择及其特性,以及如何在实际应用中进行选择。通过对比分析,了解各绑定在互操作性、安全性、会话、事务和全双工通信上的差异,以指导开发者合理配置WCF服务。

原文地址: http://www.cnblogs.com/jams742003/archive/2010/01/13/1646379.html

 

Binding描述了哪些层面的信息

一个Binding包含着丰富的信息,每种信息都描述了服务端和客户端交互过程中的一方面,如下表所示,Binding描述了这些层面的信息:

 

层次

备注说明

Transactions(事务)

TransactionFlowBindingElement,用于指定事务流程

Reliability(信赖)

ReliableSessionBindingElement,用于指定对会话方式

Security(安全)

SecurityBindingElement,指定安全方式

Encoding(编码)

Text, Binary, MTOM, Custom,指定数据传输格式

Transport(传输)

TCP, Named Pipes, HTTP, HTTPS, MSMQ, Custom,指定传输方式

 

 

选择正确的Binding

Binding是可以自定义实现的,可WCF框架已经为我们实现了足够多的Binding,供我们来选择,

如下表所示:

 

Binding名称

Configuration Element

描述

BasicHttpBinding

basicHttpBinding

一个指定用符合基本网络服务规范通讯的binding,它用http进行传输,数据格式为text/xml

WSHttpBinding

wsHttpBinding

一个安全的通用的binding,但它不能在deplex中使用

WSDualHttpBinding

wsDualHttpBinding

一个安全的通用的binding,但能在deplex中使用

WSFederationHttpBinding

wsFederationHttpBinding

一个安全的通用的支持WSF的binding,能对用户进行验证和授权

NetTcpBinding

netTcpBinding

在wcf应用程序中最适合跨机器进行安全通讯的binding

NetNamedPipeBinding

netNamedPipeBinding

在wcf应用程序中最适合本机进行安全通讯的binding

NetMsmqBinding

netMsmqBinding

在wcf应用程序中最适合跨机器进行安全通讯的binding,并且支持排队

NetPeerTcpBinding

netPeerTcpBinding

一个支持安全的,多机交互的binding

MsmqIntegrationBinding

msmqIntegrationBinding

一个用于wcf与现有msmq程序进行安全通讯的binding

 

 

下面的表格分别删除了上表中的Binding在互操作性(Interoperability), 安全性(Security), 是否支持会话(Session), 是否支持事务(Transactions)和是否为全双工(Duplex)上不同。

 

 

 

Bingding

Interoperability

Security

Session

Transactions

Duplex

BasicHttpBinding

Basic Profile 1.1

(None), Transport, Message

None, (None)

None

n/a

WSHttpBinding

WS

Transport, (Message), Mixed

(None), Transport, Reliable Session

(None), Yes

n/a

WSDualHttpBinding

WS

(Message)

(Reliable Session)

(None), Yes

Yes

WSFederationHttpBinding

WS-Federation

(Message)

(None), Reliable Session

(None), Yes

No

NetTcpBinding

.NET

(Transport), Message

Reliable Session, (Transport)

(None), Yes

Yes

NetNamedPipeBinding

.NET

(Transport)

None, (Transport)

(None), Yes

Yes

NetMsmqBinding

.NET

Message, (Transport), Both

(None)

(None), Yes

No

NetPeerTcpBinding

Peer

(Transport)

(None)

(None)

Yes

MsmqIntegrationBinding

MSMQ

(Transport)

(None)

(None), Yes

n/a

 

 

 

 

 

·BasicHttpBinding: 最简单的绑定类型,通常用于 Web Services。使用 HTTP 协议,Text/XML 编码方式。
·WSHttpBinding: 比 BasicHttpBinding 更加安全,通常用于 non-duplex 服务通讯。
·WSDualHttpBinding: 和 WSHttpBinding 相比,它支持 duplex 类型的服务。
·WSFederationHttpBinding: 支持 WS-Federation 安全通讯协议。
·NetTcpBinding: 效率最高,安全的跨机器通讯方式。
·NetNamedPipeBinding: 安全、可靠、高效的单机服务通讯方式。
·NetMsmqBinding: 使用消息队列在不同机器间进行通讯。
·NetPeerTcpBinding: 使用 P2P 协议在多机器间通讯。
·MsmqIntegrationBinding: 使用现有的消息队列系统进行跨机器通讯。如 MSMQ。

仅作参考。

片段摘自:

http://www.rainsts.net/article.asp?id=439

http://www.cnblogs.com/jillzhang/archive/2008/02/03/1063406.html

博客园大道至简

http://www.cnblogs.com/jams742003/

转载请注明:博客园

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值