开发者

How to differentiate between various exception while calling a webservice in using .net?

I am consuming one webservice, while consuming there can different types expception might occur depeninding on various situation like.. network failur, invalid soap data or exception from serverside also might occur.

How can I differntiate between these different excpetion?

Because in my application, with these exceptions I need to update th开发者_JS百科e various status Like: if network failure occurs Status will be "unable to connect webservice" so I can try after sometime later. If exception comes from Web server , no need to call/try again.

nRk


What about a try/catch block but with multiple catches for different exceptions? e.g.

try
{
    // webservice invocation
}
catch (SoapException ex)
{
    // Handle Soap exceptions
}
catch (IOException ex)
{
    // Handle IOException
}
catch (Exception ex}
{
    // Handler of last resort - any exception not specifically handled above 
    // will be caught here
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜