Note that there are some explanatory texts on larger screens.

plurals
  1. POWCF Transaction Flow not getting committed on success
    primarykey
    data
    text
    <p>I have been trying to implement the transaction flow in WCF. When I am executing My Client code I could see that the transaction is propagating to the Service from client as I see the record is locked in db(I used with(nolock) in SQL server to see if the transaction is happening). However my client code completes successfully, but the transaction is rolled back, Do I miss something here, </p> <p>following are the code snippets,</p> <p>Service class</p> <pre><code>[ServiceBehavior( TransactionIsolationLevel = System.Transactions.IsolationLevel.ReadCommitted, TransactionTimeout = "00:00:30")] public class TransactionTest : ITransactionTest { [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = false)] public void DoWork(string aliasName) { string constr = "Data Source=MyDBServer;User ID=DBUser;password=123;Initial Catalog=MyTestDB;"; using (SqlConnection objcon = new SqlConnection(constr)) { string qry = @"UPDATE Customer SET Alias = '" + aliasName + "' WHERE CustomerID = 10"; SqlCommand cmd = new SqlCommand(qry, objcon); objcon.Open(); cmd.ExecuteNonQuery(); } } </code></pre> <p>}</p> <pre><code> Service Contract: [ServiceContract(SessionMode = SessionMode.Required)] public interface ITransactionTest { [OperationContract, TransactionFlow(TransactionFlowOption.Allowed)] void DoWork(string aliasName); } </code></pre> <p>following is my Web.config</p> <pre><code>&lt;bindings&gt; &lt;wsHttpBinding&gt; &lt;binding name="wsHttpBinding_ITransactionTest" transactionFlow="true"/&gt; &lt;/wsHttpBinding&gt; &lt;/bindings&gt; </code></pre> <p>I have added a service reference in my client application (which is a console application)</p> <pre><code>class Program { static void Main(string[] args) { //updateCustomeAlias(); try { using (TransactionScope TranScope = new TransactionScope(TransactionScopeOption.RequiresNew)) { var proxy = new TransactionTestClient("WSHttpBinding_ITransactionTest"); proxy.DoWork("XYZ"); TranScope.Complete(); } } catch { //Exception handling. } } </code></pre> <p>Client application config </p> <pre><code> &lt;system.serviceModel&gt; &lt;bindings&gt; &lt;wsHttpBinding&gt; &lt;binding name="WSHttpBinding_ITransactionTest" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false"&gt; &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt; &lt;reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" /&gt; &lt;security mode="Message"&gt; &lt;transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /&gt; &lt;message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" /&gt; &lt;/security&gt; &lt;/binding&gt; &lt;/wsHttpBinding&gt; &lt;/bindings&gt; &lt;client&gt; &lt;endpoint address="http://localhost:91/TransactionTest.svc" binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_ITransactionTest" contract="TransactionTestService.ITransactionTest" name="WSHttpBinding_ITransactionTest"&gt; &lt;/endpoint&gt; &lt;/client&gt; &lt;/system.serviceModel&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload