views:

17

answers:

1

Hi,

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 the 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.

Thanks
nRk

+1  A: 

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
}
PhilPursglove
Thanks phil for the answer. this help me...
nRk