I throw a few soap exceptions in my web service successfully. I would like to catch the exceptions and access the string and ClientFaultCode that are called with the exception.
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
}
Catch the SoapException
instance. That way you can access its information:
try {
service.StartGame();
} catch (SoapException e) {
// The variable 'e' can access the exception's information.
}
catch (SoapException soapEx)
{
//Do something with soapEx
}