Transactional Web Services


Individual Web methods in Web services can participate in a transaction. Transactional Web services enable performing a series of steps as a unit of work (see Listing 9.5). Transactional Web methods can invoke other .NET Enterprise components and/or invoke transactional resources such as relational databases, Microsoft Message Queuing (MSMQ), Host Integration Server, and so on using the Distributed Transaction Coordinator (DTC). This allows the entire transaction to occur as a unit of work. One limitation imposed on Web services, however, is that Web methods can participate in a transaction as the initial root of a new transaction ( RequiresNew TransactionOption ). Also, Web services methods cannot be chained together within a single transaction.

Listing 9.5 Transactional Web Services
 <%@ WebService Language="C#" Class="hks.TxnService"%> using System; using System.Web; using System.Web.Services; using System.EnterpriseServices; namespace hks {    [WebService(Namespace="http://www.hiteshseth.com/webservices")]    public class TxnService    {       [WebMethod(Description="Transactional Web Method",        TransactionOption=TransactionOption.RequiresNew)]       public IAsyncResult(String name, String identifier, String type)       {          ...          // All actions performed in this service will          // execute as part of an ACID Transaction Context          // Any exceptions will result in a automatic rollback.       }    } } 


Microsoft.Net Kick Start
Microsoft .NET Kick Start
ISBN: 0672325748
EAN: 2147483647
Year: 2003
Pages: 195
Authors: Hitesh Seth

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net