WCF Transaction Configuration Steps

Step 1) Contact được thiết lập thuộc tính:

public interface IService1
[OperationContract, TransactionFlow(TransactionFlowOption.Mandatory)]
bool PerformCreditTransaction(string creditAccountID, double amount);

Step 2)
Lớp cài đặt dịch vụ được thiết lập như sau:

[OperationBehavior(TransactionScopeRequired = true)]
public bool PerformCreditTransaction(string creditAccountID, double amount)

Step 3) cấu hình web.config

<service name=”WcfServiceTransaction.Service1″ behaviorConfiguration=”WcfServiceTransaction.Service1Behavior”>
<endpoint address=”” binding=”wsHttpBinding” contract=”WcfServiceTransaction.IService1″ bindingConfiguration=”httpBinding”>
<dns value=”localhost”/>
<endpoint address=”mex” binding=”mexHttpBinding” contract=”IMetadataExchange”/>
<binding name=”httpBinding” transactionFlow=”true”/>

Step 4) Client

Sử dụng TransactionScope và ts.Complete()


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s