一个Binding由一个有序的binding元素栈所组成,其中的每一个元素都指定了连接到ServiceEndpoint的一个方面。在这个栈中的最底两层都是必须要有的。最底下的一层是传输binding元素,在它之上是用于指定编码规范的binding元素。
一个Binding中的元素可以分为三类:协议、传输与编码, 它们分别可以指定如下信息:
- 协议栈元素指定诸如安全性、可靠性、上下文流设置(context flow settins);
- 传输中指定底层的传输协议,如TCP或是HTTP。
- 编码中指定发送到ServiceEndpoint中的消息编码,如Text/XML, Binary或是MTOM。
WCF预定义了一些Binding,它们在互操作性(Interoperability), 安全性(Security), 是否支持会话(Session), 是否支持事务(Transactions)和是否为全双工(Duplex)上各有不同。
Binding | Configuration Element | Description |
---|---|---|
BasicHttpBinding | basicHttpBinding Element | A binding that is suitable for communicating with WS-Basic Profile conformant Web Services, for example, ASMX-based services. This binding uses HTTP as the transport and Text/XML as the default message encoding. |
WSHttpBinding | wsHttpBinding Element | A secure and interoperable binding that is suitable for non-duplex service contracts. |
WSDualHttpBinding | wsDualHttpBinding Element | A secure and interoperable binding that is suitable for duplex service contracts or communication through SOAP intermediaries. |
WSFederationHttpBinding | wsFederationHttpBinding element | A secure and interoperable binding that supports the WS-Federation protocol, enabling organizations that are in a federation to efficiently authenticate and authorize users. |
NetTcpBinding | netTcpBinding Element | A secure and optimized binding suitable for cross-machine communication between WCF applications. |
Net NamedPipeBinding | netNamedPipeBinding Element | A secure, reliable, optimized binding that is suitable for on-machine communication between WCF applications. |
NetMsmqBinding | netMsmqBinding Element | A queued binding that is suitable for cross-machine communication between WCF applications. |
NetPeerTcpBinding | netPeerTcpBinding element | A binding that enables secure, multi-machine communication. |
MsmqIntegrationBinding | msmqIntegrationBinding element | A binding that is suitable for cross-machine communication between an WCF application and existing MSMQ applications. |
Binding | Interoperability | Security (Default) | Session (Default) | 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 |