473,395 Members | 1,978 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Calling ContextUtil SetAbort or SetComplete explicitly from Web Me

I know that "a new transaction" can be started from a web method by simply
using an attribute
"[System.Web.Services.WebMethod(TransactionOption=Tr ansactionOption.RequiresNew)]

I guess the assumption here is that if the web method returns normally, the
transaction is automatically committed. Likewsie, if an exception throws, the
transaction is automatically aborted.

However, there are business scenarios under which I want to explicitly abort
the transaction in my web method. I heard this can be achieved with
"ContextUtil.SetAbort()". Since the web method is in a class that derives
from "System.Web.Services.WebServiceand" and that the same class cannot also
be derived from ServicedComponent (no multiple class inheritance supported in
..NET), is this possible? Maybe this is not relevant but when I call
ContextUtil.SetAbort() explicitly, I get an error "There is no MTS object
context".

I'd really appreciate help.

Here's my code (I get the "No MTS" error after the first occurence of
ContextUtil.SetAbort() in this code)

public class Gateway : System.Web.Services.WebService
{
public Gateway()
{
InitializeComponent();
}

[WebMethod(TransactionOption = TransactionOption.RequiresNew)]
[TraceExtensionAttribute(Filename="InsertCRPReportW ithTransaction.log")]
private XmlNode InsertCRPReportWithTransaction(string
strXMLParameters,string strCRPPivotalSystemName,string strCRPReportASR,string
strCRPReportASRMethodName)
{
const string WEBMETHODNAME="InsertCRPReportWithTransaction";
const string CLIENT_FAULTCODE="CLIENT";
XmlNode ndToReturn = null;
string strXMLReturnASR=string.Empty;
try
{
//call a work-horse component that does DB writes
if (strStatus=="FAILURE")
{
//Error occurred after this statement - There is no MTS object
context
ContextUtil.SetAbort();
}
ContextUtil.SetComplete();
}
//Various Catch blocks here
catch (XmlException xmlEx)
{
ContextUtil.SetAbort();
//release resources etc.
}
catch (PivotalWS.PIVOTALWSException exPIVOTALWS)
{
ContextUtil.SetAbort();
//release resources etc.
}
catch (Exception ex)
{
ContextUtil.SetAbort();
//release resources etc.
}
}

Thanks for your help.

Nov 23 '05 #1
0 1702

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Midas | last post by:
In my "main" code, I would like to create two new objects (ObjectA and ObjectB) and have ObjectA directly call an ObjectB method. In order to do this I believe ObjectA must hold a reference to...
4
by: Martin Maney | last post by:
I've been to the cookbook (both forms, since they're sometimes usefully different), but that gave rise to more questions than answers. Heck, let me pull some of them up while I'm at it. ...
1
by: Stephen Kellett | last post by:
Hello everyone, I'm trying to do something in C calling Python and its failing. I'd be grateful if you could take a look and hopefully you have an answer. What I'm trying to do is determine...
0
by: billj2 | last post by:
Should I use rollback and commit in my stored procs when I am using serabort and setcomplete in my COM+ middle tier? I took out the setcomplete and setabort from the COM+ middle tier and the...
2
by: Eric Cadwell | last post by:
Does anyone know of any case in which the CLR explicitly calls GC.Collect? I have a form that when unloaded, shows # of induced GC's incremented by 5. This is killing performance. I have a...
5
by: Dave Veeneman | last post by:
I'm using inheritance more than I used to, and I find myself calling a lot of base class methods. I generally call a base method from a dreived class like this: this.MyMethod(); I'm finding...
6
by: daveb | last post by:
I'm trying to write some code that calls the constructors of STL containers explicitly, and I can't get it to compile. A sample program is below. One compiler complains about the last two lines...
7
by: engaarea | last post by:
hi all, What are the circumstances in which one would have to call a destructor explicitly. Regards 5
9
by: =?Utf-8?B?Q01hcnRpbg==?= | last post by:
How do I call the "buttonRun_Click()" method in C#? I can do this so easily in VB but I have yet to figuere out how in C#. I keep getting errors. Thanks CM
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.