{"id":32330,"date":"2016-02-08T11:47:03","date_gmt":"2016-02-08T06:17:03","guid":{"rendered":"https:\/\/2thenew.xyz\/blog\/?p=32330"},"modified":"2016-02-09T11:10:12","modified_gmt":"2016-02-09T05:40:12","slug":"enable-transaction-in-wcf","status":"publish","type":"post","link":"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/","title":{"rendered":"Enable Transaction in WCF"},"content":{"rendered":"<p>Transaction in WCF is a set of operations or logical unit of work comprising of activities. Here, if a single operation fails, then all operation fails automatically.<\/p>\n<p style=\"background: white\"><strong><span style=\"font-size: 9.0pt;font-family: 'Verdana','sans-serif';color: #444444;background: white\">We will follow these steps for enable transaction in WCF :<\/span><\/strong><\/p>\n<p><strong>Step 1:-<\/strong> Add\u00a0 Transactions\u00a0namespace in \u00a0WCF Service project.<\/p>\n<p>Using System.Transaction;<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Step 2:-<\/strong> Set\u00a0TransactionFlow\u00a0property of the OperationContract attribute\u00a0Mandatory.<\/p>\n<p>options for TransactionFlow are as follows:<br \/>\na. Mandatory \u2013 transaction must be flowed<br \/>\nb. Allowed \u2013 transaction may be flowed<br \/>\nc. Not Allowed \u2013 transaction is not flowed<\/p>\n<p>Our WCF service contract:<\/p>\n<p>[TransactionFlow(TransactionFlowOptions.Mandatory]<br \/>\nvoid Showinfo();<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Step 3:-<\/strong> Now, set the\u00a0OperationBehavior\u00a0attribute for the method.<\/p>\n<p>[OperationBehavior(TransactionScopeRequired=true, TransactionAutoComplete=true)]<br \/>\nvoid showinfo()<br \/>\n{<br \/>\n}<\/p>\n<p>&nbsp;<\/p>\n<p>TransactionScopeRequired\u00a0= true (it can only be called in a transaction)<br \/>\nTransactionAutoComplete\u00a0= true (if the operation completes successfully, transaction will be committed.)<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Step 4:-<\/strong> Enable Transactions for WCF\u00a0Binding being used.<br \/>\nFor Example, In our configuration file (Web.config) bindings will be as follows:<\/p>\n<p>&lt;bindings&gt;<\/p>\n<p>&lt;wsHttpBinding&gt;<br \/>\n&lt;binding name=\u201dhttpBinding\u201d\u00a0\u00a0transactionFlow=\u201dtrue\u201d\u00a0\/&gt;<br \/>\nwsHttpBinding &gt;<br \/>\nNote:- That we must choose a binding that supports transactions As Follow<\/p>\n<ul>\n<li>netTcpBinding<\/li>\n<li>netNamedPipeBinding<\/li>\n<li>wsHttpBinding<\/li>\n<li>wsDualHttpBinding<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Step 5:-<\/strong> Need to start the transaction from client side<\/p>\n<p>Import namspance transaction in WCF<\/p>\n<p>using System.Transaction;<br \/>\nUsing(TransactionScope \u00a0transScope = new TransactionScope())<br \/>\n{<br \/>\nIMyServiceClient client = new IMyServiceClient();<br \/>\nclient.showinfo();<\/p>\n<p>transScope.complete();<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Transaction in WCF is a set of operations or logical unit of work comprising of activities. Here, if a single operation fails, then all operation fails automatically. We will follow these steps for enable transaction in WCF : Step 1:- Add\u00a0 Transactions\u00a0namespace in \u00a0WCF Service project. Using System.Transaction; &nbsp; Step 2:- Set\u00a0TransactionFlow\u00a0property of the OperationContract [&hellip;]<\/p>\n","protected":false},"author":855,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":1,"footnotes":""},"categories":[1],"tags":[1440,3064],"class_list":["post-32330","post","type-post","status-publish","format-standard","hentry","category-technology","tag-asp-net","tag-wcf"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Transaction in WCF is a set of operations or logical unit of work comprising of activities. Here, if a single operation fails, then all operation fails automatically. We will follow these steps for enable transaction in WCF : Step 1:- Add Transactions namespace in WCF Service project. Using System.Transaction; Step 2:- Set TransactionFlow property of the OperationContract\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Mohit Kumar\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"TO THE NEW BLOG\" \/>\n\t\t<meta property=\"og:type\" content=\"blog\" \/>\n\t\t<meta property=\"og:title\" content=\"Enable Transaction in WCF | TO THE NEW Blog\" \/>\n\t\t<meta property=\"og:description\" content=\"Transaction in WCF is a set of operations or logical unit of work comprising of activities. Here, if a single operation fails, then all operation fails automatically. We will follow these steps for enable transaction in WCF : Step 1:- Add Transactions namespace in WCF Service project. Using System.Transaction; Step 2:- Set TransactionFlow property of the OperationContract\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/\" \/>\n\t\t<meta property=\"og:image\" content=\"https:\/\/2thenew.xyz\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta property=\"og:image:secure_url\" content=\"https:\/\/2thenew.xyz\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:site\" content=\"@tothenew\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Enable Transaction in WCF | TO THE NEW Blog\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Transaction in WCF is a set of operations or logical unit of work comprising of activities. Here, if a single operation fails, then all operation fails automatically. We will follow these steps for enable transaction in WCF : Step 1:- Add Transactions namespace in WCF Service project. Using System.Transaction; Step 2:- Set TransactionFlow property of the OperationContract\" \/>\n\t\t<meta name=\"twitter:image\" content=\"https:\/\/2thenew.xyz\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enable-transaction-in-wcf\\\/#article\",\"name\":\"Enable Transaction in WCF | TO THE NEW Blog\",\"headline\":\"Enable Transaction in WCF\",\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/mohit-kumar1\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"},\"datePublished\":\"2016-02-08T11:47:03+05:30\",\"dateModified\":\"2016-02-09T11:10:12+05:30\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enable-transaction-in-wcf\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enable-transaction-in-wcf\\\/#webpage\"},\"articleSection\":\"Technology, asp.net, WCF\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enable-transaction-in-wcf\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"position\":2,\"name\":\"Technology\",\"item\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enable-transaction-in-wcf\\\/#listItem\",\"name\":\"Enable Transaction in WCF\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enable-transaction-in-wcf\\\/#listItem\",\"position\":3,\"name\":\"Enable Transaction in WCF\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/category\\\/technology\\\/#listItem\",\"name\":\"Technology\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\",\"name\":\"TO THE NEW Blog\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/mohit-kumar1\\\/#author\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/mohit-kumar1\\\/\",\"name\":\"Mohit Kumar\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enable-transaction-in-wcf\\\/#authorImage\",\"url\":\"https:\\\/\\\/newersworld-sf-static.tothenew.net\\\/prod\\\/profilePicFolder\\\/21c535ef-49a1-438f-a7e0-613e190f0829_mohit.kumar1@tothenew.com.jpg\",\"width\":96,\"height\":96,\"caption\":\"Mohit Kumar\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enable-transaction-in-wcf\\\/#webpage\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enable-transaction-in-wcf\\\/\",\"name\":\"Enable Transaction in WCF | TO THE NEW Blog\",\"description\":\"Transaction in WCF is a set of operations or logical unit of work comprising of activities. Here, if a single operation fails, then all operation fails automatically. We will follow these steps for enable transaction in WCF : Step 1:- Add Transactions namespace in WCF Service project. Using System.Transaction; Step 2:- Set TransactionFlow property of the OperationContract\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/enable-transaction-in-wcf\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/mohit-kumar1\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/author\\\/mohit-kumar1\\\/#author\"},\"datePublished\":\"2016-02-08T11:47:03+05:30\",\"dateModified\":\"2016-02-09T11:10:12+05:30\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/\",\"name\":\"TO THE NEW Blog\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.tothenew.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Enable Transaction in WCF | TO THE NEW Blog","description":"Transaction in WCF is a set of operations or logical unit of work comprising of activities. Here, if a single operation fails, then all operation fails automatically. We will follow these steps for enable transaction in WCF : Step 1:- Add Transactions namespace in WCF Service project. Using System.Transaction; Step 2:- Set TransactionFlow property of the OperationContract","canonical_url":"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/#article","name":"Enable Transaction in WCF | TO THE NEW Blog","headline":"Enable Transaction in WCF","author":{"@id":"https:\/\/2thenew.xyz\/blog\/author\/mohit-kumar1\/#author"},"publisher":{"@id":"https:\/\/2thenew.xyz\/blog\/#organization"},"datePublished":"2016-02-08T11:47:03+05:30","dateModified":"2016-02-09T11:10:12+05:30","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/#webpage"},"isPartOf":{"@id":"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/#webpage"},"articleSection":"Technology, asp.net, WCF"},{"@type":"BreadcrumbList","@id":"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/2thenew.xyz\/blog#listItem","position":1,"name":"Home","item":"https:\/\/2thenew.xyz\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/2thenew.xyz\/blog\/category\/technology\/#listItem","name":"Technology"}},{"@type":"ListItem","@id":"https:\/\/2thenew.xyz\/blog\/category\/technology\/#listItem","position":2,"name":"Technology","item":"https:\/\/2thenew.xyz\/blog\/category\/technology\/","nextItem":{"@type":"ListItem","@id":"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/#listItem","name":"Enable Transaction in WCF"},"previousItem":{"@type":"ListItem","@id":"https:\/\/2thenew.xyz\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/#listItem","position":3,"name":"Enable Transaction in WCF","previousItem":{"@type":"ListItem","@id":"https:\/\/2thenew.xyz\/blog\/category\/technology\/#listItem","name":"Technology"}}]},{"@type":"Organization","@id":"https:\/\/2thenew.xyz\/blog\/#organization","name":"TO THE NEW Blog","url":"https:\/\/2thenew.xyz\/blog\/"},{"@type":"Person","@id":"https:\/\/2thenew.xyz\/blog\/author\/mohit-kumar1\/#author","url":"https:\/\/2thenew.xyz\/blog\/author\/mohit-kumar1\/","name":"Mohit Kumar","image":{"@type":"ImageObject","@id":"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/#authorImage","url":"https:\/\/newersworld-sf-static.tothenew.net\/prod\/profilePicFolder\/21c535ef-49a1-438f-a7e0-613e190f0829_mohit.kumar1@tothenew.com.jpg","width":96,"height":96,"caption":"Mohit Kumar"}},{"@type":"WebPage","@id":"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/#webpage","url":"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/","name":"Enable Transaction in WCF | TO THE NEW Blog","description":"Transaction in WCF is a set of operations or logical unit of work comprising of activities. Here, if a single operation fails, then all operation fails automatically. We will follow these steps for enable transaction in WCF : Step 1:- Add Transactions namespace in WCF Service project. Using System.Transaction; Step 2:- Set TransactionFlow property of the OperationContract","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/2thenew.xyz\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/#breadcrumblist"},"author":{"@id":"https:\/\/2thenew.xyz\/blog\/author\/mohit-kumar1\/#author"},"creator":{"@id":"https:\/\/2thenew.xyz\/blog\/author\/mohit-kumar1\/#author"},"datePublished":"2016-02-08T11:47:03+05:30","dateModified":"2016-02-09T11:10:12+05:30"},{"@type":"WebSite","@id":"https:\/\/2thenew.xyz\/blog\/#website","url":"https:\/\/2thenew.xyz\/blog\/","name":"TO THE NEW Blog","inLanguage":"en-US","publisher":{"@id":"https:\/\/2thenew.xyz\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"TO THE NEW BLOG","og:type":"blog","og:title":"Enable Transaction in WCF | TO THE NEW Blog","og:description":"Transaction in WCF is a set of operations or logical unit of work comprising of activities. Here, if a single operation fails, then all operation fails automatically. We will follow these steps for enable transaction in WCF : Step 1:- Add Transactions namespace in WCF Service project. Using System.Transaction; Step 2:- Set TransactionFlow property of the OperationContract","og:url":"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/","og:image":"https:\/\/2thenew.xyz\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","og:image:secure_url":"https:\/\/2thenew.xyz\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png","twitter:card":"summary","twitter:site":"@tothenew","twitter:title":"Enable Transaction in WCF | TO THE NEW Blog","twitter:description":"Transaction in WCF is a set of operations or logical unit of work comprising of activities. Here, if a single operation fails, then all operation fails automatically. We will follow these steps for enable transaction in WCF : Step 1:- Add Transactions namespace in WCF Service project. Using System.Transaction; Step 2:- Set TransactionFlow property of the OperationContract","twitter:image":"https:\/\/2thenew.xyz\/blog\/wp-content\/themes\/ttn\/images\/social-logo.png"},"aioseo_meta_data":{"post_id":"32330","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":"","og_description":"","og_object_type":"blog","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":"","og_article_tags":"","twitter_use_og":false,"twitter_card":"summary","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2021-04-30 06:13:25","updated":"2024-02-29 09:48:57","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/2thenew.xyz\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/2thenew.xyz\/blog\/category\/technology\/\" title=\"Technology\">Technology<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tEnable Transaction in WCF\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/2thenew.xyz\/blog"},{"label":"Technology","link":"https:\/\/2thenew.xyz\/blog\/category\/technology\/"},{"label":"Enable Transaction in WCF","link":"https:\/\/2thenew.xyz\/blog\/enable-transaction-in-wcf\/"}],"_links":{"self":[{"href":"https:\/\/2thenew.xyz\/blog\/wp-json\/wp\/v2\/posts\/32330","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/2thenew.xyz\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/2thenew.xyz\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/2thenew.xyz\/blog\/wp-json\/wp\/v2\/users\/855"}],"replies":[{"embeddable":true,"href":"https:\/\/2thenew.xyz\/blog\/wp-json\/wp\/v2\/comments?post=32330"}],"version-history":[{"count":0,"href":"https:\/\/2thenew.xyz\/blog\/wp-json\/wp\/v2\/posts\/32330\/revisions"}],"wp:attachment":[{"href":"https:\/\/2thenew.xyz\/blog\/wp-json\/wp\/v2\/media?parent=32330"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/2thenew.xyz\/blog\/wp-json\/wp\/v2\/categories?post=32330"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/2thenew.xyz\/blog\/wp-json\/wp\/v2\/tags?post=32330"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}