Chapter 13. Distributed Transaction Support of WCF

In the chapters so far, we have created a WCF service using LINQ to SQL in the data access layer. Next, we will apply some settings so that this WCF service will be a distributed service, which means that it can participate in distributed client transactions, if there are any. Client applications will control the transaction scope and decide whether a service should commit or rollback its transaction.

In this chapter, we will first verify that the LINQNorthwind WCF service that we built in the previous chapter does not support distributed transaction processing. We will then explain how to enhance this WCF service to support distributed transaction processing, and how to configure all related computers to enable distributed transaction support. As a proof, we will propagate a transaction from the client to the WCF service, and verify that all sequential calls to the WCF service are within one single distributed transaction. We will also explain the multiple database support of the WCF service, and discuss how to configure MSDTC and the firewall for the distributed WCF service.

We will cover the following topics in this chapter:

  • Creating the solution files
  • Testing the transaction behavior of the LINQNorthwind WCF service
  • Enabling transaction flow in the service bindings
  • Modifying the service operation contract to allow transaction flow
  • Modifying the service operation implementation to require a transaction scope
  • Propagating a transaction from the client to the WCF service
  • Testing the multiple database support of the distributed WCF service
  • Configuring the Distributed Transaction Coordinator for the distributed WCF service
  • Configuring the firewall for the distributed WCF service

Creating the DistNorthwind solution

In this chapter, we will create a new solution based on the LINQNorthwind solution. We will copy all of the source code from the LINQNorthwind directory to a new directory, and then customize it to suit our needs.

Follow these steps to create the new solution:

  1. Create a new directory named DistNorthwind under the existing D:SOAwithWCFandLINQProjects directory.
  2. Copy all of files under the D:SOAwithWCFandLINQProjectsLINQNorthwind directory to the D:SOAwithWCFandLINQProjectsDistNorthwind directory.
  3. Start Visual Studio 2008.
  4. Open the solution LINQNorthwind under the DistNorthwind directory.
  5. In the Solution Explorer, rename the solution to DistNorthwind. We will leave all of other files as LINQ-something, but renaming the solution is necessary, otherwise we may get confused as to which solution we are working on.
  6. Rebuild the DistNorthwind solution.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset