BizTalk and web service transactions - how to do that?
Hi all!
I have an orchestration which calls two web services (they are further performing some database operations).
I have managed to use Transaction Internet Protocol and TipUrl to get transactions and rollback working for web services, when I call them from a C# application. But when trying to send TIPUrl as a part of a message from a BizTalk orchestration I get "Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.BizTalk.Agent.Interop.IBTMessageBatchEx'." error.
So is there any way to get TIP working from an orchestration or maybe I need completely different approach to get transactions and rollback working for webservices and BizTalk?
Thanks.
[872 byte] By [
midix] at [2008-1-10]
Thanks,
ibrahim durmus, for your interest. I 'll try to explain the problem deeper.At first I read some info about BizTalk orchestartions and found out that Atomic scope does not guarantee full transactions support if not used directly with MSDTC. And I think that my case is really far from direct MSDTC connectivity.
I am using 2 web services. One is trying to save (or update) one kind of documents in a MS SQL database, the other is doing the same with other kind of documents in other database. Tha task is: if the second of web services fails to save (or update) the document, then the first one should roll back (if it succeeded with saving). And if the first fails, then the second should not try to save anything at all.
The first thing I studied was this "
Using TIP (Transaction Internet Protocol) to Enlist Web Services into COM+ Distributed Transactions"
:
http://www.codeproject.com/csharp/complus_tip.asp
and I got it working nice from a simple C# Application - my web services act exactly the way I need. Then I tried to implement it in an orchestration the same way. I thought that orchestration should not know anything about the transaction process behind those web services.
All the transactions are controlled by a class TransactionController from the example in the article. So I registered my TransactionController.dll in GAC, made a reference to the dll and made a simple orchestration which:
receives a multipart message with two dokuments
then comes Atomic scope with a variable TC of my TransactionController class
orch. calls TC.BegioTransaction();
orch. constructs a message (the first document to save) and adds TC.TipUrl as a part of message;
orch. sends a message to the first web service through SOAP prot;
orch. constructs a message (the second document to save) and adds TC.TipUrl as a part of message;
orch. sends a message to the second web service through SOAP prot;
orch. calls TC.EndTransaction();
Atomic scope ends.
orch. receives response from the first web service;
orch. receives response from the second web service.
I am using System.Diagnostics.Trace.WriteLine to output messages from an orch. and DebugView utility to see those messages. So I monitored debug messages that I put in the orch. and I saw that TIPUrl is fine, it is filled with data. The first message was constructed successfully. Then comes the Send shape. ... and all freezes and event log says:
"An error occurred that requires the BizTalk service to terminate. The most common causes are the following:
1) An unexpected out of memory error.
OR
2) An inability to connect or a loss of connectivity to one of the BizTalk databases.
The service will shutdown and auto-restart in 1 minute. If the problematic database remains unavailable, this cycle will repeat.
Error message: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.BizTalk.Agent.Interop.IBTMessageBatchEx'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{6C90EC04-4918-11D3-A242-00C04F60A533}' failed due to the following error: Interface not registered (Exception from HRESULT: 0x80040155).
Error source: Microsoft.BizTalk.Interop.Agent
BizTalk host name: BizTalkServerApplication
Windows service name: BTSSvc$BizTalkServerApplication "
and after that BizTalk host instance shuts off and starts again after a minute and gives the same error and so on until I terminate the orch.
However, if I run the orchestration without TC.BegioTransaction(); and TC.EndTransaction(); it runs fine, but TIPUrl is empty and that means - no transactions at all.
I googled a lot but got no idea what BizTalk needs to send TIPUrl to the web service. So I am stuck. But ithe solution seems to be so close - if it works from C# app then why it cannot work from orchestrations? Maybe it is somehow related to COM+ and how BizTalk uses COM+ ?
I would be grateful for any ideas.
Thanks.
Hi again Midix:
Thanks for the error log. It says "Interface not registered (Exception from HRESULT: 0x80040155)."
Probably, Biztalk Message Agent faces with a problem however it is not easy to say
the reason on top of head.
Before investigating further, let me ask you a question:
What was the reason that you don't prefer to use LR transaction.
I know you didn't prefer for Atomic Scopes but I wonder the reason of LR?
LR Transactions Info : http://msdn2.microsoft.com/en-us/library/aa560028.aspx
- Ibrahim DURMUS
http://www.ibrahimdurmus.com
http://blogs.msdn.com/ibrahim