Wcf provides transaction so operations(wcf methods) those are part of a single work unit can be called in a transaction. Operations could be from same or different wcf services.
If any one method out of all methods called in one transaction fails & thrown exception then all other method's operations also rolled back.
Three options are available of transaction flow:
Steps to make Wcf service transaction enabled:
If any one method out of all methods called in one transaction fails & thrown exception then all other method's operations also rolled back.
Three options are available of transaction flow:
- Allowed: Marked service method can be called with in transaction or without transaction
- NotAllowed: Marked service method can't be called in transaction
- Mandatory: Marked service method must be called in transaction only
Steps to make Wcf service transaction enabled:
- Create binding tag with attribute transactionFlow is true
<bindings>
<wsHttpBinding>
<binding name ="TransBind" transactionFlow="true"></binding>
</wsHttpBinding>
</bindings>
- Assign binding name to bindingConfiguration attribute of endpoint
<services>
<service name="WcfTranService1.Service1" behaviorConfiguration="serviceBehavior">
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"></endpoint>
<endpoint address="" binding="wsHttpBinding" contract ="WcfTranService1.IService1" bindingConfiguration="TransBind"></endpoint>
</service>
</services>
- Mark method in interface with TransactionFlowOption.allowed in TransactionFlow
[OperationContract]
[TransactionFlow(TransactionFlowOption.Allowed)]
void SetData(int value);










