[ACCEPTED]-How do you catch a thrown soap exception from a web service?-exception

Accepted answer
Score: 11

You may want to catch the specific exceptions.

try
{
     service.StartGame();
}
catch(SoapHeaderException)
{
// soap fault in the header e.g. auth failed
}
catch(SoapException x)
{
// general soap fault  and details in x.Message
}
catch(WebException)
{
// e.g. internet is down
}
catch(Exception)
{
// handles everything else
}

0

Score: 8

Catch the SoapException instance. That way you can access 1 its information:

try {
     service.StartGame();
} catch (SoapException e)  {
    // The variable 'e' can access the exception's information.
}
Score: 1
catch (SoapException soapEx) 
{
  //Do something with soapEx
}

0

More Related questions