469,573 Members | 1,668 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,573 developers. It's quick & easy.

How to make two WCF services in a transaction

I am new to WCF, so please point me to the right direction.

I created 2 WCF serivces, each one uses a difference database connection in
the back end.
Now from the client application, I need to keep two methods call to the
service in one transaction.
using (TransactionScope scope = new TransactionScope())
{
using (Proxy1 proxy = new Proxy1())
{
proxy.Method1();
}
using (Proxy2 proxy = new Proxy2())
{
proxy.Method2();
}
scope.Complete();
}

Above code does not work. If there is exception in Method2, Method1 still
commit.

What will be the right way to make transcation across multiple WCF services?
Thanks
Feb 8 '08 #1
2 1725
one solution (although not using transactions) would be to check the return
value from each method and proceed to the next only if the previous returned
true and commit only if both/all return true

--
Misbah Arefin
"John Dow" <jo**@hotmail.comwrote in message
news:O6**************@TK2MSFTNGP04.phx.gbl...
I am new to WCF, so please point me to the right direction.

I created 2 WCF serivces, each one uses a difference database connection
in the back end.
Now from the client application, I need to keep two methods call to the
service in one transaction.
using (TransactionScope scope = new TransactionScope())
{
using (Proxy1 proxy = new Proxy1())
{
proxy.Method1();
}
using (Proxy2 proxy = new Proxy2())
{
proxy.Method2();
}
scope.Complete();
}

Above code does not work. If there is exception in Method2, Method1 still
commit.

What will be the right way to make transcation across multiple WCF
services? Thanks

Feb 13 '08 #2
try DependentTransaction object

The DependentTransaction is a clone of a Transaction object created using
the DependentClone method. Its sole purpose is to allow the application to
come to rest and guarantee that the transaction cannot commit while work is
still being performed on the transaction (for example, on a worker thread).

When the work done within the cloned transaction is finally complete and
ready to be committed, it can inform the creator of the transaction using the
Complete method. Thus you can preserve the consistency and correctness of
data.

The DependentCloneOption enumeration is used to determine the behavior on
commit. This behavior control allows an application to come to rest, as well
as provides concurrency support.

--
Misbah Arefin

https://mcp.support.microsoft.com/profile/MISBAH.AREFIN
http://www.linkedin.com/in/misbaharefin
"Misbah Arefin" wrote:
one solution (although not using transactions) would be to check the return
value from each method and proceed to the next only if the previous returned
true and commit only if both/all return true

--
Misbah Arefin
"John Dow" <jo**@hotmail.comwrote in message
news:O6**************@TK2MSFTNGP04.phx.gbl...
I am new to WCF, so please point me to the right direction.

I created 2 WCF serivces, each one uses a difference database connection
in the back end.
Now from the client application, I need to keep two methods call to the
service in one transaction.
using (TransactionScope scope = new TransactionScope())
{
using (Proxy1 proxy = new Proxy1())
{
proxy.Method1();
}
using (Proxy2 proxy = new Proxy2())
{
proxy.Method2();
}
scope.Complete();
}

Above code does not work. If there is exception in Method2, Method1 still
commit.

What will be the right way to make transcation across multiple WCF
services? Thanks
Feb 25 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.