tags:

views:

140

answers:

2

I need to maintain distributed transactions in my application

Assume Service1 is installed on Server1

[ServiceContract]
IService1
{
    [OperationContract]
    Operation1();
}

Service2 is installed on Server2

[ServiceContract]
IService2
{
    [OperationContract]
    Operation2();
}

and the client is consuming the two services

using (TransactionScope ts = new TransactionScope())
{
    Service1Proxy.Operation1();
    Service2Proxy.Operation2();
}

Where should i exactly install the MSDTC, do it required to be installed on Server1,Server2 and client

Is it requires any additional configuration in this case ?

A: 

I'd be careful about this setup. I've used "TransactionScope" to programmatically execute SQL commands that I want to run for testing purposes and then roll back, but I haven't tried to propogate "TransactionScope" through WCF calls.

A cursory Google search found this documentation on MSDN: http://msdn.microsoft.com/en-us/magazine/cc163432.aspx. This documentation says that you need special attributes on your Service interface to make your TransactionScope cross service boundaries.

As far as "installing" MSDTC, you do not install it. It should already be part of your Windows installation. However, MSDTC does not work with remote clients on the network by default; this setting is for security purposes. Here's a link showing how to enable MSDTC to work with remote clients in Windows Server 2003: http://support.microsoft.com/kb/817064. For other versions of Windows, try Googling for "MSDTC network access". I believe you'll need to set this configuration on each server hosting a service you want to include in a remote transaction.

WCF services can be very tricky to configure with all the different possible settings. I hope this helps you get started.

Rice Flour Cookies
A: 

You would have to enable MSDTC on your clients and server 1, server 2.

you should allow outbound in the security configuration of MSDTC on your client.
you should allow Inbound and Outbound on your servers.
if your DB is on a seperate machine, it should allow Inbound.

One issue that I ran to using MSDTC, is don't forget to ALLOW MSDTC in the list of exception of your FIREWALL.

Looking at your code snippet, you'll need to add the Transactionflow attribut on your operation interface also.

Here is a good link for WCF with transactions : Foundation: Transaction Propagation

pdiddy
Hi pididdy,thanks for responding to my query.i have set the transaflow setting in the configuration filetransactionFlow="true"is it ok, do i need to transactionflow attribute for each method in the service interface.
kumar
yes you need to put the attribut on each service operation. Read the article in my answer, it's really a good start.
pdiddy
Of course, you only put the attribut on operation that you need them to be transactional.
pdiddy