Transactions

Team-Fly    

 
.NET and COM Interoperability Handbook, The
By Alan Gordon
Table of Contents
Chapter Ten.  XML Web Services

Transactions

The .NET Framework provides an integration between XML Web services and Microsoft DTC distributed transactions. You can cause a method that is exposed using the WebMethod attribute to start a DTC transaction using the Transaction property of the WebMethod attribute.

  [WebMethod(TransactionOption=TransactionOption.Required)]  public DataSet GetBookByTitle(string title) {     DataSet ds;     SqlCommand cmd;     SqlDataAdapter dsCmd;     SqlParameter param;     SqlConnection conn;     ds=new DataSet();     conn=new SqlConnection(         "user id=sa;password=;initial         catalog=DevDotNet;data source=localhost");     cmd=new SqlCommand("GetBooksByTitle",conn);     cmd.CommandType=CommandType.StoredProcedure;     param=cmd.Parameters.Add(new         SqlParameter("@Title",SqlDbType.NVarChar,255));     param.Value=title;     param.Direction=ParameterDirection.Input;     try     {     // Open the connection and execute the Command         conn.Open();         dsCmd=new SqlDataAdapter();         dsCmd.SelectCommand =cmd;         dsCmd.Fill(ds,"Titles");         return ds;     }     catch (Exception err)     {     // An error occurred, pass the exception up       throw err;     }     finally     {     // Close the Connection         if (conn.State == ConnectionState.Open)             conn.Close();     } } 

Using transactions in this manner will only coordinate a transaction involving multiple resource managers (say a database and an MSMQ message queue) from a single Web service. Microsoft, IBM, and BEA Systems are currently working on a specification called Web Services Transaction (WS-Transaction) that will allow you to coordinate a transaction between multiple XML Web services. See the following URL for more information: msdn.microsoft.com/library/default.asp?url=/library/en-us/dnglobspec/html/ws-transaction.asp.


Team-Fly    
Top
 


. Net and COM Interoperability Handbook
The .NET and COM Interoperability Handbook (Integrated .Net)
ISBN: 013046130X
EAN: 2147483647
Year: 2002
Pages: 119
Authors: Alan Gordon

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