WCF学习之:Binding

      WCF服务的创建有ABC三点;最复杂的就是binding. binding要解决的问题是:
             1、使用什么方式来传递. 既通讯协议:tcp,http,ipc,msmq等
             2、使用什么编码方式。比如xml,binary,MTOM
             3、使用什么来保证信息的安全,即安全策略
      一个Binding包含着上述3方面信息,每种信息都描述了服务端和客户端交互过程中的一方面,如下表所示,Binding描述了这些层面的信息: 

层次

备注说明

Transactions(事务)

TransactionFlowBindingElement,用于指定事务流程

Reliability(信赖)

ReliableSessionBindingElement,用于指定对会话方式

Security(安全)

SecurityBindingElement,指定安全方式

Encoding(编码)

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

Transport(传输)

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

      基于WCF的通信,使用场景的不同,选择的通讯协议,编码方法,安全策略就不同,下面我们来看一下wcf支持的通讯协议。

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

      下面的图给出了我们选择Binding的方式

 


posted @ 2009-09-18 14:37  成都ABC  阅读(284)  评论(0编辑  收藏  举报