I'm trying enble transaction flow in a wcf service.
However I get the following error:
The header 'OleTxTransaction' from the namespace 'http://schemas.microsoft.com/ws/2006/02/tx/oletx' was not understood by the recipient of this message, causing the message to not be processed. This error typically indicates that the sender of this message has enabled a communication protocol that the receiver cannot process. Please ensure that the configuration of the client's binding is consistent with the service's binding.
This is a code snippet of the code I'm trying to run:
var transactionOptions = new TransactionOptions
{
IsolationLevel = IsolationLevel.ReadCommitted
};
using (var transaction = new TransactionScope(TransactionScopeOption.Required, transactionOptions))
{
try
{
var company = CreateCompanyDto(settings);
if (settings.Institution.CompletedSetup)
{
_ezFinanceCompanyServiceLibrary.UpdateCompany(company); // This is the wcf call.
}
else
{
_ezFinanceCompanyServiceLibrary.CreateCompany(company); // This is the wcf call.
CreateDefaultInventroyItems(company.EntityGuid);
}
_db.SaveChanges();
transaction.Complete();
return true;
}
catch (Exception exception)
{
_log.Error(exception.Message);
return false;
}
}
this is my binding options on the web.config of the web api
<bindings>
<netTcpBinding>
<binding name="netTcpBindingbehavior" transactionFlow="true" portSharingEnabled="true" />
</netTcpBinding>
<netMsmqBinding>
<binding name="netMsmqBinding">
<security mode="None" />
</binding>
</netMsmqBinding>
</bindings>
I have the Operation contracts on my service interface in the wcf
[OperationContract]
[TransactionFlow(TransactionFlowOption.Allowed)]
int CreateCompany(CompanyDto newCompany);
[OperationContract]
[TransactionFlow(TransactionFlowOption.Allowed)]
int UpdateCompany(CompanyDto Company);
I have the following attribute on my exposed methods
[OperationBehavior(TransactionScopeRequired = true)]
My bindings options on the App.config in the wcf service
<bindings>
<netTcpBinding>
<binding name="netTcpBinding" transactionFlow="true" portSharingEnabled="true" />
</netTcpBinding>
</bindings>
I have enabled the Network DTC access, I allow Inbounnd and Outbound, I have no authentication Required checked. I have enabled XA Transactions and SNA LU 6.2 Transactions
I have tried adding the following attribute to my bindings:
transactionProtocol="OleTransactions"
on both the service and web api.
Cannot seem to figure out what the problem is.
Turns out that there were [OperationContract]
attributes placed on the methods that were being called by the WCF methods that already had the [OperationContract]
removing all the [OperationContract]
attributes and only placing them on the methods exposed by the WCF solved the problem.