As we have seen, distributed transaction support of a WCF service depends on the binding of the service, the operation contract attribute, the operation implementation behavior, and the client applications.
The following table shows some possible combinations of the WCF-distributed transaction support:
Binding permits transaction flow | Client flows transaction | Service contract opts in transaction | Service operation requires transaction scope | Possible result |
True | Yes | Allowed or Mandatory | True | Service executes under the flowed in transaction |
True or False | No | Allowed | True | Service creates and executes within a new transaction |
True | Yes or No | Allowed | False | Service executes without a transaction |
True or False | No | Mandatory | True or False | SOAP exception |
True | Yes | NotAllowed | True or False | SOAP exception |
Now that we have changed the service to support distributed transaction and let the client propagate the transaction to the service, we will test this. We will propagate a transaction from the client to the service, test the multiple database support of the WCF service, and discuss the Distributed Transaction Coordinator and Firewall settings for the distributed transaction support of the WCF service.
In a subsequent section, we will call two services to update two databases on two different computers. As these two updates are wrapped within one distributed transaction, Microsoft Distributed Transaction Coordinator (MSDTC) will be activated to manage this distributed transaction. If MSDTC is not started or configured properly the distributed transaction will not be successful. In this section, we will explain how to configure MSDTC on both machines.
You can follow these steps to configure MSDTC on your local and remote machines:
You have to restart the MSDTC service after you have changed your MSDTC settings, for the changes to take effect.Also, to simplify our example, we have chosen the No Authentication Required option. You should be aware that not needing authentication is a serious security issue in production. For more information about WCF security, you can go to the MSDN WCF security website at this address:MSDN Library.
Even though Distributed Transaction Coordinator has been enabled the distributed transaction may still fail if the firewall is turned on and hasn’t been set up properly for MSDTC.
To set up the firewall for MSTC, follow these steps:
Now the firewall will allow msdtc.exe to go through so our next test won’t fail due to the firewall restrictions.
You may have to restart IIS after you have changed your firewall settings. In some cases you may also have to stop and then restart your fi rewall for the changes to take effect.
I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…
Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…
Once we learn how to deploy an Ubuntu server, how to manage users, and how…
Key-takeaways: Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…
While developing a web application, or setting dynamic pages and meta tags we need to deal with…
Software architecture is one of the most discussed topics in the software industry today, and…