SOA Patterns with BizTalk Server 2009
上QQ阅读APP看书,第一时间看更新

The role of service bindings

The WCF service binding (or the B in the WCF endpoint ABCs) is the channel stack that ties up how a service actually transmits data across the wire. The stack is made up of individual elements that make up the message communication. This includes elements that control security options, session capacity, and transaction capabilities. They are also used to determine how a message is actually encoded during transmission, whether that is in text/XML, binary format, or the new MTOM (Message Transmission Optimization Mechanism) format.

WCF provides a series of bindings for the available WCF transports which offer the most compatible and logical component order for a given transport. Let's review the key bindings that are also available with BizTalk Server 2009 as adapters:

  • BasicHttpBinding: This binding works great for ASMX SOAP clients that only support the SOAP 1.1 Basic Profile. By default, there is no security aspect enabled, no session or transaction capabilities, and its default data encoding is plain text. This is your "safe bet" binding that is the most interoperable for clients that don't support the latest WS* web services standards.
  • WSHttpBinding: Like the BasicHttpBinding , this binding is for HTTP and HTTP/S traffic. This is a rich HTTP-based binding with full support for transactions, sessions, and a default message-based security scheme. With the WSHttpBinding , you have the choice of not only encoding the payload in plain text, but also the more compressed MTOM format.
  • NetTCPBinding: If you need fast, secure connectivity between WCF endpoints, then the NetTCPBinding is an excellent choice. Data is transferred over TCP in binary format while still getting full support for sessions, transactions, and the full range of security options.
  • NetNamedPipeBinding: If your client is communicating with a WCF service and both resides on the same physical server, then this is the binding for you. The NetNamedPipeBinding uses IPC (named pipes) to transport data in a binary encoding with a secure transmission channel.
  • NetMsmqBinding: This binding uses queuing technology that is ideal for disconnected applications. Data is transferred in a binary encoding with rich security options available, but no support for sessions. That makes sense because in a queue scenario, the publisher and subscriber are not aware of each other.

If the situation arises where none of the above set of bindings meet your needs, you can always craft a custom binding, which mixes and matches available binding elements to your liking. What if your service consumer can only send binary messages over HTTP? The out-of-the-box HTTP bindings don't support such an encoding, but we could configure a custom binding that matches this business requirement. Or what if you need a transmission protocol not offered in the standard WCF toolset? We'll see in Chapter 9 that the WCF SQL Server Adapter delivers a custom binding, which includes SQL Server communication as a valid service transport. Such control over the WCF channel stack is a key aspect of the framework's flexibility.

Note that there are additional bindings provided by WCF in the .NET Framework 3.5, which are not explicitly set up as BizTalk adapters. These include WSDualHttpBinding (for duplex communication between endpoints), WS2007FederationHttpBinding (which supports federated security scenarios), and NetPeerTcpBinding (for peer-to-peer networking).