不厚

博客园 首页 新随笔 联系 订阅 管理

一、BasicHttpBinding

BasicHttpBinding binding = new BasicHttpBinding();

1. System.ServiceModel.Channels.TextMessageEncodingBindingElement(基于文本的消息编码元素)
2. System.ServiceModel.Channels.HttpTransportBindingElement
(传输元素)

BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);

1. System.ServiceModel.Channels.TextMessageEncodingBindingElement
2. System.ServiceModel.Channels.HttpsTransportBindingElement
Https实现安全)

 

BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Message);

binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.Certificate;

1. System.ServiceModel.Channels.AsymmetricSecurityBindingElement(非对称加密,X509证书加密方式)
2. System.ServiceModel.Channels.TextMessageEncodingBindingElement
3. System.ServiceModel.Channels.HttpsTransportBindingElement

BasicHttpBinding binding = new BasicHttpBinding();

binding.MessageEncoding = WSMessageEncoding.Mtom;

1. System.ServiceModel.Channels.MtomMessageEncodingBindingElement(基于MTOM编码方式)
2. System.ServiceModel.Channels.HttpTransportBindingElement

 

提供对WS-BP 1.1的支持

 

WsHttpBinding

WsHttpBinding binding = new WsHttpBinding();

1.System.ServiceModel.Channels.TransactionFlowBindingElement(事务流,WS-Transactions规范)

2. System.ServiceModel.Channels.SymmetricSecurityBindingElement(对称加密实现安全认证)

3. System.ServiceModel.Channels.TextMessageEncodingBindingElement

4System.ServiceModel.Channels.HttpTransportBindingElement

 

WsHttpBinding binding = new WsHttpBinding(SecurityMode.Transport);

1. System.ServiceModel.Channels.TransactionFlowBindingElement

2. System.ServiceModel.Channels.TextMessageEncodingBindingElement

3System.ServiceModel.Channels.HttpsTransportBindingElement

WSHttpBinding binding = new WSHttpBinding(SecurityMode.Message, true); 第二个参数代表是否支持可靠会话

1System.ServiceModel.Channels.TransactionFlowBindingElement

2. System.ServiceModel.Channels.ReliableSessionBindingElementWS-RM(Reliable Messaging)实现消息传输的有效,有序)

3. System.ServiceModel.Channels.SymmetricSecurityBindingElement

4. System.ServiceModel.Channels.TextMessageEncodingBindingElement

5System.ServiceModel.Channels.HttpTransportBindingElement

BasicHttpBinding一样,WsHttpBinding定义了类型为System.ServiceModel.WSMessageEncoding枚举类型的MessageEncoding属性,有两种WSMessageEncoding枚举值供你选择:TextMTOM

WsHttpBinding对大部分的WS-*提供支持,这包括WS-TransactionsWS-SecurityWS-Reliable Messaging等等。所以从互操作角度讲,WsHttpBinding可以和满足这些标准的Web Service进行互操作。

 

WS-*新的协议提供很好的支持,比如WS-TransactionsWS-Reliable MessagingWS-Security

 

WsDualHttpBinding

WSDualHttpBinding binding = new WSDualHttpBinding();            ListAllBindingElements(binding);

1. System.ServiceModel.Channels.TransactionFlowBindingElementWS-T

2. System.ServiceModel.Channels.ReliableSessionBindingElement(WS-RM)

3. System.ServiceModel.Channels.SymmetricSecurityBindingElement(WS-Security)

4. System.ServiceModel.Channels.CompositeDuplexBindingElement(双工通信)

5. System.ServiceModel.Channels.OneWayBindingElement(单向)

6. System.ServiceModel.Channels.TextMessageEncodingBindingElement(Text 或者 MTOM)

7. System.ServiceModel.Channels.HttpTransportBindingElement()

WS-*新的协议提供很好的支持,比如WS-TransactionsWS-Reliable MessagingWS-Security

 

从对标准的支持看来,BasicHttpBinding提供对WS-BP 1.1的支持,WsHttpBindingWsDualHttpBinding则对WS-*新的协议提供很好的支持,比如WS-TransactionsWS-Reliable MessagingWS-Security等等;

从消息编码的角度来看,它们均支持基于纯文本的消息编码和MTOM编码。这些属性都决定了这三种绑定具有较好的互操作性,也就是说,对于此三种绑定的应用并不限于对于基于.NET平台应用的交互,如果通过这些绑定寄宿我们的服务,其他平台的客户端可以调用我们的服务,同理我们也可以利用基于这些绑定的客户端访问其他非.NET平台的Web服务,只要对方支持相应的标准。

 

NetTcpBinding

NetTcpBinding binding = new NetTcpBinding();

1. System.ServiceModel.Channels.TransactionFlowBindingElement

2. System.ServiceModel.Channels.BinaryMessageEncodingBindingElement(二进制消息编码)

3. System.ServiceModel.Channels. WindowsStreamSecurityBindingElementWindows凭证的传输安全,对应的有SslStreamSecurityBindingElement,需要客户端用Certificate验证)

4. System.ServiceModel.Channels.TcpTransportBindingElement(TCP作为传输协议)

 

NetTcpBinding binding = new NetTcpBinding();            binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate;

1. System.ServiceModel.Channels.TransactionFlowBindingElement

2. System.ServiceModel.Channels.BinaryMessageEncodingBindingElement

3. System.ServiceModel.Channels.SslStreamSecurityBindingElement

4. System.ServiceModel.Channels.TcpTransportBindingElement

 

NetTcpBinding binding = new NetTcpBinding(SecurityMode.Message);

1. System.ServiceModel.Channels.TransactionFlowBindingElement

2. System.ServiceModel.Channels.SymmetricSecurityBindingElement

3. System.ServiceModel.Channels.BinaryMessageEncodingBindingElement

4. System.ServiceModel.Channels.TcpTransportBindingElement

 

混合的安全模式,SslStreamSecurityBindingElementTransportSecurityBindingElement一起提供该模式的安全

NetTcpBinding binding = new NetTcpBinding(SecurityMode.TransportWithMessageCredential);

1. System.ServiceModel.Channels.TransactionFlowBindingElement

2. System.ServiceModel.Channels.TransportSecurityBindingElement

3. System.ServiceModel.Channels.BinaryMessageEncodingBindingElement

4. System.ServiceModel.Channels.SslStreamSecurityBindingElement

5. System.ServiceModel.Channels.TcpTransportBindingElement

 

WsHttpBinding一样,NetTcpBinding也提供对可靠会话的支持,以保障数据包或者消息的可靠、有序传递。不过与WsHttpBinding的实现机制不同的是,基于NetTcpBinding是采用TCP协议固有的可靠传输机制,比如消息确认机制、重发机制等等。

 

NetTcpBinding binding = new NetTcpBinding();

binding.ReliableSession.Enabled = true;

1. System.ServiceModel.Channels.TransactionFlowBindingElement

2. System.ServiceModel.Channels.ReliableSessionBindingElement

3. System.ServiceModel.Channels.BinaryMessageEncodingBindingElement

4. System.ServiceModel.Channels.WindowsStreamSecurityBindingElement

5. System.ServiceModel.Channels.TcpTransportBindingElement

由于NetTcpBinding采用TCP作为传输协议,所以它一般只应用于Intranet中;由于采用二进制的消息编码方式,在性能上较之基于文本的编码会有较大的提高;此外,由于和HTTP协议不同,TCP本身就是一个基于双工通信的协议,所以和WsDualBinding一样可以用于基于双工消息交换模式的WCF应用中。

 

NetNamedPipeBinding

NetNamedPipeBinding,顾名思义,就是基于命名管道传输的绑定。命名管道本身可以支持跨机器的通信,而在WCF中对NetNamedPipeBinding作了更加严格的限制,使其只能用于同一台机器的跨进程通信(IPC)。所以在所有的绑定中,NetNamedPipeBinding将是性能最好的绑定类型。

NetNamedPipeBinding binding = new NetNamedPipeBinding();

1. System.ServiceModel.Channels.TransactionFlowBindingElement

2. System.ServiceModel.Channels.BinaryMessageEncodingBindingElement

3. System.ServiceModel.Channels.WindowsStreamSecurityBindingElement

4. System.ServiceModel.Channels.NamedPipeTransportBindingElement

由于NetNamedPipeBinding的特殊性(提供基于IPC的通信),所以决定了它的一些相关的特性:仅仅支持传输模式的安全(实际上消息安全模式在IPC场景下已经没有意义);客户端凭证只限于Windows

 

NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);

1. System.ServiceModel.Channels.TransactionFlowBindingElement

2. System.ServiceModel.Channels.BinaryMessageEncodingBindingElement

3. System.ServiceModel.Channels.NamedPipeTransportBindingElement

posted on 2012-09-01 21:40  飞宏风  阅读(920)  评论(1编辑  收藏  举报