What should you do?

You are integrating a Windows Communication Foundation (WCF) service within an enterprise-wide Service Oriented Architecture (SOA).
Your service has the following service contract:

[ServiceContract]
public class CreditCardConfirmationService
{
[OperationContract]
boolean ConfirmCreditCard(string ccNumber);

double OrderAmount(int orderNumber);
}

You need to allow the code in the ConfirmCreditCard method to participate automatically in existing transactions.
If there is no existing transaction, a new transaction must be created automatically. What should you do?

You are integrating a Windows Communication Foundation (WCF) service within an enterprise-wide Service Oriented Architecture (SOA).
Your service has the following service contract:

[ServiceContract]
public class CreditCardConfirmationService
{
[OperationContract]
boolean ConfirmCreditCard(string ccNumber);

double OrderAmount(int orderNumber);
}

You need to allow the code in the ConfirmCreditCard method to participate automatically in existing transactions.
If there is no existing transaction, a new transaction must be created automatically. What should you do?

A.
Inside the ConfirmCreditCard method,
surround the code that must participate in the transaction with a using(new TransactionScope()) block.

B.
Inside the ConfirmCreditCard method,
surround the code that must participate in the transaction with a using(new CommittableTransaction()) block.

C.
Add an [OperationBehavior(TransactionScopeRequired=true)] attribute to the ConfirmCreditCard method.

D.
Add an [OperationBehavior(TransactionAutoComplete=true)] attribute to the ConfirmCreditCard method.

Explanation:
Set the TransactionScopeRequired to true to require your operation to execute within a transaction scope.
If a flowed transaction is available, the operation executes within that transaction. If one is not available,
a new transaction is created and used for the operation execution. The binding specified in the endpoint controls whether flowed transactions are supported.
Therefore, to obtain the proper behavior you must understand the interaction between whether transaction flow is permitted
by the binding and the TransactionScopeRequired property. The following table shows the possible behavior.

How to: Create a Transactional Service
(http://msdn.microsoft.com/en-us/library/ms730232.aspx)



Leave a Reply 1

Your email address will not be published. Required fields are marked *