I have code like:
using (TransactionScope scope = TransactionScopeFactory.CreateTransactionScope())
{
*// some methodes calls for which scope is needed*
...
...
*//than WCF method code for which I don't want transaction to be involved, but if it throws an exception I don't wish scope to be completed*
WcfServiceInstance.SomeMethod();
scope.Complete();
}
My question is, can I call the WCF service method inside of the Transaction scope without any problems ? (I don’t know how the service method is implemented) Also, I want to be shure that Transaction will not be involved in wcf service method calling.
To propagate a transaction from your client application ot the service you need to explicity opt-in to transaction flows on the serer and client. If your client is using a transaction aware binding
(NetTcp, NetNamedPipe, WSHttp, WSDualHttp, & WSFederation)then you should see a boolean propertyTransactionFlow. Setting this to false will prevent any transactions from flowing from your cient to the server.You get some additional control on the operation level with the
TransactionFlowattribute, but this is a server side attribute, so if you don’t have access to the service code this likely isn’t an option.Please let me know if the
TransactionFlowattribute doesn’t solve your problem. Understand that setting this to false on the client will prevent any & all transactions from being passed from client to service for that particular endpoint binding.