Hi Jorge,
There is no problem with creating a transaction from a web service,
commiting it or rolling it back. I am doing this using a database class I
have created. The constructor of this class has a parameter for stating a
transaction. I am using the "using" keyword when creating a new instance of
that class. Whenever this object goes out of scope, I have code in the
Dispose method to commit ot rollback the transaction based on a flag that
tells me if the statement executes successfully or not.
Something like that:
protected virtual void Dispose(bool disposing)
{
if(!is_disposed)
{
if(disposing)
{
}
if(m_bStartTransaction == true)
{
myTrans = m_SQLCommand.Transaction;
if (m_bError == true)
{
myTrans.Rollback();
}
else
{
myTrans.Commit();
}
}
m_SQLConnection.Close();
}
this.is_disposed = true;
}
--function call inside service1.asmx.cs
try
{
using(DatabaseClass dbObj = new DatabaseClass(m_strConnectionString,
true,"prApp_IsUserOwnerOfAnyPTG",false))
{
dbObj.BindStringParameter(strLANID,"@User_LAN_ID") ;
dbObj.BindStringParameter(strObjectName,"@Frmwk_co de");
nCount = dbObj.BindStoredProcedureOutputIntParameterAndExec ute("@nCount");
}
}
catch (SoapException se)
{
throw(se);
}
catch(SqlException mySqlEx)
{
strErrorMessage = mySqlEx.Source + ":" + mySqlEx.Message;
throwException(strErrorMessage,"",mySqlEx.Number,m _strModuleName,m_strClassName,
strFunctionName, 1243, 2, "Failed to update the database. Please contact the
system administrator");
}
catch(Exception myException)
{
strErrorMessage = myException.Source + ":" + myException.Message;
throwException(strErrorMessage, "", 0, m_strModuleName, m_strClassName,
strFunctionName, 1243, 2, "Failed to update the database. Please contact the
system administrator");
}
finally
{
}
Your intention is to use two separate web services to work in the context of
the same transaction in the database?
Eugen
"mo*********@hotmail.com" wrote:
Hello Eugen,
i got the serialization and deserialization to work Thanks.
Now i need to implement a transaction. i think i will not be able to
accomplish the following using web services.
Scenario:
the code behind web_page_1 Calls webservice_1 and starts transaction.
the results of webservice_1 are used by webservice_2.
if THERE_IS_AN_ERROR then
rollback transaction
else
commit transaction
the results of webservice2 are displayed in web_page_2.
thanks for any input.
Jorge