{"id":369,"date":"2013-11-12T15:32:06","date_gmt":"2013-11-12T15:32:06","guid":{"rendered":"https:\/\/praveenkatiyar.wordpress.com\/?p=369"},"modified":"2013-11-12T15:32:06","modified_gmt":"2013-11-12T15:32:06","slug":"understanding-transactions-in-wcf","status":"publish","type":"post","link":"https:\/\/praveenkatiyar.in\/blog\/index.php\/2013\/11\/12\/understanding-transactions-in-wcf\/","title":{"rendered":"Understanding Transactions in WCF"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>A Transaction is a <strong>set of complex operations<\/strong>, where <strong>failure of any single operation causes entire set to fail<\/strong>. A <strong>successful transaction<\/strong>, that <strong>transfers the system from one consistent state (A) to another consistent state (B)<\/strong>, called a committed transaction.<\/p>\n<p align=\"center\">&#160;<\/p>\n<p><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/transactionblock5.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"TransactionBlock[5]\" style=\"background-image:none;float:none;padding-top:0;padding-left:0;margin-left:auto;display:block;padding-right:0;margin-right:auto;border-width:0;\" border=\"0\" alt=\"TransactionBlock[5]\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/transactionblock5_thumb.jpg\" width=\"403\" height=\"130\" \/><\/a><\/p>\n<h3>Transaction Properties<\/h3>\n<p>When you write <strong>a transactional service<\/strong>, one <strong>must abide by four core properties<\/strong>, known as <strong>ACID (atomic, consistent, isolated, and durable)<\/strong>, and <b>they are not optional.<\/b><\/p>\n<ol>\n<li><strong>Atomic : <\/strong>To qualify as atomic, when a transaction completes. all individual operations must be made, as if they were one indivisible operation. <\/li>\n<li><strong>Consistent:&#160; <\/strong>any transaction must leave the system in consistent state (that makes sense), so transaction is required to transfer the system from one consistent state to another. <\/li>\n<li><strong>Isolated : <\/strong>No other entity (transactional or not) is able to see the intermediate state of the resources, for obvious reasons (as they may be inconsistent). <\/li>\n<li><strong>Durable :<\/strong> For a transaction to be durable, it must maintain its committed state, even if there is a failure (power outage, hardware failure).&#160; The transaction must survive, regardless of the type of failure. <\/li>\n<\/ol>\n<h3>Transaction Propagation<\/h3>\n<p>In WCF, transaction can be propagated across service boundary. This enables <strong>service to participate in a client transaction<\/strong> and it also allows client, to include operations on multiple services in a sme transaction. By default, transaction aware bindings do not propagate transactions. You can specify whether or not client transaction is propagated to service by changing Binding and operational contract configuration. as shown below.<\/p>\n<pre>   <font color=\"#0000ff\"> &lt;bindings &gt; \n     &lt;wsHttpBinding &gt; \n        &lt;binding name =&quot;MandatoryTransBinding&quot; transactionFlow =&quot;true&quot;&gt; \n              &lt;reliableSession enabled =&quot;true&quot;\/&gt; \n        &lt;\/binding&gt; \n     &lt;\/wsHttpBinding&gt; \n   &lt;\/bindings&gt;<\/font><\/pre>\n<h4>Note:<\/h4>\n<p>by default transaction does not require reliable messaging, how ever enabling reliability will decrease the likelihood of aborted transactions, means that the transactions will be less likely to abort due to communication problems. <\/p>\n<p>Just enabling <strong>transactionFlow<\/strong>, will not be sufficient to state, that a service wants to use client&#8217;s transaction in its each operation. You need to specify the \u201c<strong>TransactionFlowAttribute&quot; <\/strong>attribute in each <strong>operation contract<\/strong>, to enable transaction flow, as shown below.<\/p>\n<pre>  <font color=\"#0000ff\">[OperationContract] \n  [TransactionFlow(<strong>TransactionFlowOption.Mandatory<\/strong>)] \n  [FaultContract(typeof(CuboidFaultException))] \n  void AddTM(int nID, double dblL, double dblW, double dblH);\n<\/font>or<\/pre>\n<pre><font color=\"#0000ff\">  [OperationContract] \n  [TransactionFlow(<strong>TransactionFlowOption.Allowed<\/strong>)] \n  [FaultContract(typeof(CuboidFaultException))] \n  void AddTM(int nID, double dblL, double dblW, double dblH);\n<\/font><\/pre>\n<p>the values for the <strong>TransactionFlowOption<\/strong> property come from TransactionFlowOption enumeration as shown below.<\/p>\n<ul>\n<li><strong>Allowed<\/strong> : Transaction Flow <strong>may<\/strong> <strong>be<\/strong> flowed, (Client may or may not create a transaction, to be flowed for this operation.) <\/li>\n<li><strong>Mandatory<\/strong> : Transaction Flow <strong>must<\/strong> <strong>be<\/strong> flowed, (Client must create a transaction to be flowed, for this operation.) <\/li>\n<li><strong>NotAllowed<\/strong> : Transaction Flow <strong>Can not<\/strong> <strong>be<\/strong> flowed. , (Transaction can not be flowed, for this operation.) <\/li>\n<\/ul>\n<h4>Creating WCF Transaction<\/h4>\n<p>Once the interface has been defined with the proper TransactionFlow attribute, we need to create the service class which implements the service contract and set the operation behavior stating that operation needs a transaction, with <strong>TransactionScopeRequired = true<\/strong>.&#160; This attribute <strong>enables the service transaction<\/strong>, if the client&#8217;s (propagated) transaction is not available. <\/p>\n<pre>    <font color=\"#0000ff\">public class CuboidService:ICuboidService\n    {\n        [OperationBehavior(<strong>TransactionScopeRequired = true<\/strong>, <strong>TransactionAutoComplete<\/strong> = true)] \n        public void AddTM(int nID, double dblL, double dblW, double dblH) \n        {\n            . . . \n        }\n    }<\/font><\/pre>\n<p>another important attribute <strong>TransactionAutoComplete<\/strong>, specifies whether to commit the current transaction automatically. If set true, and no unhandled exceptions are found, the current transaction is automatically committed. the default value for this property is true.<\/p>\n<p><font color=\"#0000ff\"><\/font><\/p>\n<p><font color=\"#0000ff\"><\/font><\/p>\n<h3>Transaction Propagation<\/h3>\n<p>In WCF, transaction can be propagated across service boundary. This enables <strong>service to participate in a client transaction<\/strong> and it allows client to include operations on multiple services in same transaction.&#160; By default, transaction aware bindings do not propagate transactions. You can specify whether or not client transaction is propagated to service by changing Binding and operational contract configuration. as shown below.<\/p>\n<p><font color=\"#0000ff\">&lt;bindings &gt;<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160; &lt;wsHttpBinding &gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;binding name =&quot;MandatoryTransBinding&quot; <strong>transactionFlow<\/strong> =&quot;true&quot; &gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;reliableSession enabled =&quot;true&quot;\/&gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;\/binding&gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160; &lt;\/wsHttpBinding&gt; <\/p>\n<p>&#160;&#160;&#160; &lt;\/bindings&gt;<\/font><\/p>\n<h4>Note:<\/h4>\n<p>by default transaction does not require reliable messaging, how ever enabling reliability will decrease the likelihood of aborted transactions, means that the transactions will be less likely to abort due to communication problems.<\/p>\n<h2>Background<\/h2>\n<p>In this article, i have taken a Cuboid as an example, Cuboid is a rectangular shaped cube, which has 3 dimensions (length, width and height). <\/p>\n<p>for the database, there are two tables, one is called <strong>CuboidInfo<\/strong>, which simply contains the dimensions of the said cuboid, every cuboid is identified by its ID (primary key). The schema of <strong>CuboidInfo<\/strong> table is shown below.<\/p>\n<p><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/cuboidinfotable.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"cuboidInfoTable\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"cuboidInfoTable\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/cuboidinfotable_thumb.jpg\" width=\"484\" height=\"124\" \/><\/a><\/p>\n<p>the other table is called CuboidDetail, which contains the Volume and Surface Area of the said Cuboid (identified by its ID). The schema of CuboidDetail table is shown below.<\/p>\n<p><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/cuboiddetailtable.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"cuboidDetailTable\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"cuboidDetailTable\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/cuboiddetailtable_thumb.jpg\" width=\"487\" height=\"94\" \/><\/a><\/p>\n<p>So, our service demonstrates the transaction in following ways.<\/p>\n<ul>\n<li>when you add a new cuboid to the database, its information is added to the <strong>CuboidInfo<\/strong> table, and its volume and surface area must be added to the <strong>CuboidDetail<\/strong> table. <\/li>\n<li>when you update an existing cuboid in the database, its information is updated in the <strong>CuboidInfo<\/strong> table, and its volume and surface area must be updated, to the <strong>CuboidDetail<\/strong> table. <\/li>\n<li>when you delete an existing cuboid from&#160; the database, its information is deleted from <strong>CuboidInfo<\/strong> table, and its details must be deleted from the <strong>CuboidDetail<\/strong> table too. <\/li>\n<\/ul>\n<h2>Using the code<\/h2>\n<p>This article has been divided into 3 modules: <\/p>\n<ul>\n<li><strong>WCF Service Library (<em>TransactionLib.dll<\/em>)<\/strong>: Service logic, which defines a Service Contract Interface, <code>OperationContract<\/code>, and implements them, and exposes few functions to the world to use them, and also implements transaction infrastructure. <\/li>\n<li><strong>Windows Form based Application to host the WCF Service Library TransactionLibHost.exe<\/strong>): Host the WCF library <\/li>\n<li><strong><strong>Windows Form based Application <\/strong>(<em>TransactionClient.exe<\/em>):<\/strong> Client Application which will use this service <\/li>\n<\/ul>\n<h3>First Module: WCF Service Library (<em>TransactionLib<\/em>.<em>dll<\/em>) <\/h3>\n<p>To create this project, you can simply take a &quot;<strong>Class Library&quot; <\/strong>project, while choosing from project wizard option. let&#8217;s name it &quot;<code><strong>TransactionLib<\/strong><\/code>&quot;, it is the actual service which implements the business logic. The project already contains a file <em>Class1.cs<\/em>, let us do some house keeping, before we write any code for the service library&#160;&#160; <\/p>\n<h4>Little House Keeping<\/h4>\n<ul>\n<li>Delete the file<strong> <\/strong><em>Class1.cs<\/em> from the project workspace. <\/li>\n<li>Add a new <strong>Interface<\/strong> named <strong>ICuboidService <\/strong>to the project, a new file <strong>ICuboidService.cs<\/strong> will be added to the project. <\/li>\n<li>Add a new <strong>Class<\/strong> named <strong>CuboidService<\/strong>, to the project. that will implement the <strong><code>ICuboidService<\/code>&#160;<\/strong>interface, a new file <strong>CuboidService<em>.cs<\/em><\/strong> will be added to the project. <\/li>\n<\/ul>\n<h4>Defining ICuboidService Interface (ICuboidService.cs).<\/h4>\n<p>ICuboidService interface has seven methods, out of which<\/p>\n<ul>\n<li>two methods with mandatory transactions as shown below. <\/li>\n<\/ul>\n<p><font color=\"#0000ff\"><font face=\"Verdana\">void <strong>AddTM<\/strong>(int nID, double dblL, double dblW, double dblH); <\/font><\/font><\/p>\n<p><font color=\"#0000ff\"><font face=\"Verdana\">&#160;&#160; void <strong>UpdateTM<\/strong>(int nID, double dblL, double dblW, double dblH); <\/p>\n<p><\/font><\/font><\/p>\n<p><font color=\"#0000ff\"><font face=\"Verdana\">void <strong>DeleteTM<\/strong>(int nID);<\/font> <\/p>\n<p><\/font><\/p>\n<p>notice that, each method has been decorated with <\/p>\n<p><font color=\"#0000ff\"><font face=\"Verdana\">[TransactionFlow(TransactionFlowOption.Mandatory)]<\/font> <\/font><\/p>\n<p><strong>mandates<\/strong> the transaction flow, from the client. that says, that client <strong>must create a transaction <\/strong>and propagate its transaction to the service, before executing these methods. if these methods are called without transaction, <strong>an exception is generated<\/strong>. <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">[FaultContract(typeof(CuboidFaultException))]<\/font><\/p>\n<p>implements a <strong>FaultContract<\/strong>, which raises <strong>CuboidFaultException<\/strong>, if there is something not the way, as it supposed to be.&#160; <\/p>\n<ul>\n<li>the next two methods with allowed transactions as shown below. <\/li>\n<\/ul>\n<p><font color=\"#0000ff\"><font face=\"Verdana\">void <strong>AddTA<\/strong>(int nID, double dblL, double dblW, double dblH); <\/font><\/font><\/p>\n<p><font color=\"#0000ff\"><font face=\"Verdana\">&#160;&#160; void <strong>UpdateTA<\/strong>(int nID, double dblL, double dblW, double dblH); <\/p>\n<p><\/font><\/font><\/p>\n<p><font color=\"#0000ff\"><font face=\"Verdana\">void <strong>DeleteTA<\/strong>(int nID);<\/font> <\/p>\n<p><\/font><\/p>\n<p>notice that, each method has been decorated with <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">[TransactionFlow(TransactionFlowOption.Allowed)] <\/font><\/p>\n<p>that says, that client <strong>may create a transaction<\/strong> and propagate its transaction, to the service, before executing these methods. if client does not create a transaction,&#160; and&#160; method implementation is marked with, <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">[OperationBehavior(TransactionScopeRequired = true)]<\/font><\/p>\n<p>then service itself will create a transaction scope, to execute its method. <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">[FaultContract(typeof(CuboidFaultException))]<\/font><\/p>\n<p>implements a <strong>FaultContract<\/strong>, which raises <strong>CuboidFaultException<\/strong>, if there is something not the way, as it supposed to be.&#160; <\/p>\n<ul>\n<li>the last method simply implements a fault contract, and does not mention anything about transaction, that means this method can be executed without any transaction overhead. <\/li>\n<\/ul>\n<p><font color=\"#0000ff\" face=\"Verdana\">[OperationContract]<br \/>\n    <br \/>[FaultContract(typeof(CuboidFaultException))] <\/p>\n<p>Dictionary&lt;int, CuboidData&gt; GetList();<\/font><\/p>\n<h4>Implement ICuboidService Interface (CuboidService.cs).<\/h4>\n<p>CuboidService class implements the ICuboidService interface, as shown below. Service has been decorated with some attributes.<\/p>\n<p><font color=\"#0000ff\"><font face=\"Verdana\">[ServiceBehavior(TransactionIsolationLevel = System.Transactions.IsolationLevel.Serializable)]<br \/>\n      <br \/>public class CuboidService : ICuboidService <\/p>\n<p>{<\/font> <\/p>\n<p><\/font>The <strong>isolation level <\/strong>of a transaction determines what level of access other transactions have to volatile data before a transaction completes.&#160; The data affected by a transaction is called volatile. When you create a transaction, you can specify the isolation level that applies to the transaction. The isolation level of a transaction determines what level of access other transactions have to volatile data before a transaction completes. The highest isolation level, <strong>Serializable<\/strong>, provides a high degree of protection against interruptive transactions, but requires that each transaction complete before any other transactions are allowed to operate on the data. <\/p>\n<h5>Method AddTM ( int nID, double dblL, double dblW, double dblH)<\/h5>\n<p><strong>AddTM<\/strong> is used to Add data to the table, passed cuboid information its information is added to the <strong>CuboidInfo<\/strong> table, and its volume and surface area is calculated and added to the <strong>CuboidDetail<\/strong> table. <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]<br \/>\n    <br \/>public void AddTM(int nID, double dblL, double dblW, double dblH) <\/p>\n<p>{<\/font><\/p>\n<p>Operations are decorated with <\/p>\n<p><font color=\"#0000ff\"><strong>TransactionScopeRequired = true<\/strong>,<\/font> that simply says that this operation <strong>requires a TransactionScope<\/strong>, if client does not propagate its transaction, transaction is created at the service level itself.<\/p>\n<p><strong><font color=\"#0000ff\">TransactionAutoComplete = true<\/font><\/strong> signifies, to complete the transaction scope automatically on successful execution of the operation; <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">if ((nID &lt;= 0) || (dblL &lt;= 0) || (dblW &lt;= 0) || (dblH &lt;= 0))<br \/>\n    <br \/>{ <\/p>\n<p>&#160;&#160;&#160; CuboidFaultException faultEx = new CuboidFaultException(); <\/p>\n<p>&#160;&#160;&#160; faultEx.Reason = &quot;Any dimension of Cuboid (length\/width\/height) can not be zero or negative value&quot;; <\/p>\n<p>&#160;&#160;&#160; faultEx.Source = &quot;AddUpdateTM&quot;; <\/p>\n<p>&#160;&#160;&#160; StringBuilder sbDetail = new StringBuilder(&quot;&quot;); <\/p>\n<p>&#160;&#160;&#160; if (nID &lt;= 0) sbDetail.Append(&quot;[ID is &lt;= 0] &quot;); <\/p>\n<p>&#160;&#160;&#160; if (dblL &lt;= 0) sbDetail.Append(&quot;[Length is &lt;= 0] &quot;); <\/p>\n<p>&#160;&#160;&#160; if (dblW &lt;= 0) sbDetail.Append(&quot;[Width is &lt;= 0] &quot;); <\/p>\n<p>&#160;&#160;&#160; if (dblW &lt;= 0) sbDetail.Append(&quot;[Height is &lt;= 0]&quot;); <\/p>\n<p>&#160;&#160;&#160; faultEx.Detail = sbDetail.ToString(); <\/p>\n<p>&#160;&#160;&#160; throw new FaultException&lt;CuboidFaultException&gt;(faultEx); <\/p>\n<p>} <\/p>\n<p><\/font>then method checks the passed parameters, in case they are zero or negative a <strong>FaultException<\/strong> is thrown. if the input parameters are permissible, then usual business logic proceeds, that includes.<\/p>\n<ul>\n<li>calculating the values to be added\/updated in CuboidDetail table. <\/li>\n<\/ul>\n<p><font color=\"#0000ff\" face=\"Verdana\">double dblVolume = (dblL * dblW * dblH);<br \/>\n    <br \/>double dblSArea = 2 * ((dblL * dblW) + (dblW * dblH) + (dblL * dblH));<\/font>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/p>\n<ul>\n<li>preparing appropriate query to be run on database, for both the tables, according to the method called (add\/update). <\/li>\n<\/ul>\n<p><font color=\"#0000ff\" size=\"1\" face=\"Verdana\">&#160;&#160;&#160; <strong>strQuery1 <\/strong>= &quot;INSERT INTO CuboidInfo (ID, Length, Width, Height ) VALUES (&quot; + nID.ToString() + &quot;, &quot; + dblL.ToString(&quot;F2&quot;) + &quot;, &quot; + dblW.ToString(&quot;F2&quot;) + &quot;, &quot; + dblH.ToString(&quot;F2&quot;) + &quot; )&quot;; <\/p>\n<p>&#160;&#160;&#160; <strong>strQuery2 <\/strong>= &quot;INSERT INTO CuboidDetail (ID, SurfaceArea, Volume) VALUES (&quot; + nID.ToString() + &quot;, &quot; + dblSArea.ToString(&quot;F2&quot;) + &quot;, &quot; + dblVolume.ToString(&quot;F2&quot;) + &quot; )&quot;;<\/font><\/p>\n<ul>\n<li>Reading Connection string from the App.config file of the host application. <\/li>\n<\/ul>\n<p><font color=\"#0000ff\" size=\"2\" face=\"Verdana\">\/\/ Get the all keys from the appSettings section from the configuration file.<br \/>\n    <br \/>System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); <\/p>\n<p>AppSettingsSection appSettings = (AppSettingsSection)config.GetSection(&quot;appSettings&quot;); <\/p>\n<p>string[] keys = appSettings.Settings.AllKeys;<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\"><font size=\"2\">\/\/ Get the connection string.<br \/>\n      <br \/>string strConnStr = appSettings.Settings[&quot;ConnectionString&quot;].Value;<\/font><\/font><\/p>\n<ul>\n<li>Now the business logic, open Connection, execute both the queries, if there is any error throw a fault exception encapsulating error information. <\/li>\n<\/ul>\n<p><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/>{ <\/p>\n<p>&#160;&#160;&#160;&#160; \/\/&#160; Open Connection <\/p>\n<p>&#160;&#160;&#160;&#160; dbConn = new SqlConnection(strConnStr); <\/p>\n<p>&#160;&#160;&#160;&#160; dbConn.Open();<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160; \/\/&#160; Create Command for Query 1<br \/>\n    <br \/>&#160;&#160;&#160;&#160; SqlCommand dbCmd1 = new SqlCommand(strQuery1, dbConn); <\/p>\n<p>&#160;&#160;&#160;&#160; nCnt1 = dbCmd1.ExecuteNonQuery();<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160; \/\/&#160; Create Command for Query 2<br \/>\n    <br \/>&#160;&#160;&#160;&#160; SqlCommand dbCmd2 = new SqlCommand(strQuery2, dbConn); <\/p>\n<p>&#160;&#160;&#160;&#160; nCnt2 = dbCmd2.ExecuteNonQuery();<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\"><strong>&#160;&#160;&#160;&#160; \/\/&#160; If TransactionAutoComplete=false, you need the line below.<br \/>\n      <br \/><\/strong>&#160;&#160;&#160;&#160; \/\/&#160; OperationContext.Current.SetTransactionComplete(); <\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160; \/\/&#160; Close Connection.<br \/>\n    <br \/>&#160;&#160;&#160;&#160; dbConn.Close(); <\/p>\n<p>&#160;&#160;&#160;&#160; dbConn = null; <\/p>\n<p>}<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">catch (Exception eX)<br \/>\n    <br \/>{ <\/p>\n<p>&#160;&#160;&#160;&#160; \/\/&#160; Close Connection. <\/p>\n<p>&#160;&#160;&#160;&#160; if (dbConn != null) <\/p>\n<p>&#160;&#160;&#160;&#160; { <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (dbConn.State == ConnectionState.Open) dbConn.Close(); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; dbConn = null; <\/p>\n<p>&#160;&#160;&#160;&#160; }<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160; CuboidFaultException faultEx = new CuboidFaultException();<br \/>\n    <br \/>&#160;&#160;&#160;&#160; faultEx.Reason = &quot;Failed while performing Add &quot; ;&#160; <br \/>&#160;&#160;&#160;&#160; faultEx.Source = &quot;AddUpdateTM&quot;; <\/p>\n<p>&#160;&#160;&#160;&#160; faultEx.Detail = eX.Message; <\/p>\n<p>&#160;&#160;&#160;&#160; throw new FaultException&lt;CuboidFaultException&gt;(faultEx); <\/p>\n<p>}<\/font><\/p>\n<h5>Method AddTA (int nID, double dblL, double dblW, double dblH)<\/h5>\n<p>business logic for method <strong>AddTA<\/strong> is same as for <strong>AddTM.<\/strong>&#160;<\/p>\n<h5>Method UpdateTM (int nID, double dblL, double dblW, double dblH)<\/h5>\n<p><strong>UpdateTM<\/strong> is used to Update data to the table, passed cuboid information is updated to the <strong>CuboidInfo<\/strong> table, and its volume and surface area is calculated and updated to the <strong>CuboidDetail<\/strong> table. <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">[OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]<br \/>\n    <br \/>public void UpdateTM(int nID, double dblL, double dblW, double dblH) <\/p>\n<p>{<\/font><\/p>\n<p>Operations are decorated with <\/p>\n<p><font color=\"#0000ff\"><strong>TransactionScopeRequired = true<\/strong>,<\/font> that simply says that this operation <strong>requires a TransactionScope<\/strong>, if client does not propagate its transaction, transaction is created at the service level itself.<\/p>\n<p><strong><font color=\"#0000ff\">TransactionAutoComplete = true<\/font><\/strong> signifies, to complete the transaction scope automatically on successful execution of the operation; <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">if ((nID &lt;= 0) || (dblL &lt;= 0) || (dblW &lt;= 0) || (dblH &lt;= 0))<br \/>\n    <br \/>{ <\/p>\n<p>&#160;&#160;&#160; CuboidFaultException faultEx = new CuboidFaultException(); <\/p>\n<p>&#160;&#160;&#160; faultEx.Reason = &quot;Any dimension of Cuboid (length\/width\/height) can not be zero or negative value&quot;; <\/p>\n<p>&#160;&#160;&#160; faultEx.Source = &quot;AddUpdateTM&quot;; <\/p>\n<p>&#160;&#160;&#160; StringBuilder sbDetail = new StringBuilder(&quot;&quot;); <\/p>\n<p>&#160;&#160;&#160; if (nID &lt;= 0) sbDetail.Append(&quot;[ID is &lt;= 0] &quot;); <\/p>\n<p>&#160;&#160;&#160; if (dblL &lt;= 0) sbDetail.Append(&quot;[Length is &lt;= 0] &quot;); <\/p>\n<p>&#160;&#160;&#160; if (dblW &lt;= 0) sbDetail.Append(&quot;[Width is &lt;= 0] &quot;); <\/p>\n<p>&#160;&#160;&#160; if (dblW &lt;= 0) sbDetail.Append(&quot;[Height is &lt;= 0]&quot;); <\/p>\n<p>&#160;&#160;&#160; faultEx.Detail = sbDetail.ToString(); <\/p>\n<p>&#160;&#160;&#160; throw new FaultException&lt;CuboidFaultException&gt;(faultEx); <\/p>\n<p>} <\/p>\n<p><\/font>then method checks the passed parameters, in case they are zero or negative a <strong>FaultException<\/strong> is thrown. if the input parameters are permissible, then usual business logic proceeds, that includes.<\/p>\n<ul>\n<li>calculating the values to be added\/updated in CuboidDetail table. <\/li>\n<\/ul>\n<p><font color=\"#0000ff\" face=\"Verdana\">double dblVolume = (dblL * dblW * dblH);<br \/>\n    <br \/>double dblSArea = 2 * ((dblL * dblW) + (dblW * dblH) + (dblL * dblH));<\/font>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <\/p>\n<ul>\n<li>preparing appropriate query to be run on database, for both the tables, according to the method called (add\/update). <\/li>\n<\/ul>\n<p><font color=\"#0000ff\" size=\"1\" face=\"Verdana\">&#160;<strong>strQuery1 <\/strong>= &quot;Update CuboidInfo SET Length=&quot; + dblL.ToString(&quot;F2&quot;) + &quot;, Width=&quot; + dblW.ToString() + &quot;, Height=&quot; + dblH.ToString() + &quot; where ID=&quot; + nID.ToString(); <\/p>\n<p>&#160;&#160;&#160; <strong>strQuery2 <\/strong>= &quot;Update CuboidDetail SET SurfaceArea=&quot; + dblSArea.ToString(&quot;F2&quot;) + &quot;, Volume=&quot; + dblVolume.ToString() + &quot; where ID=&quot; + nID.ToString(); <\/font><\/p>\n<ul>\n<li>Reading Connection string from the App.config file of the host application. <\/li>\n<\/ul>\n<p><font color=\"#0000ff\" size=\"2\" face=\"Verdana\">\/\/ Get the all keys from the appSettings section from the configuration file.<br \/>\n    <br \/>System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); <\/p>\n<p>AppSettingsSection appSettings = (AppSettingsSection)config.GetSection(&quot;appSettings&quot;); <\/p>\n<p>string[] keys = appSettings.Settings.AllKeys;<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\"><font size=\"2\">\/\/ Get the connection string.<br \/>\n      <br \/>string strConnStr = appSettings.Settings[&quot;ConnectionString&quot;].Value;<\/font><\/font><\/p>\n<ul>\n<li>Now the business logic, open Connection, execute both the queries, if there is any error throw a fault exception encapsulating error information. <\/li>\n<\/ul>\n<p><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/>{ <\/p>\n<p>&#160;&#160;&#160;&#160; \/\/&#160; Open Connection <\/p>\n<p>&#160;&#160;&#160;&#160; dbConn = new SqlConnection(strConnStr); <\/p>\n<p>&#160;&#160;&#160;&#160; dbConn.Open();<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160; \/\/&#160; Create Command for Query 1<br \/>\n    <br \/>&#160;&#160;&#160;&#160; SqlCommand dbCmd1 = new SqlCommand(strQuery1, dbConn); <\/p>\n<p>&#160;&#160;&#160;&#160; nCnt1 = dbCmd1.ExecuteNonQuery();<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160; \/\/&#160; Create Command for Query 2<br \/>\n    <br \/>&#160;&#160;&#160;&#160; SqlCommand dbCmd2 = new SqlCommand(strQuery2, dbConn); <\/p>\n<p>&#160;&#160;&#160;&#160; nCnt2 = dbCmd2.ExecuteNonQuery();<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\"><strong>&#160;&#160;&#160;&#160; \/\/&#160; If TransactionAutoComplete=false, you need the line below.<br \/>\n      <br \/><\/strong>&#160;&#160;&#160;&#160; \/\/&#160; OperationContext.Current.SetTransactionComplete(); <\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160; \/\/&#160; Close Connection.<br \/>\n    <br \/>&#160;&#160;&#160;&#160; dbConn.Close(); <\/p>\n<p>&#160;&#160;&#160;&#160; dbConn = null; <\/p>\n<p>}<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">catch (Exception eX)<br \/>\n    <br \/>{ <\/p>\n<p>&#160;&#160;&#160;&#160; \/\/&#160; Close Connection. <\/p>\n<p>&#160;&#160;&#160;&#160; if (dbConn != null) <\/p>\n<p>&#160;&#160;&#160;&#160; { <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (dbConn.State == ConnectionState.Open) dbConn.Close(); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; dbConn = null; <\/p>\n<p>&#160;&#160;&#160;&#160; }<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160; CuboidFaultException faultEx = new CuboidFaultException();<br \/>\n    <br \/>&#160;&#160;&#160;&#160; faultEx.Reason =&#160; &quot;Failed while performing Update&quot;; <\/p>\n<p>&#160;&#160;&#160;&#160; faultEx.Source = &quot;UpdateTM&quot;; <\/p>\n<p>&#160;&#160;&#160;&#160; faultEx.Detail = eX.Message; <\/p>\n<p>&#160;&#160;&#160;&#160; throw new FaultException&lt;CuboidFaultException&gt;(faultEx); <\/p>\n<p>}<\/font><\/p>\n<h5>Method UpdateTA (int nID, double dblL, double dblW, double dblH)<\/h5>\n<p>business logic for method <strong>UpdateTA<\/strong> is same as for <strong><strong>Update<\/strong>TM.<\/strong>&#160;<\/p>\n<h5>Method void DeleteTM(int nID)<\/h5>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160; [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = true)]<br \/>\n  <br \/><\/font><\/p>\n<p><font color=\"#0000ff\">public void DeleteTM(int nID )<br \/>\n    <br \/>{<\/font><\/p>\n<p>Operations are decorated with <\/p>\n<p><font color=\"#0000ff\"><strong>TransactionScopeRequired = true<\/strong>,<\/font> that simply says that this operation <strong>requires a TransactionScope<\/strong>, if client does not propagate its transaction, transaction is created at the service level itself.<\/p>\n<p><strong><font color=\"#0000ff\">TransactionAutoComplete = true<\/font><\/strong> signifies, to complete the transaction scope automatically on successful execution of the operation; <\/p>\n<p>preparing appropriate query to be run on database, for both the tables, as records from both the tables need to be deleted.<font color=\"#0000ff\"><\/font><font color=\"#0000ff\" face=\"Verdana\">StringBuilder sbErr = new StringBuilder();<br \/>\n    <br \/>string strQuery1 = &quot;delete from CuboidInfo where ID=&quot; + nID.ToString(); <\/p>\n<p>string strQuery2 = &quot;delete from CuboidDetail where ID=&quot; + nID.ToString();<\/font><\/p>\n<p>Fetch connection string from the app.config file. <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);<br \/>\n    <br \/>AppSettingsSection appSettings = (AppSettingsSection)config.GetSection(&quot;appSettings&quot;); <\/p>\n<p>string[] keys = appSettings.Settings.AllKeys;<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">\/\/ Get the connection string.<br \/>\n    <br \/>string strConnStr = appSettings.Settings[&quot;ConnectionString&quot;].Value;<\/font><\/p>\n<p>Do the business logic, which involves, opening connection, deleting the matching row from both the tables. execute both the queries inside a try block,&#160; if there is any error throw a fault exception encapsulating error information.<\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/>{ <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; \/\/&#160; Open Connection <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; dbConn = new SqlConnection(strConnStr); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; dbConn.Open();<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; \/\/&#160; Create Command for Query 1<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; SqlCommand dbCmd1 = new SqlCommand(strQuery1, dbConn); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; nCnt1 = dbCmd1.ExecuteNonQuery();<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; \/\/&#160; Create Command for Query 2<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; SqlCommand dbCmd2 = new SqlCommand(strQuery2, dbConn); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; nCnt2 = dbCmd2.ExecuteNonQuery();<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; \/\/&#160; As TransactionAutoComplete = false, so you manually need to notify, that transaction is compplete.<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; \/\/&#160; OperationContext.Current.SetTransactionComplete();<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; \/\/&#160; Close Connection.<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; dbConn.Close(); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; dbConn = null; <\/p>\n<p>&#160;&#160;&#160; } <\/p>\n<p>&#160;&#160;&#160; catch (Exception eX) <\/p>\n<p>&#160;&#160;&#160; { <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; \/\/&#160; Close Connection. <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (dbConn != null) <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; { <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (dbConn.State == ConnectionState.Open) dbConn.Close(); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; dbConn = null; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; }<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160;&#160;&#160;&#160; CuboidFaultException faultEx = new CuboidFaultException();<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; faultEx.Reason = &quot;Failed while performing Delete&quot;; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; faultEx.Source = &quot;DeleteTM&quot;; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; faultEx.Detail = eX.Message; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; throw new FaultException&lt;CuboidFaultException&gt;(faultEx); <\/p>\n<p>&#160;&#160;&#160; }<\/font><\/p>\n<h5>Method void DeleteTA(int nID)<\/h5>\n<p>business logic for method <strong>DeleteTA<\/strong> is same as for <strong>DeleteTM.<\/strong>&#160;<\/p>\n<h5>Method&#160; public&#160; Dictionary&lt;int, CuboidData&gt; GetList()<\/h5>\n<p>This method simply reads the list all the Cuboid from the database. <strong>all inside a try block.<\/strong><\/p>\n<p>get connection string from app.config file. <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">Find application&#8217;s Settings through config file.<br \/>\n    <br \/>System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); <\/p>\n<p>AppSettingsSection appSettings = (AppSettingsSection)config.GetSection(&quot;appSettings&quot;); <\/p>\n<p>string[] keys = appSettings.Settings.AllKeys;<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">\/\/ Get the connection string.<br \/>\n    <br \/>string strConnStr = appSettings.Settings[&quot;ConnectionString&quot;].Value;<\/font><\/p>\n<p>Open Connection<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">dbConn = new SqlConnection(strConnStr);<br \/>\n    <br \/>dbConn.Open();<\/font><\/p>\n<p>Create Query to read ID, Length, Width, Height from CuboidInfo Table, while as SurfaceArea and Volume is fetched from CuboidDetail table.&#160; <\/p>\n<p><font color=\"#0000ff\">string strQuery = &quot;select CuboidInfo.*, CuboidDetail.SurfaceArea, CuboidDetail.Volume from CuboidInfo join CuboidDetail on CuboidDetail.ID=CuboidInfo.ID&quot;;`<\/font><font color=\"#0000ff\"><\/font><\/p>\n<p>execute query and collect the result in the list. <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">\/\/&#160; Create Command for Query 1<br \/>\n    <br \/>string strQuery = &quot;select CuboidInfo.*, CuboidDetail.SurfaceArea, CuboidDetail.Volume from CuboidInfo join CuboidDetail on CuboidDetail.ID=CuboidInfo.ID&quot;; <\/p>\n<p>SqlCommand dbCmd = new SqlCommand(strQuery, dbConn); <\/p>\n<p>dbReader = dbCmd.ExecuteReader();<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">while (dbReader.HasRows)<br \/>\n    <br \/>{ <\/p>\n<p>&#160;&#160;&#160;&#160; bool bReaded = dbReader.Read(); <\/p>\n<p>&#160;&#160;&#160;&#160; if (bReaded == false) break;<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160; CuboidData cInfo = new CuboidData();<br \/>\n    <br \/>&#160;&#160;&#160;&#160; cInfo.ID = int.Parse(dbReader[&quot;ID&quot;].ToString()); <\/p>\n<p>&#160;&#160;&#160;&#160; cInfo.Length = int.Parse(dbReader[&quot;Length&quot;].ToString()); <\/p>\n<p>&#160;&#160;&#160;&#160; cInfo.Width = int.Parse(dbReader[&quot;Width&quot;].ToString()); <\/p>\n<p>&#160;&#160;&#160;&#160; cInfo.Height = int.Parse(dbReader[&quot;Height&quot;].ToString()); <\/p>\n<p>&#160;&#160;&#160;&#160; cInfo.SurfaceArea = int.Parse(dbReader[&quot;SurfaceArea&quot;].ToString()); <\/p>\n<p>&#160;&#160;&#160;&#160; cInfo.Volume = int.Parse(dbReader[&quot;Volume&quot;].ToString()); <\/p>\n<p>&#160;&#160;&#160;&#160; cuboidList.Add(cInfo.ID, cInfo); <\/p>\n<p>}<\/font><\/p>\n<p>Close reader and Connection.<\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">dbReader.Close();&#160;&#160; \/\/&#160; Close Reader<br \/>\n    <br \/>dbConn.Close();&#160;&#160;&#160;&#160; \/\/&#160; Close Connection. <\/p>\n<p>dbConn = null;<\/font><\/p>\n<p>as everything was inside try block, if there is any error throw a fault exception encapsulating error information.<\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">catch (Exception eX)<br \/>\n    <br \/>{ <\/p>\n<p>&#160;&#160;&#160;&#160; \/\/&#160; Close Connection. <\/p>\n<p>&#160;&#160;&#160;&#160; if (dbConn != null) <\/p>\n<p>&#160;&#160;&#160;&#160; { <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (dbReader.IsClosed == false) dbReader.Close(); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if (dbConn.State == ConnectionState.Open) dbConn.Close(); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; dbConn = null; <\/p>\n<p>&#160;&#160;&#160;&#160; }<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160; CuboidFaultException faultEx = new CuboidFaultException();<br \/>\n    <br \/>&#160;&#160;&#160;&#160; faultEx.Reason = &quot;Failed while fetching QuboidData&quot;; <\/p>\n<p>&#160;&#160;&#160;&#160; faultEx.Source = &quot;GetList&quot;; <\/p>\n<p>&#160;&#160;&#160;&#160; faultEx.Detail = eX.Message; <\/p>\n<p>&#160;&#160;&#160;&#160; throw new FaultException&lt;CuboidFaultException&gt;(faultEx); <\/p>\n<p>}<\/font><\/p>\n<p>otherwise simply return the populated <strong>CuboidList<\/strong>, and close the function block.<\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160; return cuboidList;<br \/>\n    <br \/>} <\/font><\/p>\n<h3>Second Module: Service Host Application (<em>TransactionLibHost<\/em>.<em>dll<\/em>) <\/h3>\n<p>Add a new Project to the workspace, To create this project, i have taken a simple Console based application , while choosing from project wizard option. let&#8217;s name it &quot;<code><strong>TransactionLibHost<\/strong><\/code>&quot;, this application will host our WCF Service library. <\/p>\n<h4>Adding application configuration<\/h4>\n<ul>\n<li>Add an <strong>Application configuration (App.config)<\/strong> file to the project. <\/li>\n<\/ul>\n<h4>Defining configuration<\/h4>\n<p>before we write any code for the host, let\u2019s define the configuration. <\/p>\n<h4>Assumption<\/h4>\n<p>The Host application will expose the following endpoints for the service.<\/p>\n<ul>\n<li>CuboidService will expose <strong>HTTP endpoint at Port 9011<\/strong> <\/li>\n<li>Corresponding <strong>mex <\/strong>End Point <strong>(IMetadatExchange)<\/strong> for the HTTP end point. <\/li>\n<\/ul>\n<h4>Defining configuration for <strong>CuboidService<\/strong><\/h4>\n<h5>Defining Service base address and Service Endpoints <\/h5>\n<p><font color=\"#000080\" size=\"2\">&lt;services&gt;<br \/>\n    <br \/>&#160;&#160;&#160;&#160; &lt;service behaviorConfiguration=&quot;TransactionLib.<strong><font color=\"#ff0000\">CuboidServiceBehavior<\/font><\/strong>&quot; name=&quot;TransactionLib.CuboidService&quot;&gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160; &lt;host&gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;baseAddresses&gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;add baseAddress=&quot;<strong>http:\/\/localhost:9011\/CuboidService<\/strong>\/&quot; \/&gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;\/baseAddresses&gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160; &lt;\/host&gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160; <br \/>&#160;&#160;&#160;&#160;&#160;&#160; &lt;endpoint address=&quot;&quot; binding=&quot;wsHttpBinding&quot; contract=&quot;TransactionLib.ICuboidService&quot; <strong>bindingConfiguration<\/strong> =&quot;<strong><font color=\"#0000ff\">transBinding<\/font><\/strong>&quot; \/&gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160; &lt;endpoint address=&quot;mex&quot; binding=&quot;mexHttpBinding&quot; contract=&quot;IMetadataExchange&quot; \/&gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160; <br \/>&#160;&#160;&#160;&#160; &lt;\/service&gt; <\/p>\n<p>&#160;&#160; &lt;\/services&gt;<\/font><\/p>\n<h6>Explanation <\/h6>\n<p>behaviorConfiguration=&quot;TransactionLib.<strong><font color=\"#ff0000\">CuboidServiceBehavior<\/font><\/strong><\/p>\n<p>specifies that Service behavior of service has been defined in <strong>&lt;serviceBehaviors&gt;<\/strong> section,&#160; which is named as &quot;<strong>CuboidServiceBehavior<\/strong>&quot;.<\/p>\n<p>&lt;<strong>baseAddresses&gt;&#160; &lt;\/baseAddresses&gt;<\/strong><\/p>\n<p>Represents a collection of <strong>&lt;baseAddress&gt;<\/strong> elements, which are base addresses for a service host in a self-hosted environment. If a base address is present, endpoints can be configured with addresses relative to the base address. <\/p>\n<p>&lt;add baseAddress=&quot;<strong>http:\/\/localhost:9011\/CuboidService<\/strong>\/&quot; \/&gt;<\/p>\n<p>Represents a configuration element that specifies the base addresses used by the service host.<\/p>\n<p><font color=\"#000080\" size=\"2\"><\/font><font color=\"#000080\" size=\"2\">&lt;endpoint address=&quot;&quot; binding=&quot;wsHttpBinding&quot; contract=&quot;TransactionLib.ICuboidService&quot; <strong>bindingConfiguration<\/strong> =&quot;<strong><font color=\"#0000ff\">transBinding<\/font><\/strong>&quot; \/&gt; <\/p>\n<p>&lt;endpoint address=&quot;mex&quot; binding=&quot;mexHttpBinding&quot; contract=&quot;IMetadataExchange&quot; \/&gt;<\/font><\/p>\n<p>The service defines, one <strong>endpoint<\/strong> with <strong>wsHttpBinding<\/strong>, another endpoint is defined as <strong>mex<\/strong>, are defined for publication of metadata, <strong>IMetadataExchange<\/strong> is standard contract for <strong>mex<\/strong> endpoints. <\/p>\n<h4><\/h4>\n<h5>Defining behaviors <\/h5>\n<p><font color=\"#000080\">&lt;behaviors&gt;<br \/>\n    <br \/>&#160;&#160;&#160;&#160; &lt;serviceBehaviors&gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160; &lt;behavior name=&quot;TransactionLib.<strong><font color=\"#ff0000\">CuboidServiceBehavior<\/font><\/strong>&quot;&gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!&#8211; To avoid disclosing metadata information, <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; set the value below to false and remove the metadata endpoint above before deployment &#8211;&gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; <strong>&lt;serviceMetadata httpGetEnabled=&quot;True&quot;\/&gt;<\/strong> <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;!&#8211; To receive exception details in faults for debugging purposes, <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; set the value below to true.&#160; Set to false before deployment to avoid disclosing exception information &#8211;&gt; <\/p>\n<p><\/font><font color=\"#000080\"><strong>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;serviceDebug includeExceptionDetailInFaults=&quot;true&quot; \/&gt;<br \/>\n      <br \/><\/strong>&#160;&#160;&#160;&#160;&#160;&#160; &lt;\/behavior&gt; <\/p>\n<p>&#160;&#160;&#160;&#160; &lt;\/serviceBehaviors&gt; <\/p>\n<p>&#160;&#160; &lt;\/behaviors&gt;<\/font><\/p>\n<h6>Explanation <\/h6>\n<p>&lt;serviceBehaviors&gt; section represents all the behaviors defined for a specific service. <\/p>\n<p>service behaviour defines two attributes,&#160;&#160; <\/p>\n<pre><strong><font color=\"#0000ff\">&lt;serviceMetadata httpGetEnabled=&quot;true&quot; \/&gt;<\/font> <\/strong><\/pre>\n<p>Gets or sets a value that indicates whether to publich service medtadata for retrieval using an HTTP\/GET request, true means yes, metadata is available for retrieval using a HTTP\/GET request. <\/p>\n<pre><strong><font color=\"#0000ff\">&lt;serviceDebug includeExceptionDetailInFaults=&quot;true &quot;\/&gt;<\/font><\/strong><\/pre>\n<p>Set <strong><code>IncludeExceptionDetailsInFaults<\/code> <\/strong>to <code>true<\/code><strong> <\/strong>to enable clients to obtain information about internal service method&#160; exceptions; it is only recommended as a way of temporarily debugging a service application. this property <strong>must be set to false on production servers<\/strong>.&#160;&#160; <\/p>\n<h5>Defining Bindings<\/h5>\n<p>&lt;bindings &gt;<br \/>\n  <br \/>&#160;&#160;&#160; &lt;wsHttpBinding&gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160; &lt;binding name =&quot;<strong><font color=\"#0000ff\">transBinding<\/font><\/strong>&quot;<strong> transactionFlow=&quot;true<\/strong>&quot; &gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;reliableSession enabled =&quot;true&quot;\/&gt; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160; &lt;\/binding&gt; <\/p>\n<p>&#160;&#160;&#160; &lt;\/wsHttpBinding&gt; <\/p>\n<p>&lt;\/bindings&gt;<\/p>\n<h6>Explanation <\/h6>\n<p>&lt;bindings&gt; section used to configure system provided bindings. <\/p>\n<p><font color=\"#0000ff\">&lt;binding name =&quot;<strong>transBinding<\/strong>&quot;<strong> transactionFlow=&quot;true<\/strong>&quot; &gt;<\/font><\/p>\n<p>By default, transaction aware bindings do not propagate transactions. You can specify whether or not client transaction is propagated to service by changing Binding and operational contract configuration. as <strong>transactionFlow=&quot;true&quot;. <\/strong><\/p>\n<p><strong><font color=\"#0000ff\">&lt;reliableSession enabled =&quot;true&quot;\/&gt;<\/font><\/strong><\/p>\n<p>Enabling reliability will decrease the likelihood of aborted transactions, means that the transactions will be less likely to abort due to communication problems.<\/p>\n<h4>Writing Code to Host the service.<\/h4>\n<p>As the configuration for the service has been defined, before we write any code&#160; <\/p>\n<ul>\n<li>add reference of <strong>System.ServiceModel<\/strong> to the project.&#160; <\/li>\n<\/ul>\n<p>Let\u2019s write code to host the service.<\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/>{ <\/p>\n<p>&#160;&#160;&#160;&#160; ServiceHost host = new ServiceHost(typeof(TransactionLib.CuboidService)); <\/p>\n<p>&#160;&#160;&#160;&#160; host.Open(); <\/p>\n<p>&#160;&#160;&#160;&#160; Console.WriteLine(&quot;\\nService is Hosted as http:\/\/localhost:9011\/CuboidService&quot;); <\/p>\n<p>&#160;&#160;&#160;&#160; Console.WriteLine(&quot;\\nPress&#160; key to stop the service.&quot;); <\/p>\n<p>&#160;&#160;&#160;&#160; Console.ReadLine(); <\/p>\n<p>&#160;&#160;&#160;&#160; host.Close(); <\/p>\n<p>} <\/p>\n<p>catch (Exception eX) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160;&#160; Console.WriteLine(&quot;There was en error while Hosting Service [&quot; + eX.Message + &quot;]&quot;); <\/p>\n<p>&#160;&#160;&#160;&#160; Console.WriteLine(&quot;\\nPress&#160; key to close.&quot;); <\/p>\n<p>&#160;&#160;&#160;&#160; Console.ReadLine(); <\/p>\n<p>}<\/font><\/p>\n<h5>Explanation<\/h5>\n<p><strong>ServiceHost<\/strong> class provides a host for services. <\/p>\n<p>Build and Execute the Host.<\/p>\n<h3>Third Module, Creating Client (TransactionClient.exe)<\/h3>\n<h4>Creating the base project&#160; <\/h4>\n<p>Take a Windows Form based based application. name it <strong>TransactionClient<\/strong>. <\/p>\n<h4>Creating GUI for the Client Project.<\/h4>\n<p>I have designed the GUI for the client project, to test all the aspects of the service as shown below.<\/p>\n<p><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/clientgui.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"ClientGUI\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"ClientGUI\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/clientgui_thumb.jpg\" width=\"499\" height=\"325\" \/><\/a><\/p>\n<table cellspacing=\"0\" cellpadding=\"2\" width=\"674\" border=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"69\"><strong>Control <\/strong><\/td>\n<td valign=\"top\" width=\"110\"><strong>Control Name<\/strong><\/td>\n<td valign=\"top\" width=\"493\"><strong>Purpose <\/strong><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">TextBox<\/td>\n<td valign=\"top\" width=\"110\">txtID<\/td>\n<td valign=\"top\" width=\"493\">ID of the Cuboid has to be entered here.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">TextBox<\/td>\n<td valign=\"top\" width=\"110\">txtLength<\/td>\n<td valign=\"top\" width=\"493\">Length of the Cuboid has to be entered here.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">TextBox<\/td>\n<td valign=\"top\" width=\"110\">txtWidth<\/td>\n<td valign=\"top\" width=\"493\">Width of the Cuboid has to be entered here.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">TextBox<\/td>\n<td valign=\"top\" width=\"110\">txtHeight<\/td>\n<td valign=\"top\" width=\"493\">Height of the Cuboid has to be entered here.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">Button<\/td>\n<td valign=\"top\" width=\"110\">btnDeleteTMYes<\/td>\n<td valign=\"top\" width=\"493\">Calls <strong>DeleteTM <\/strong>method, with transaction<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">Button<\/td>\n<td valign=\"top\" width=\"110\">btnDeleteTMNo<\/td>\n<td valign=\"top\" width=\"493\">Calls <strong>DeleteTM <\/strong>method, without transaction<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">Button<\/td>\n<td valign=\"top\" width=\"110\">btnDeleteTAYes<\/td>\n<td valign=\"top\" width=\"493\">Calls <strong>DeleteTA <\/strong>method, with transaction<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">Button<\/td>\n<td valign=\"top\" width=\"110\">btnDeleteTANo<\/td>\n<td valign=\"top\" width=\"493\">Calls <strong>DeleteTA<\/strong> method, without transaction<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">Button<\/td>\n<td valign=\"top\" width=\"110\">btnAddTMYes<\/td>\n<td valign=\"top\" width=\"493\">Calls <strong>AddTM<\/strong> method, with transaction<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">Button<\/td>\n<td valign=\"top\" width=\"110\">btnAddTMNo<\/td>\n<td valign=\"top\" width=\"493\">Calls <strong>AddTM<\/strong> method, without transaction<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">Button<\/td>\n<td valign=\"top\" width=\"110\">btnAddTAYes<\/td>\n<td valign=\"top\" width=\"493\">Calls <strong>AddTA <\/strong>method, with transaction<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">Button<\/td>\n<td valign=\"top\" width=\"110\">btnAddTANo<\/td>\n<td valign=\"top\" width=\"493\">Calls <strong>AddTA<\/strong> method, without transaction<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">Button<\/td>\n<td valign=\"top\" width=\"110\">btnUpdateTMYes<\/td>\n<td valign=\"top\" width=\"493\">Calls <strong>UpdateTM <\/strong>method, with transaction<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">Button<\/td>\n<td valign=\"top\" width=\"110\">btnUpdateTMNo<\/td>\n<td valign=\"top\" width=\"493\">Calls <strong>UpdateTM<\/strong> method, without transaction<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">Button<\/td>\n<td valign=\"top\" width=\"110\">btnUpdateTAYes<\/td>\n<td valign=\"top\" width=\"493\">Calls <strong>UpdateTA <\/strong>method, with transaction<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">Button<\/td>\n<td valign=\"top\" width=\"110\">btnUpdateTANo<\/td>\n<td valign=\"top\" width=\"493\">Calls <strong>UpdateTA<\/strong> method, without transaction<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">Button<\/td>\n<td valign=\"top\" width=\"110\">btnRefresh<\/td>\n<td valign=\"top\" width=\"493\">Calls GetList method <\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">Button<\/td>\n<td valign=\"top\" width=\"110\">btnClose<\/td>\n<td valign=\"top\" width=\"493\">Closes the Application.<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"69\">LuistView<\/td>\n<td valign=\"top\" width=\"110\">lvOutput<\/td>\n<td valign=\"top\" width=\"493\">Displays Output.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&#160;<\/p>\n<h4>Add service Reference to the client application<\/h4>\n<p>Make sure Host Application (<strong>TransactionLibHost.exe)&#160; <\/strong>is running,<\/p>\n<p><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/runningtransactionlibhost.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"RunningTransactionLibHost\" style=\"background-image:none;padding-top:0;padding-left:0;margin:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"RunningTransactionLibHost\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/runningtransactionlibhost_thumb.jpg\" width=\"558\" height=\"99\" \/><\/a><\/p>\n<p>right click on the project, select <strong>Add Service Reference <\/strong><\/p>\n<p>Add Service Reference, a dialog box will be displayed as shown below.<\/p>\n<p><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/generateproxycuboidservice.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"GenerateProxyCuboidService\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"GenerateProxyCuboidService\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/generateproxycuboidservice_thumb.jpg\" width=\"646\" height=\"436\" \/><\/a><\/p>\n<p>for the Address, enter <strong>http:\/\/localhost:9011\/CuboidService\/mex<\/strong><\/p>\n<p>for the Namespace, enter <strong>CuboidServiceReference<\/strong>.<\/p>\n<p>press OK.<\/p>\n<ul>\n<li><strong>Service References<\/strong> folder will be created under Client project. under which a new node <strong>CuboidServiceReference<\/strong> will be created. <\/li>\n<li>A configuration file (<strong>app.config<\/strong>) will be added to the client project. <\/li>\n<\/ul>\n<h4>Little house keeping<\/h4>\n<ul>\n<li>On the Form_Load event just initialize the controls.,\n<p><font color=\"#0000ff\" face=\"Verdana\">private void <strong>frmTransactionLibClient_Load<\/strong>(object sender, EventArgs e) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; txtID.Text = &quot;1&quot;; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; txtLength.Text = &quot;400&quot;; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; txtWidth.Text = &quot;300.0&quot;; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; txtHeight.Text = &quot;200&quot; ;<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lvOutput.View = View.Details;<br \/>\n        <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lvOutput.FullRowSelect = true; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lvOutput.GridLines = true;<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lvOutput.Columns.Clear();<br \/>\n        <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lvOutput.Columns.Add( &quot;ID&quot;, 43); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lvOutput.Columns.Add(&quot;Length&quot;, 52); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lvOutput.Columns.Add(&quot;Width&quot;, 52); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lvOutput.Columns.Add(&quot;Height&quot;, 52); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lvOutput.Columns.Add(&quot;Area&quot;, 70); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lvOutput.Columns.Add(&quot;Volume&quot;, 88); <\/p>\n<p>}<\/font><\/p>\n<h4>&#160;<\/h4>\n<\/li>\n<li>Create an Helper function to fetch the numeric values from Input Text Boxes.\n<p>\/\/&#160; Common Helper Function.<br \/>\n      <br \/><font color=\"#0000ff\" face=\"Verdana\">private void <strong>ParseInputs<\/strong>(ref int nID, ref double dblL, ref double dblW, ref double dblH) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160;&#160; nID = 0;&#160;&#160;&#160; dblL = 0;&#160; dblW = 0;&#160;&#160; dblH = 0; <\/p>\n<p>&#160;&#160;&#160;&#160; int.TryParse(txtID.Text, out nID); <\/p>\n<p>&#160;&#160;&#160;&#160; double.TryParse(txtLength.Text, out dblL); <\/p>\n<p>&#160;&#160;&#160;&#160; double.TryParse(txtWidth.Text, out dblW); <\/p>\n<p>&#160;&#160;&#160;&#160; double.TryParse(txtHeight.Text, out dblH); <\/p>\n<p>}<\/font><\/p>\n<p>note that, no input is&#160; validated at this side, i just fetched the values, as we have implemented a <strong>FaultContract<\/strong> on the service side, to handle invalid input errors. although i would recommend, if possible,&#160; always validate parameters at the client side, before passing them to service.<\/p>\n<\/li>\n<\/ul>\n<h4>Calling Methods on the Service.<\/h4>\n<h5>Calling Method GetList<\/h5>\n<p>enclose every thing in a try block, Creates an object of the Service Proxy, and calls the service method.<\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/>{ <\/p>\n<p>&#160;&#160;&#160; CuboidServiceClient objClient = new CuboidServiceClient(); <\/p>\n<p>&#160;&#160;&#160; Dictionary&lt;int, CuboidData&gt; list = objClient.GetList(); <\/p>\n<p>&#160;&#160;&#160; if (list != null)&#160;&#160; <br \/>&#160;&#160;&#160; {<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160;&#160;&#160; and if the return value is not null (there was no error). ListView control is populated.<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">&#160;&#160;&#160;&#160;&#160;&#160; int nCount = list.Keys.Count;<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160; lvOutput.Items.Clear(); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160; foreach (int nID in list.Keys) <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160; { <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; CuboidData cInfo = list[nID]; <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ListViewItem lvItem = lvOutput.Items.Add(cInfo.ID.ToString()); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lvItem.SubItems.Add(cInfo.Length.ToString(&quot;F2&quot;)); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lvItem.SubItems.Add(cInfo.Width.ToString(&quot;F2&quot;)); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lvItem.SubItems.Add(cInfo.Height.ToString(&quot;F2&quot;)); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lvItem.SubItems.Add(cInfo.SurfaceArea.ToString(&quot;F2&quot;)); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; lvItem.SubItems.Add(cInfo.Volume.ToString(&quot;F2&quot;)); <\/p>\n<p>&#160;&#160;&#160;&#160;&#160;&#160; } <\/p>\n<p>&#160;&#160;&#160; }<\/font><\/p>\n<p>Close try block, and see if you got any fault exception, if yes, then display the error message.<\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">}<br \/>\n    <br \/>catch (FaultException&lt;CuboidFaultException&gt; eX) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160; strMsg = &quot;Source [&quot; + eX.Detail.Source + &quot;]&quot; + &quot;\\nReason [&quot; + eX.Detail.Reason + &quot;] \\nDeatil [&quot; + eX.Detail.Detail + &quot;]&quot;; <\/p>\n<p>} <\/p>\n<p>catch (Exception eX) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160; strMsg = eX.Message; <\/p>\n<p>} <\/p>\n<p>MessageBox.Show(strMsg); <\/p>\n<p><\/font><\/p>\n<h5>Calling Method AddTM, Adding a cuboid, inside a client&#8217;s transaction<\/h5>\n<p>declare and initialize variables.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">int nID = 0;<br \/>\n    <br \/>double dblLength = 0, dblWidth = 0, dblHeight = 0;<\/font><\/p>\n<p>Parse input values from controls.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">ParseInputs(ref nID, ref dblLength, ref dblWidth, ref dblHeight);<\/font><\/p>\n<p>enclose every thing in a try block<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/><strong>{<\/strong><\/font><\/p>\n<p>execute the service method in client&#8217;s transaction<br \/>\n  <br \/>&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew))<br \/>\n    <br \/>&#160;&#160;&#160; <strong>{<\/strong><\/font><\/p>\n<p>create procy object and call the method.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">&#160; CuboidServiceClient objClient = new CuboidServiceClient();<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; objClient.AddTM ( nID, dblLength, dblWidth, dblHeight);<\/font><\/p>\n<p>Client&#8217;s transacton is complete.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">ts.Complete();<\/font><\/p>\n<p>close client&#8217;s Transaction scope block&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br \/><font color=\"#0000ff\" face=\"Verdana\"><strong>&#160;&#160;&#160; <\/strong><font color=\"#0000ff\"><strong>}<br \/>\n        <br \/><\/strong><\/font><\/font>close try block <\/p>\n<p><strong><font color=\"#0000ff\">}<\/font><\/strong><\/p>\n<p>in case if there is any problem. store the error message from service.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">catch (FaultException&lt;CuboidFaultException&gt; eX)<br \/>\n    <br \/>{ <\/p>\n<p><font size=\"1\">&#160;&#160;&#160; strMsg = &quot;Source [&quot;+eX.Detail.Source+&quot;]&quot;+&quot;\\nReason [&quot;+ eX.Detail.Reason+&quot;] \\nDeatil [&quot;+eX.Detail.Detail+ &quot;]&quot;;<\/font> <\/p>\n<p>} <\/p>\n<p>catch (Exception eX) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160; strMsg = eX.Message; <\/p>\n<p>} <\/p>\n<p><\/font>display error message <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">MessageBox.Show(strMsg);<\/font><\/p>\n<h5>Calling Method AddTM, Adding a cuboid, without a client&#8217;s transaction<\/h5>\n<p>declare and initialize variables.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">int nID = 0;<br \/>\n    <br \/>double dblLength = 0, dblWidth = 0, dblHeight = 0;<\/font><\/p>\n<p>Parse input values from controls.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">ParseInputs(ref nID, ref dblLength, ref dblWidth, ref dblHeight);<\/font><\/p>\n<p>enclose every thing in a try block<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/><strong>{<\/strong><\/font><\/p>\n<p>create proxy object and call the method.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">&#160; CuboidServiceClient objClient = new CuboidServiceClient();<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; objClient.AddTM (&#160; nID, dblLength, dblWidth, dblHeight);<\/font><\/p>\n<p><strong>Note: <\/strong>same method is called for <strong>Updating a cuboid<\/strong>, <strong>passing first parameter as false<\/strong>.<\/p>\n<p>close try block<br \/>\n  <br \/><strong><font color=\"#0000ff\">}<\/font><\/strong><\/p>\n<p>in case if there is any problem. store the error message from service.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">catch (FaultException&lt;CuboidFaultException&gt; eX)<br \/>\n    <br \/>{ <\/p>\n<p><font size=\"1\">&#160;&#160;&#160; strMsg = &quot;Source [&quot;+eX.Detail.Source+&quot;]&quot;+&quot;\\nReason [&quot;+ eX.Detail.Reason+&quot;] \\nDeatil [&quot;+eX.Detail.Detail+ &quot;]&quot;;<\/font> <\/p>\n<p>} <\/p>\n<p>catch (Exception eX) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160; strMsg = eX.Message; <\/p>\n<p>} <\/p>\n<p><\/font>display error message <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">MessageBox.Show(strMsg);<\/font><\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\"><\/font><\/p>\n<h5>Calling Method UpdateTM, updating a cuboid, inside a client&#8217;s transaction<\/h5>\n<p>declare and initialize variables.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">int nID = 0;<br \/>\n    <br \/>double dblLength = 0, dblWidth = 0, dblHeight = 0;<\/font><\/p>\n<p>Parse input values from controls.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">ParseInputs(ref nID, ref dblLength, ref dblWidth, ref dblHeight);<\/font><\/p>\n<p>enclose every thing in a try block<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/><strong>{<\/strong><\/font><\/p>\n<p>execute the service method in client&#8217;s transaction<br \/>\n  <br \/>&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew))<br \/>\n    <br \/>&#160;&#160;&#160; <strong>{<\/strong><\/font><\/p>\n<p>create procy object and call the method.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">&#160; CuboidServiceClient objClient = new CuboidServiceClient();<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; objClient.UpdateTM ( nID, dblLength, dblWidth, dblHeight);<\/font><\/p>\n<p><strong>Note: <\/strong>same method is called for <strong>Updating a cuboid<\/strong>, <strong>passing first parameter as false<\/strong>.<\/p>\n<p>Client&#8217;s transacton is complete.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">ts.Complete();<\/font><\/p>\n<p>close client&#8217;s Transaction scope block&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br \/><font color=\"#0000ff\" face=\"Verdana\"><strong>&#160;&#160;&#160; <\/strong><font color=\"#0000ff\"><strong>}<br \/>\n        <br \/><\/strong><\/font><\/font>close try block <\/p>\n<p><strong><font color=\"#0000ff\">}<\/font><\/strong><\/p>\n<p>in case if there is any problem. store the error message from service.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">catch (FaultException&lt;CuboidFaultException&gt; eX)<br \/>\n    <br \/>{ <\/p>\n<p><font size=\"1\">&#160;&#160;&#160; strMsg = &quot;Source [&quot;+eX.Detail.Source+&quot;]&quot;+&quot;\\nReason [&quot;+ eX.Detail.Reason+&quot;] \\nDeatil [&quot;+eX.Detail.Detail+ &quot;]&quot;;<\/font> <\/p>\n<p>} <\/p>\n<p>catch (Exception eX) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160; strMsg = eX.Message; <\/p>\n<p>} <\/p>\n<p><\/font>display error message <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">MessageBox.Show(strMsg);<\/font><\/p>\n<h5>Calling Method UpdateTM, Updating a cuboid, without a client&#8217;s transaction<\/h5>\n<p>declare and initialize variables.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">int nID = 0;<br \/>\n    <br \/>double dblLength = 0, dblWidth = 0, dblHeight = 0;<\/font><\/p>\n<p>Parse input values from controls.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">ParseInputs(ref nID, ref dblLength, ref dblWidth, ref dblHeight);<\/font><\/p>\n<p>enclose every thing in a try block<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/><strong>{<\/strong><\/font><\/p>\n<p>create proxy object and call the method.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">&#160; CuboidServiceClient objClient = new CuboidServiceClient();<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; objClient.UpdatingTM (&#160; nID, dblLength, dblWidth, dblHeight);<\/font><\/p>\n<p>close try block<br \/>\n  <br \/><strong><font color=\"#0000ff\">}<\/font><\/strong><\/p>\n<p>in case if there is any problem. store the error message from service.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">catch (FaultException&lt;CuboidFaultException&gt; eX)<br \/>\n    <br \/>{ <\/p>\n<p><font size=\"1\">&#160;&#160;&#160; strMsg = &quot;Source [&quot;+eX.Detail.Source+&quot;]&quot;+&quot;\\nReason [&quot;+ eX.Detail.Reason+&quot;] \\nDeatil [&quot;+eX.Detail.Detail+ &quot;]&quot;;<\/font> <\/p>\n<p>} <\/p>\n<p>catch (Exception eX) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160; strMsg = eX.Message; <\/p>\n<p>} <\/p>\n<p><\/font>display error message <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">MessageBox.Show(strMsg);<\/font><\/p>\n<blockquote><\/blockquote>\n<h5>Calling Method DeleteTM, Adding a cuboid, inside a client&#8217;s transaction<\/h5>\n<p>declare and initialize variables.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">int nID = 0;<br \/>\n    <br \/><\/font>Parse input values from controls. <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">int.TryParse(txtID.Text, out nID);<\/font><\/p>\n<p>enclose every thing in a try block<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/><strong>{<\/strong><\/font><\/p>\n<p>execute the service method in client&#8217;s transaction<br \/>\n  <br \/>&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew))<br \/>\n    <br \/>&#160;&#160;&#160; <strong>{<\/strong><\/font><\/p>\n<p>create procy object and call the method.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">&#160; CuboidServiceClient objClient = new CuboidServiceClient();<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; objClient.DeleteTM ( nID);<\/font><\/p>\n<p>Client&#8217;s transacton is complete.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">ts.Complete();<\/font><\/p>\n<p>close client&#8217;s Transaction scope block&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br \/><font color=\"#0000ff\" face=\"Verdana\"><strong>&#160;&#160;&#160; <\/strong><font color=\"#0000ff\"><strong>}<br \/>\n        <br \/><\/strong><\/font><\/font>close try block <\/p>\n<p><strong><font color=\"#0000ff\">}<\/font><\/strong><\/p>\n<p>in case if there is any problem. store the error message from service.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">catch (FaultException&lt;CuboidFaultException&gt; eX)<br \/>\n    <br \/>{ <\/p>\n<p><font size=\"1\">&#160;&#160;&#160; strMsg = &quot;Source [&quot;+eX.Detail.Source+&quot;]&quot;+&quot;\\nReason [&quot;+ eX.Detail.Reason+&quot;] \\nDeatil [&quot;+eX.Detail.Detail+ &quot;]&quot;;<\/font> <\/p>\n<p>} <\/p>\n<p>catch (Exception eX) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160; strMsg = eX.Message; <\/p>\n<p>} <\/p>\n<p><\/font>display error message <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">MessageBox.Show(strMsg);<\/font><\/p>\n<h5>Calling Method DeleteTM, Deleting a cuboid, without a client&#8217;s transaction<\/h5>\n<p>declare and initialize variables.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">int nID = 0;<br \/>\n    <br \/><\/font>Parse input values from controls. <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">int.TryParse(txtID.Text, out nID);<\/font><\/p>\n<p>enclose every thing in a try block<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/><strong>{<\/strong><\/font><\/p>\n<p>create procy object and call the method.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">&#160; CuboidServiceClient objClient = new CuboidServiceClient();<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; objClient.DeleteTM ( nID);<\/font><\/p>\n<p>close try block<br \/>\n  <br \/><strong><font color=\"#0000ff\">}<\/font><\/strong><\/p>\n<p>in case if there is any problem. store the error message from service.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">catch (FaultException&lt;CuboidFaultException&gt; eX)<br \/>\n    <br \/>{ <\/p>\n<p><font size=\"1\">&#160;&#160;&#160; strMsg = &quot;Source [&quot;+eX.Detail.Source+&quot;]&quot;+&quot;\\nReason [&quot;+ eX.Detail.Reason+&quot;] \\nDeatil [&quot;+eX.Detail.Detail+ &quot;]&quot;;<\/font> <\/p>\n<p>} <\/p>\n<p>catch (Exception eX) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160; strMsg = eX.Message; <\/p>\n<p>} <\/p>\n<p><\/font>display error message <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">MessageBox.Show(strMsg);<\/font><\/p>\n<h5>Calling Method AddTA, Adding a cuboid, inside a client&#8217;s transaction<\/h5>\n<p>declare and initialize variables.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">int nID = 0;<br \/>\n    <br \/>double dblLength = 0, dblWidth = 0, dblHeight = 0;<\/font><\/p>\n<p>Parse input values from controls.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">ParseInputs(ref nID, ref dblLength, ref dblWidth, ref dblHeight);<\/font><\/p>\n<p>enclose every thing in a try block<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/><strong>{<\/strong><\/font><\/p>\n<p>execute the service method in client&#8217;s transaction<br \/>\n  <br \/>&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew))<br \/>\n    <br \/>&#160;&#160;&#160; <strong>{<\/strong><\/font><\/p>\n<p>create procy object and call the method.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">&#160; CuboidServiceClient objClient = new CuboidServiceClient();<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; objClient.AddTA ( nID, dblLength, dblWidth, dblHeight);<\/font><\/p>\n<p>Client&#8217;s transacton is complete.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">ts.Complete();<\/font><\/p>\n<p>close client&#8217;s Transaction scope block&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br \/><font color=\"#0000ff\" face=\"Verdana\"><strong>&#160;&#160;&#160; <\/strong><font color=\"#0000ff\"><strong>}<br \/>\n        <br \/><\/strong><\/font><\/font>close try block <\/p>\n<p><strong><font color=\"#0000ff\">}<\/font><\/strong><\/p>\n<p>in case if there is any problem. store the error message from service.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">catch (FaultException&lt;CuboidFaultException&gt; eX)<br \/>\n    <br \/>{ <\/p>\n<p><font size=\"1\">&#160;&#160;&#160; strMsg = &quot;Source [&quot;+eX.Detail.Source+&quot;]&quot;+&quot;\\nReason [&quot;+ eX.Detail.Reason+&quot;] \\nDeatil [&quot;+eX.Detail.Detail+ &quot;]&quot;;<\/font> <\/p>\n<p>} <\/p>\n<p>catch (Exception eX) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160; strMsg = eX.Message; <\/p>\n<p>} <\/p>\n<p><\/font>display error message <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">MessageBox.Show(strMsg);<\/font><\/p>\n<h5>Calling Method AddTA, Adding a cuboid, without a client&#8217;s transaction<\/h5>\n<p>declare and initialize variables.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">int nID = 0;<br \/>\n    <br \/>double dblLength = 0, dblWidth = 0, dblHeight = 0;<\/font><\/p>\n<p>Parse input values from controls.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">ParseInputs(ref nID, ref dblLength, ref dblWidth, ref dblHeight);<\/font><\/p>\n<p>enclose every thing in a try block<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/><strong>{<\/strong><\/font><\/p>\n<p>create proxy object and call the method.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">&#160; CuboidServiceClient objClient = new CuboidServiceClient();<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; objClient.AddTA ( nID, dblLength, dblWidth, dblHeight);<\/font><\/p>\n<p>close try block<br \/>\n  <br \/><strong><font color=\"#0000ff\">}<\/font><\/strong><\/p>\n<p>in case if there is any problem. store the error message from service.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">catch (FaultException&lt;CuboidFaultException&gt; eX)<br \/>\n    <br \/>{ <\/p>\n<p><font size=\"1\">&#160;&#160;&#160; strMsg = &quot;Source [&quot;+eX.Detail.Source+&quot;]&quot;+&quot;\\nReason [&quot;+ eX.Detail.Reason+&quot;] \\nDeatil [&quot;+eX.Detail.Detail+ &quot;]&quot;;<\/font> <\/p>\n<p>} <\/p>\n<p>catch (Exception eX) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160; strMsg = eX.Message; <\/p>\n<p>} <\/p>\n<p><\/font>display error message <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">MessageBox.Show(strMsg);<\/font><\/p>\n<h5>Calling Method UpdateTA, updating a cuboid, inside a client&#8217;s transaction<\/h5>\n<p>declare and initialize variables.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">int nID = 0;<br \/>\n    <br \/>double dblLength = 0, dblWidth = 0, dblHeight = 0;<\/font><\/p>\n<p>Parse input values from controls.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">ParseInputs(ref nID, ref dblLength, ref dblWidth, ref dblHeight);<\/font><\/p>\n<p>enclose every thing in a try block<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/><strong>{<\/strong><\/font><\/p>\n<p>execute the service method in client&#8217;s transaction<br \/>\n  <br \/>&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew))<br \/>\n    <br \/>&#160;&#160;&#160; <strong>{<\/strong><\/font><\/p>\n<p>create procy object and call the method.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">&#160; CuboidServiceClient objClient = new CuboidServiceClient();<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; objClient.UpdateTA ( nID, dblLength, dblWidth, dblHeight);<\/font><\/p>\n<p><strong>Note: <\/strong>same method is called for <strong>Updating a cuboid<\/strong>, <strong>passing first parameter as false<\/strong>.<\/p>\n<p>Client&#8217;s transacton is complete.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">ts.Complete();<\/font><\/p>\n<p>close client&#8217;s Transaction scope block&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br \/><font color=\"#0000ff\" face=\"Verdana\"><strong>&#160;&#160;&#160; <\/strong><font color=\"#0000ff\"><strong>}<br \/>\n        <br \/><\/strong><\/font><\/font>close try block <\/p>\n<p><strong><font color=\"#0000ff\">}<\/font><\/strong><\/p>\n<p>in case if there is any problem. store the error message from service.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">catch (FaultException&lt;CuboidFaultException&gt; eX)<br \/>\n    <br \/>{ <\/p>\n<p><font size=\"1\">&#160;&#160;&#160; strMsg = &quot;Source [&quot;+eX.Detail.Source+&quot;]&quot;+&quot;\\nReason [&quot;+ eX.Detail.Reason+&quot;] \\nDeatil [&quot;+eX.Detail.Detail+ &quot;]&quot;;<\/font> <\/p>\n<p>} <\/p>\n<p>catch (Exception eX) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160; strMsg = eX.Message; <\/p>\n<p>} <\/p>\n<p><\/font>display error message <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">MessageBox.Show(strMsg);<\/font><\/p>\n<h5>Calling Method UpdateTA, Updating a cuboid, without a client&#8217;s transaction<\/h5>\n<p>declare and initialize variables.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">int nID = 0;<br \/>\n    <br \/>double dblLength = 0, dblWidth = 0, dblHeight = 0;<\/font><\/p>\n<p>Parse input values from controls.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">ParseInputs(ref nID, ref dblLength, ref dblWidth, ref dblHeight);<\/font><\/p>\n<p>enclose every thing in a try block<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/><strong>{<\/strong><\/font><\/p>\n<p>create proxy object and call the method.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">&#160; CuboidServiceClient objClient = new CuboidServiceClient();<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; objClient.UpdatingTA (&#160; nID, dblLength, dblWidth, dblHeight);<\/font><\/p>\n<p>close try block<br \/>\n  <br \/><strong><font color=\"#0000ff\">}<\/font><\/strong><\/p>\n<p>in case if there is any problem. store the error message from service.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">catch (FaultException&lt;CuboidFaultException&gt; eX)<br \/>\n    <br \/>{ <\/p>\n<p><font size=\"1\">&#160;&#160;&#160; strMsg = &quot;Source [&quot;+eX.Detail.Source+&quot;]&quot;+&quot;\\nReason [&quot;+ eX.Detail.Reason+&quot;] \\nDeatil [&quot;+eX.Detail.Detail+ &quot;]&quot;;<\/font> <\/p>\n<p>} <\/p>\n<p>catch (Exception eX) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160; strMsg = eX.Message; <\/p>\n<p>} <\/p>\n<p><\/font>display error message <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">MessageBox.Show(strMsg);<\/font><\/p>\n<blockquote><\/blockquote>\n<h5>Calling Method DeleteTA, Adding a cuboid, inside a client&#8217;s transaction<\/h5>\n<p>declare and initialize variables.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">int nID = 0;<br \/>\n    <br \/><\/font>Parse input values from controls. <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">int.TryParse(txtID.Text, out nID);<\/font><\/p>\n<p>enclose every thing in a try block<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/><strong>{<\/strong><\/font><\/p>\n<p>execute the service method in client&#8217;s transaction<br \/>\n  <br \/>&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">using (TransactionScope ts = new TransactionScope(TransactionScopeOption.RequiresNew))<br \/>\n    <br \/>&#160;&#160;&#160; <strong>{<\/strong><\/font><\/p>\n<p>create procy object and call the method.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">&#160; CuboidServiceClient objClient = new CuboidServiceClient();<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; objClient.DeleteTA ( nID);<\/font><\/p>\n<p>Client&#8217;s transacton is complete.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">ts.Complete();<\/font><\/p>\n<p>close client&#8217;s Transaction scope block&#160;&#160;&#160;&#160;&#160;&#160;&#160; <br \/><font color=\"#0000ff\" face=\"Verdana\"><strong>&#160;&#160;&#160; <\/strong><font color=\"#0000ff\"><strong>}<br \/>\n        <br \/><\/strong><\/font><\/font>close try block <\/p>\n<p><strong><font color=\"#0000ff\">}<\/font><\/strong><\/p>\n<p>in case if there is any problem. store the error message from service.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">catch (FaultException&lt;CuboidFaultException&gt; eX)<br \/>\n    <br \/>{ <\/p>\n<p><font size=\"1\">&#160;&#160;&#160; strMsg = &quot;Source [&quot;+eX.Detail.Source+&quot;]&quot;+&quot;\\nReason [&quot;+ eX.Detail.Reason+&quot;] \\nDeatil [&quot;+eX.Detail.Detail+ &quot;]&quot;;<\/font> <\/p>\n<p>} <\/p>\n<p>catch (Exception eX) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160; strMsg = eX.Message; <\/p>\n<p>} <\/p>\n<p><\/font>display error message <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">MessageBox.Show(strMsg);<\/font><\/p>\n<h5>Calling Method DeleteTA, Deleting a cuboid, without a client&#8217;s transaction<\/h5>\n<p>declare and initialize variables.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">int nID = 0;<br \/>\n    <br \/><\/font>Parse input values from controls. <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">int.TryParse(txtID.Text, out nID);<\/font><\/p>\n<p>enclose every thing in a try block<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">try<br \/>\n    <br \/><strong>{<\/strong><\/font><\/p>\n<p>create procy object and call the method.<br \/>\n  <br \/>&#160;&#160;&#160;&#160;&#160; <font color=\"#0000ff\" face=\"Verdana\">&#160; CuboidServiceClient objClient = new CuboidServiceClient();<br \/>\n    <br \/>&#160;&#160;&#160;&#160;&#160;&#160;&#160; objClient.DeleteTA ( nID);<\/font><\/p>\n<p>close try block<br \/>\n  <br \/><strong><font color=\"#0000ff\">}<\/font><\/strong><\/p>\n<p>in case if there is any problem. store the error message from service.<br \/>\n  <br \/><font color=\"#0000ff\" face=\"Verdana\">catch (FaultException&lt;CuboidFaultException&gt; eX)<br \/>\n    <br \/>{ <\/p>\n<p><font size=\"1\">&#160;&#160;&#160; strMsg = &quot;Source [&quot;+eX.Detail.Source+&quot;]&quot;+&quot;\\nReason [&quot;+ eX.Detail.Reason+&quot;] \\nDeatil [&quot;+eX.Detail.Detail+ &quot;]&quot;;<\/font> <\/p>\n<p>} <\/p>\n<p>catch (Exception eX) <\/p>\n<p>{ <\/p>\n<p>&#160;&#160;&#160; strMsg = eX.Message; <\/p>\n<p>} <\/p>\n<p><\/font>display error message <\/p>\n<p><font color=\"#0000ff\" face=\"Verdana\">MessageBox.Show(strMsg);<\/font><\/p>\n<h2>Output<\/h2>\n<h3>Calling Method GetList<\/h3>\n<p>&#160;<\/p>\n<table cellspacing=\"0\" cellpadding=\"2\" width=\"681\" border=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"103\"><strong><font size=\"2\">Calling Method<\/font><\/strong><\/td>\n<td valign=\"top\" width=\"109\"><strong><font size=\"2\">Client Transaction<\/font><\/strong><\/td>\n<td valign=\"top\" width=\"467\"><font size=\"5\"><\/font><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"103\"><font size=\"5\">GetList<\/font><\/td>\n<td valign=\"top\" width=\"109\"><font size=\"5\">N\/A<\/font><\/td>\n<td valign=\"top\" width=\"467\"><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/getlistoutput.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"GetListOutput\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"GetListOutput\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/getlistoutput_thumb.jpg\" width=\"459\" height=\"223\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"103\"><font size=\"5\">&#160; <\/p>\n<p>AddTM<\/font><\/td>\n<td valign=\"top\" width=\"109\"><font size=\"5\"><\/p>\n<p>Yes<\/font><\/td>\n<td valign=\"top\" width=\"467\"><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"image\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image_thumb.png\" width=\"280\" height=\"125\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"103\">&#160;<\/td>\n<td valign=\"top\" width=\"109\">&#160;<\/td>\n<td valign=\"top\" width=\"467\">&#160;<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"103\"><font size=\"5\">AddTM<\/font><\/td>\n<td valign=\"top\" width=\"109\"><font size=\"5\">No<\/font><\/td>\n<td valign=\"top\" width=\"467\"><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image1.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"image\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image_thumb1.png\" width=\"276\" height=\"127\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"103\"><font size=\"5\"><br \/>\n            <br \/>AddTA<\/font><\/td>\n<td valign=\"top\" width=\"109\"><font size=\"5\">Yes<\/font><\/td>\n<td valign=\"top\" width=\"467\"><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image22.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"image\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image_thumb22.png\" width=\"277\" height=\"126\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"103\"><font size=\"5\">AddTA<\/font><\/td>\n<td valign=\"top\" width=\"109\"><font size=\"5\">No<\/font><\/td>\n<td valign=\"top\" width=\"467\"><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image19.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"image\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image_thumb19.png\" width=\"277\" height=\"116\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"103\"><font size=\"5\">UpdateTM<\/font><\/td>\n<td valign=\"top\" width=\"109\"><font size=\"5\">Yes<\/font><\/td>\n<td valign=\"top\" width=\"467\"><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image4.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"image\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image_thumb4.png\" width=\"275\" height=\"125\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"103\"><font size=\"5\">UpdateTM<\/font><\/td>\n<td valign=\"top\" width=\"109\"><font size=\"5\">No<\/font><\/td>\n<td valign=\"top\" width=\"467\"><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image20.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"image\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image_thumb20.png\" width=\"280\" height=\"132\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"103\"><font size=\"5\">UpdateTA<\/font><\/td>\n<td valign=\"top\" width=\"109\"><font size=\"5\">Yes<\/font><\/td>\n<td valign=\"top\" width=\"467\"><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image23.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"image\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image_thumb23.png\" width=\"282\" height=\"126\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"103\"><font size=\"5\">UpdateTA<\/font><\/td>\n<td valign=\"top\" width=\"109\"><font size=\"5\">No<\/font><\/td>\n<td valign=\"top\" width=\"467\"><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image24.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"image\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image_thumb24.png\" width=\"282\" height=\"127\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"103\"><font size=\"5\">DeleteTM<\/font><\/td>\n<td valign=\"top\" width=\"109\"><font size=\"5\">Yes<\/font><\/td>\n<td valign=\"top\" width=\"467\"><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image8.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"image\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image_thumb8.png\" width=\"282\" height=\"133\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"103\"><font size=\"5\">DeleteTM<\/font><\/td>\n<td valign=\"top\" width=\"109\"><font size=\"5\">No<\/font><\/td>\n<td valign=\"top\" width=\"467\"><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image25.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"image\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image_thumb25.png\" width=\"282\" height=\"131\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"103\"><font size=\"5\">DeleteTA<\/font><\/td>\n<td valign=\"top\" width=\"109\"><font size=\"5\">Yes<\/font><\/td>\n<td valign=\"top\" width=\"467\"><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image10.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"image\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image_thumb10.png\" width=\"281\" height=\"124\" \/><\/a><\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"103\"><font size=\"5\">DeleteTA<\/font><\/td>\n<td valign=\"top\" width=\"109\"><font size=\"5\">No<\/font><\/td>\n<td valign=\"top\" width=\"467\"><a href=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image11.png\"><img loading=\"lazy\" decoding=\"async\" title=\"image\" style=\"background-image:none;padding-top:0;padding-left:0;display:inline;padding-right:0;border-width:0;\" border=\"0\" alt=\"image\" src=\"http:\/\/praveenkatiyar.wordpress.com\/wp-content\/uploads\/2013\/11\/image_thumb11.png\" width=\"283\" height=\"131\" \/><\/a><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>Introduction A Transaction is a set of complex operations, where failure of any single operation causes entire set to fail. A successful transaction, that transfers the system from one consistent state (A) to another consistent state (B), called a committed transaction. &#160; Transaction Properties When you write a transactional service, one must abide by four&hellip; <a class=\"more-link\" href=\"https:\/\/praveenkatiyar.in\/blog\/index.php\/2013\/11\/12\/understanding-transactions-in-wcf\/\">Continue reading <span class=\"screen-reader-text\">Understanding Transactions in WCF<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[17,33],"class_list":["post-369","post","type-post","status-publish","format-standard","hentry","category-soa","tag-net","tag-wcf","entry"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/posts\/369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=369"}],"version-history":[{"count":0,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/posts\/369\/revisions"}],"wp:attachment":[{"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/praveenkatiyar.in\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}