Yesterday, I got a query regarding how to handle exceptions in case of asynchronous web service operations. Precise question was,
I am calling a WCF service using Asynchronous way, the service may execute for some time, meanwhile if any exception occurred in the service side how can I come to know what happened in the service side?
I am not able to get the status in the Async Method.
There is a pretty simple solution available for this problem.
When the asynchronous method throws an exception, proxy catches it and when the client calls End Operation the proxy re-throws that exception object so that client can handle the exception. If a COMPLETION CALLBACK is provided, WCF calls that method immediately after the exception is received. Exception thrown is compliant with the fault contract and type of exception. Following code snippet shows how to do this;
Using this method you can receive any service side exceptions on client side.
Currently Listening to: Bekaraar from Pathshala (new Lucky Ali song)