B.10. Use Distributed Transactions Only If You Need Them

It's very easy to use distributed transactions (also known as Enterprise Services, COM+, and DTC transactions) within a Web method. Simply set the WebMethod-Attribute's TransactionOption property to RequiresNew and you're set. This is another example of “just because you can doesn't mean you should.” Please understand that distributed transactions are designed for specific scenarios and are not intended to replace TSQL or ADO.NET transactions. Each has its role and the scenarios where each makes sense. See Chapter 6 for a discussion of when distributed transactions make sense and a link to an MSDN article that compares the performance of the three transaction control mechanisms.

Get Real World XML Web Services: For VB and VB .NET Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.