You need to ensure that the transaction is aborted if the Update method is not successful

You are developing a Windows Communication Foundation (WCF) service that allows

customers to update financial dat a. The client applications call the service in a transaction.
The service contract is defined as follows. (Line numbers are included for reference only.)
01 <ServiceContract()> 02 Public Interface IDatallpdate 03 04 <OperationContract()> 05
<TransactionFlow(TransactionFlowOption.Handatocy)> 06 Sub Update (ByVal
accountNumber As String, ByVal amount As Double) 07 08 End Interface 09 10 Class
UpdateService 11 Implements IDataUpdate 12 13 <OperationBehavior(
TransactionScopeRequired:=True, TransactionAutoComplete:=True)> 14 Public Sub
Update(ByVal accountNumber As String, ByVal amount As Double) Implements
IDataUpdate.Update IS 16 Try 17 18 Catch ex As Exception 19 WriteErrorLog(ex) 20 21
End Try 22 23 End Sub 24 25 End Class Customers report that the transaction completes
successfully even if the Update method throws an exception. You need to ensure that the
transaction is aborted if the Update method is not successful. What should you do?

You are developing a Windows Communication Foundation (WCF) service that allows

customers to update financial dat a. The client applications call the service in a transaction.
The service contract is defined as follows. (Line numbers are included for reference only.)
01 <ServiceContract()> 02 Public Interface IDatallpdate 03 04 <OperationContract()> 05
<TransactionFlow(TransactionFlowOption.Handatocy)> 06 Sub Update (ByVal
accountNumber As String, ByVal amount As Double) 07 08 End Interface 09 10 Class
UpdateService 11 Implements IDataUpdate 12 13 <OperationBehavior(
TransactionScopeRequired:=True, TransactionAutoComplete:=True)> 14 Public Sub
Update(ByVal accountNumber As String, ByVal amount As Double) Implements
IDataUpdate.Update IS 16 Try 17 18 Catch ex As Exception 19 WriteErrorLog(ex) 20 21
End Try 22 23 End Sub 24 25 End Class Customers report that the transaction completes
successfully even if the Update method throws an exception. You need to ensure that the
transaction is aborted if the Update method is not successful. What should you do?

A.
insert the following line at line 20. Throw

B.
Replace line 13 with the following line. <OperationBehavior(
TransactionScopeRequired:MTrue, TransactionAutoComplece:”False)>

C.
Insert the following line at line 09. <ServiceBehavlor(
TransactionAutoCoropleteOnSessionClose:”False) >

D.
Insert the following line at line 09. <ServiceBehavior(
TransacCionAucoCompleteOnSesslonClose:”True) >



Leave a Reply 0

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