Transaction Propagation

WCF can propagate transactions across the service boundary. This enables a service to participate in the client’s transaction, and for the client to include operations on multiple services in the same transaction. The client itself may or may not be a WCF service. Both the binding and the operation contract configuration control the decision whether or not the client transaction is propagated to the service. I call a transaction-aware binding any binding that is capable of propagating the client’s transaction to the service if configured to do so. Not all bindings are transaction-aware; only the TCP-, IPC- and WS-related bindings are transaction-aware (those would be the NetTcpBinding, the NetNamedPipeBinding, the WSHttpBinding, the WSDualHttpBinding and the WSFederationHttpBinding, respectively).

Transaction Flow and Binding

By default, transaction-aware bindings do not propagate transactions. The reason is that like most everything else in WCF, it is an opt-in setting. The service host or administrator has to explicitly give its consent to accepting incoming transactions, potentially from across the organization or the business boundaries. To propagate a transaction, you must explicitly enable it at the binding on both the service host and the client sides. All transaction-aware bindings offer the Boolean property TransactionFlow, such as:

public class NetTcpBinding : Binding,...
{
   public bool TransactionFlow
   {get;set;}
   //More members
}

TransactionFlow ...

Get Programming WCF Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.