What should you do?

You are modifying a Windows Communication Foundation (WCF) service that allows customers to update financial data.
The service currently requires a transaction from the client application and is working correctly.
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
10 public class UpdateService : IDataUpdate
11 {
12
13 [OperationBehavior(TransactionScopeRequired=true, TransactionAutoComplete=true)]
14 public void Update(string accountNumber, double amount)
16 {
17 try
18 {
19 …
20 }
19 catch(Exception ex)
20 {
21 …
22 }
23 }
24 }

The service must be modified so that client applications do not need to initiate a transaction when calling the operation.
The service must use the client applications transaction if one is available. Otherwise it must use its own transaction.
You need to ensure that the service operation is always executed within a transaction. What should you do?

You are modifying a Windows Communication Foundation (WCF) service that allows customers to update financial data.
The service currently requires a transaction from the client application and is working correctly.
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
10 public class UpdateService : IDataUpdate
11 {
12
13 [OperationBehavior(TransactionScopeRequired=true, TransactionAutoComplete=true)]
14 public void Update(string accountNumber, double amount)
16 {
17 try
18 {
19 …
20 }
19 catch(Exception ex)
20 {
21 …
22 }
23 }
24 }

The service must be modified so that client applications do not need to initiate a transaction when calling the operation.
The service must use the client applications transaction if one is available. Otherwise it must use its own transaction.
You need to ensure that the service operation is always executed within a transaction. What should you do?

A.
Replace line 05 with the following code.
[TransactionFlow(TransactionFlowOption.NotAllowed)]

B.
Replace line 13 with the following code.
[OperationBehavior(TransactionScopeRequired=false, TransactionAutoComplete=true)]

C.
Replace line 05 with the following code.
[TransactionFlow(TransactionFlowOption.Allowed)]

D.
Replace line 13 with the following code.
[OperationBehavior(TransactionScopeRequired=false, TransactionAutoComplete=false)]



Leave a Reply 3

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


Tom

Tom

I think corect answer is C.

From question:
“The service must use the client applications transaction if one is available. Otherwise it must use its own transaction.”

Allowed – Implies if client has transaction, it will be accepted otherwise not a problem.

NotAllowed – Client cannot send transaction to server while calling a method.

Mandatory – Client has to create a transaction otherwise the method cannot be called.

Gehan

Gehan

The Correct Answer Is C