Transaction flow issue in WCF Adapter
Hi,
I am trying to consume a WCF service from a BizTalk orchestration using the WCF Adapter with the Transaction enabled (OleTx). I created a WCF Service having an endpoint with NetTCP binding with the operation having transaction flow as Mandatory. I tried to consume this WCF service from BizTalk using WCF Adapter. The WCF Adapter configuration was imported from the binding file and hence, it has the 'Enable Transaction' set to True with the Transaction Protocol as OleTransaction. But when I try to invoke the WCF service from the BizTalk, I always get an error 'The service operation requires a transaction to be flowed' which denotes that the Transaction is not initiated from BizTalk. Here are the steps to reproduce the problem:
Create a WCF Service having an endpoint with NetTCP binding. Create a new Binding configuration in the config file and enable the 'TransactionFlow' as True and set the binding configuration to the NetTCP binding.
The OperationContract has the transaction flow as Mandatory ([TransactionFlow(TransactionFlowOption.Mandatory)]).
The service implementation has a OperationBehavior as TransactionScope required and Transaction Autocomplete ([OperationBehavior(TransactionScopeRequired =true, TransactionAutoComplete=true)]).
Consume the WCF service from a .Net client within a new TransactionScope to test the service.
Consume the WCF service from an Orchestration in BizTalk and notice the error in the event viewer as "Received unexpected message type 'http://www.w3.org/2003/05/soap-envelope#Fault' does not match expected type 'namespace#response' ". Go to the suspended instance's message details body and the actual error is 'The service operation requires a transaction to be flowed'.
P.S. I also get the same error if I use wsHTTPBinding with WS-AT which I have raised in another threadhttp://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1672773&SiteID=1. I have raised this in a new thread because I tried using NetTCP binding and OleTx to check if it is a binding/transaction type specific issue.
Hi,
Most likely this is caused due to an action mismatch. Could you try to make sure that the send port action is specified correctly. If there's only 1 operation you're trying to call, there is no need to specify the action mapping xml. You can directly specify the expected action for the service operation in the action field for the send port. e.g if your operation contract looks like:-
[
OperationContract(IsOneWay=false, Action="Add")] [
TransactionFlow(TransactionFlowOption.Mandatory)] OutputParams
Add(InputParams ip); Specify the SOAP action header Action as Add.
thanks,
sarathy
Hi Sarathy,
Thank you for the response. As you had specified when I removed the complete Action mapping table in the SOAP Action header and just put ‘Add’ (only the Action string) as the SOAP action header, I was able to successfully invoke the WCF service from the BizTalk orchestration. But, this solution will work if I invoke only one OperationContract from BizTalk orchestration. If I have two or more OperationContract in my WCF service that is used from the Orchestration, then, I can only use the Action mapping table that is generated from binding file. If I use the Action mapping table that is generated from the binding file, it leads to the same error ‘The service operation requires a transaction to be flowed’.
To reproduce the problem, add another operation Subtract and invoke both Add and Subtract operations from the Orchestration:
[OperationContract(IsOneWay=false, Action="Sub")]
[TransactionFlow(TransactionFlowOption.Mandatory)]
OutputParams Subtract(InputParams ip);
Thanks,
Ramesh
Hi,
Most likely your BtsActionMapping table xml is incorrect. You'll need to ensure that the orchestration operation mapping to the WCF service operation action mapping is correct.
E.g. if you had 3 methods in the WCF service with actions MyAction1, MyAction2, MyAction3 and you have 3 operations in the orchestration corresponding to them named Operation_1, Operation_2, Operation_3, you'd set the action mapping on the send port as:
<BtsActionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Operation Name="Operation_1" Action="http://MyService/IMyContract/MyAction1" />
<Operation Name="Operation_2" Action="http://MyService/IMyContract/MyAction2" />
<Operation Name="Operation_3" Action="http://MyService/IMyContract/MyAction3" />
</BtsActionMapping>
The error message is a bit misleading since this case has really nothing to do with transaction flow, it has to do with setting the right action so that the wcf dispatcher can invoke the right service operation.
thanks,
sarathy
Hi,
I do not add the Action mapping manually. I use the 'Add Generated items' in the BizTalk and I use 'Consume WCF service' wizard to generate a Binding file (BizTalkServiceInstance.BindingInfo.xml) which will be imported in the BizTalk Administration console to configure the send ports. (Followed the help topic "How to Use the BizTalk WCF Service Consuming Wizard to Consume a WCF Service"). The BtsActionMapping table that gets set when I import the binding file is:
<BtsActionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Operation Name="Add" Action="Add" />
<Operation Name="Subtract" Action="Sub" />
</BtsActionMapping>
I also tested whether this Action Mapping works by making the WCF service as TransactionFlowOption.Allowed and it worked perfectly. Only when I have the WCF service as TransactionFlowOption.Mandatory with the same Action Mapping, this error appears. So, the Action mapping is correct and it should initiate a Transaction as it does with just one Action.
As you said the error message is misleading and I realized that it is some other problem because the previous workaround that you provided to delete the action mapping and use only the Action name to invoke one operation from orchestration works. Since this is completely internal to BizTalk, is it possible to do more analysis on my side by enabling some profiling/Logging in BizTalk server?
Thank you,
Ramesh
Hi,
Could you make sure that the check box to enable transactions is checked. Few other things:
- what's the event log error you get
- what's the soap fault that you see
- do you see the transaction propagation context in the soap message on the service (you can debug this by using a generic operation contract (action="*").
thanks,
sarathy
This problem gets fixed by using the RC1 version of BizTalk 2006 R2 and the patch for KB939745(MicrosoftBiztalkServer2006R2RCESB-KB939745-ENU.exe). Only the patch solves this issue. Thank you Sarathy for your immense help.