Raj said:
I catch and throw exception in a web service like the below way:
catch (Exception e)
{
throw new SoapException(e.Message,
SoapException.ServerFaultCode, Context.Request.Url.AbsoluteUri);
}
Whether the conventional method of catching exception at the client side
sufficient to handle the exception thrown by client?
I don't know the answer to your specific question. But you should not
throw a new exception from a catch block unless you include the current
exception as the inner exception for the new exception. For example:
catch (Exception e)
{
throw new SoapException(e.Message, SoapException.ServerFaultCode,
Context.Request.Url.AbsoluteUri, e);
}
Also, if you're going to generate a new exception like that, you really
ought to provide some added value to the message, rather than just
copying the one from the previous message.
As far as the specific question goes, I know almost nothing about web
services. But, your question seems to be asking whether an exception
thrown by the client will be caught by the client. My naïve expectation
is that of course it would. If you were asking about the exception
being transferred over the network from client to server or vice a
versa, then I could see it being less clear.
But an exception thrown in a thread of the client ought to be catchable
in the same thread of that client, just like exceptions generally.
Of course, you could easily test whatever scenario you're actually
interested, regardless of the specifics. Why you're asking the question
at all, I don't know. Why not just try it?
Pete