Reader Level:
ARTICLE

WCF Service FAQs - Part 4

Posted by Imran Ghani Articles | WCF with C# December 10, 2012
This WCF Service Tutorial is Part 4 in a series of WCF Service FAQs.
  • 1
  • 0
  • 5486

Before reading these please go through the following articles in this series:

  1. WCF Service FAQs - Part 1
  2. WCF Service FAQs - Part 2
  3. WCF Service FAQs - Part 3

This WCF Service Tutorial is Part 4 in a series of WCF Service FAQs.

What is Service Oriented Architecture (SOA) and how does WCF support it?

SOA is basically an architectural model that dictates a few principles for building business applications in the form of independent, loosely coupled and interoperable services. These services are well defined, self-contained and can work together to achieve certain business functionality without depending on context or state of other services.

WCF supports nearly all principles dictated by the Service Oriented Architecture for developing services; those are also independent, loosely coupled and interoperable. Please visit for detailed discussion on WCF and SOA.

What is ESB in SOA environment?

In a Service Oriented Architecture environment, an Enterprise Service Bus (ESB) acts as a single interface for all messaging among applications and services in a loosely coupled manner. ESB is capable of calling and subscribing to various service provider's methods and subscriptions respectively.

What is Transaction Propagation? And how WCF support it?

Transaction propagation is the ability to propagate a transaction across the boundaries of a single service. Or in other words, we can say that a service can participate in a transaction that is initiated by a client.

In a SOA environment, transaction propagation becomes a key requirement. As we know, WCF supports SOA, so it provides support for transaction propagation as well.

To enable transaction propagation, we need to set the value of the TransactionFlow property of the binding being used. This can be done programmatically as follows:

WSHttpBinding bindingBeingUsed = new WSHttpBinding();
bindingBeingUsed.TransactionFlow = "true";

Or it can be done decoratively by updating the configuration file as follows:

      <bindings>
         <wsHttpBinding>
                <binding name="binding1"
                     transactionFlow="true" />
         </wsHttpBinding>
      </bindings>

The default value for the TransactionFlow property is "False".

Do all WCF bindings support Transaction Propagation?

No. Not all WCF bindings support transaction propagation. Only the following list of bindings support it:

  • wsHttpBinding

  • netTcpBinding

  • netNamedPipeBinding

  • wsDualHttpBinding

  • wsFederationHttpBinding

What are the various Transaction Flow Options available in WCF?

If a service is configured for Transaction Propagation, WCF further supports various options for service methods to be part of any transaction initiated outside service boundaries. They are:

  • NotAllowed Transaction: Propagation is not allowed for the particular service method. It's the default value.

  • Allowed Transaction: Propagation is allowed but not compulsory.

  • Mandatory Transaction: Propagation is compulsory for that service method.

For example, Transaction Propagation is mandatory for a CreditAccount service method in the following code snippet:

        [ServiceContract]
        interface IPaymentService
       {
               [OperationContract]
               [TransactionFlow(TransactionFlowOption.Mandatory)]
               void CreditAccount(….);
        }

What is a two-phase committed protocol?

In a distributed transaction scenario, a two-phase committed protocol is an algorithm that ensures all the participating processes in a distributed transaction are ready to be committed or rolled backed. This is done in two phases i.e. Prepare Phase and Commit Phase.

What is the role of transaction manager in WCF?

The Transaction Manager, while sitting on the client side, initiates the transaction and coordinates with all the processes that participate in a distributed transaction to commit or roll back.

What are the supported transaction types in WCF?

Supported transaction types in WCF are:

  • Lightweight

  • OLE Transactions

  • WS-Atomic Transactions

How to enable the Performance Counters in WCF?

A simple way to enable Performance Counters supported by WCF is as follows:

        <system.serviceModel>
                <diagnostics performanceCounters = "All" />
        </system.serviceModel>

Those configuration settings will enable all categories of counters including ServiceModelService, ServiceModelEndpoint and ServiceModelOperation. The default value for it is "Off".

COMMENT USING

Trending up