I have several transactions to insert form data into oracle table.
if (InsertQuarterly() == true)
{
InsertMeasures();
}
And if insertmeasures procedure executed successfully then I have to call another procedure.
Within InsertQuarterly I am calling a webservice method to Insert data into Oracle table
for eg
sOUT = ws_service.InsertQuarterly(txtQ2dTarget.Text, txtQ3dTarget.Text)
and for InsertMeasures I am calling webservice
sOUT = ws_service.InsertMeasures(txtachieveGold.Text, txtachieveDia.Text)
My problem is if InsertQuarterly executed successfully but if InsertMeasures failed during transaction then I want to rollback InsertQuarterly also.
How can I achieve this? I can use OracleTransaction with transaction.Rollback().
But am using different webservice methods for transactions.
How to manage rollback and commit here.?
What is the best procedure to handle Transactions?
You need the cooperation of the Web Service provider.
The Web Services standards do permit service providers to offer transactional behaviours across service invocations. In my experience comparatively few service authors do support transactionality. If the services you use offer such capability then you will need to read up on the specifics of using WS-AtomicTransaction in your environment.
However, there are considerable overheads and operational complexities in providing such transactional services, which may well be why few people do so. My preferred solution would be to provide a single coarse-grained service combining the capabilities of InsertQuarterly and InsertMeasures – that implementation can then very easily manage the Oracle transaction within the single service call.
A further possibility is to develop idempotent services (srevices that can safely be called more than once.) The client then has responsibility to call InsertQuarterly() and InsertMeasures() repeatedly until both work, the calls can only safely be repeated if the services are idempotent.
All of these approaches require your service provider to implement some suitable approach, you cannot solve this problem purely in your client code.