PrepAway - Latest Free Exam Questions & Answers

What should you do?

You are developing a Windows Communication Foundation (WCF) service that allows customers to update financial data.
The service contract is defined as follows. (Line numbers are included for reference only)

01 [ServiceContract]
02 public interface IDataUpdate
03 {
04 [OperationContract]
05 [TransactionFlow(TransactionFlowOption.Mandatory)]
06 void Update(string accountNumber, double amount);
07 }
08
09 class UpdateService : IDataUpdate
10 {
11 [OperationBehavior(TransactionScopeRequired = true, TransactionAutoComplete = false)]
12 public void Update(string accountNumber, double amount)
13 {
14 …
15 }
16 }
17

You need to ensure that the service is invoked within the transaction. What should you do?

PrepAway - Latest Free Exam Questions & Answers

A.
Replace line 01 with the following code
[ServiceContract(SessionMode = SessionMode.NotAllowed)]

B.
Replace line 01 with the following code
[ServiceContract(SessionMode = SessionMode.Required)]

C.
Call the Invoke method of the form and supply a delegate.

D.
Call the BeginInvoke method of the form and supply a delegate.

Explanation:
The contract for the service defines that all of the operations require a transaction to be flowed with requests:

[ServiceContract(Namespace = “http://Microsoft.ServiceModel.Samples”, SessionMode = SessionMode.Required)]
public interface ICalculator
{
[OperationContract]
[TransactionFlow(TransactionFlowOption.Mandatory)]
double Add(double n);
[OperationContract]
[TransactionFlow(TransactionFlowOption.Mandatory)]
double Subtract(double n);
[OperationContract]
[TransactionFlow(TransactionFlowOption.Mandatory)]
double Multiply(double n);
[OperationContract]
[TransactionFlow(TransactionFlowOption.Mandatory)]
double Divide(double n);
}

Service Transaction Behavior
(http://msdn.microsoft.com/en-us/library/ms751413.aspx)

One Comment on “What should you do?


Leave a Reply