What should you do to ensure that the application does not fail when the Web service raises the exception?

An application fails when executing a specific operation.
You discover that the failure occurs when an exception is raised by a Web service.
The application uses the following code to call the Web service.

void Process()
{
ProcessService serviceProxy = new ProcessService();
serviceProxy.ProcessDataCompleted += new ProcessDataCompletedEventHandler(ServiceCompleted);
serviceProxy.ProcessDataAsync(data);
}

You need to ensure that the application does not fail when the Web service raises the exception.
Your solution must maximize the performance of your code.

What should you do?

An application fails when executing a specific operation.
You discover that the failure occurs when an exception is raised by a Web service.
The application uses the following code to call the Web service.

void Process()
{
ProcessService serviceProxy = new ProcessService();
serviceProxy.ProcessDataCompleted += new ProcessDataCompletedEventHandler(ServiceCompleted);
serviceProxy.ProcessDataAsync(data);
}

You need to ensure that the application does not fail when the Web service raises the exception.
Your solution must maximize the performance of your code.

What should you do?

A.
Register the following method with the proxy object to receive the notification of completion.
void ServiceCompleted(object sender, ProcessDataCompletedEventArgs e)
{
if (sender is SoapException)
LogMessage(e.Error.Message);
else
ProcessResult(e.Result);
}

B.
Register the following method with the proxy object to receive the notification of completion.
void ServiceCompleted(object sender, ProcessDataCompletedEventArgs e)
{
if (e.Error is SoapException)
LogMessage(e.Error.Message);
else
ProcessResult(e.Result);
}

C.
Register the following method with the proxy object to receive the notification of completion.
void ServiceCompleted(object sender, ProcessDataCompletedEventArgs e)
{
try
{
ProcessResult(e.Result);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}

D.
Register the following method with the proxy object to receive the notification of completion.
void ServiceCompleted(object sender, ProcessDataCompletedEventArgs e)
{
if (e.Error != null)
LogMessage(e.Error.Message);
else
ProcessResult(e.Result);
}



Leave a Reply 0

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