70-513 · Question #172
A Windows Communication Foundation (WCF) service implements the following contract. (Line numbers are included for reference only.) 01 <ServiceContract()> 02 Public Interface IDataAccessService 04…
The correct answer is C. Catch and handle TimeoutFaultException. Catch FaultException and create a new channel. See the full explanation below for the reasoning.
Question
A Windows Communication Foundation (WCF) service implements the following contract. (Line numbers are included for reference only.) 01 <ServiceContract()> 02 Public Interface IDataAccessService 04 <OperationContract()> 05 Sub PutMessage(ByVal message As String) 07 <OperationContract()> 08 <FaultContract(GetType(TimeoutFaultException))> 09 <FaultContract(GetType(FaultException))> 10 Function SearchMessages(ByVal search As String) As String () 12 End Interface The implementation of the SearchMessages method throws TimeoutFaultException exceptions for database timeouts. The implementation of the SearchMessages method also throws an Exception for any other issue it encounters while processing the request. These exceptions are received on the client side as generic FaultException exceptions. You need to implement the error handling code for SearchMessages and create a new channel on the client only if the channel faults. What should you do?
Options
- ACatch and handle both TimeoutFaultException and FaultException.
- BCatch both TimeoutFaultException and FaultException. Create a new channel in both cases.
- CCatch and handle TimeoutFaultException. Catch FaultException and create a new channel.
- DCatch and handle FaultException. Catch TimeoutFaultException and create a new channel.
How the community answered
(25 responses)- A8% (2)
- B8% (2)
- C80% (20)
- D4% (1)
Community Discussion
No community discussion yet for this question.