How to make two WCF services in a transaction

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Dow

    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 (TransactionSco pe scope = new TransactionScop e())
    {
    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


  • Misbah Arefin

    #2
    Re: How to make two WCF services in a transaction

    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" <john@hotmail.c omwrote in message
    news:O6fOUgmaIH A.4140@TK2MSFTN GP04.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 (TransactionSco pe scope = new TransactionScop e())
    {
    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
    >
    >

    Comment

    • =?Utf-8?B?TWlzYmFoIEFyZWZpbg==?=

      #3
      Re: How to make two WCF services in a transaction

      try DependentTransa ction object

      The DependentTransa ction 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 DependentCloneO ption 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





      "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" <john@hotmail.c omwrote in message
      news:O6fOUgmaIH A.4140@TK2MSFTN GP04.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 (TransactionSco pe scope = new TransactionScop e())
      {
      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

      Comment

      Working...