catch(Exception ex)
{
//do what you want here
//When type of exception is System.Web.Services.Protocols.SoapException
//if (ex.Code.Name.Equals("Client"))
//{
// msg = "service's function not exist";
//}
//else if (ex.Code.Name.Equals("Server"))
//{
// msg = "function error"
//}
//else
//{
// msg = "unknown";
//}
//MessageBox.Show(msg, "error", MessageBoxButtons.OK);
**But ex is not System.Web.Services.Protocols.SoapException so I cannot call ex.Code.Name.Equals("Client")**
//When System.Net.WebException
//switch (ex.Status)
//{
// case System.Net.WebExceptionStatus.ConnectFailure:
// do some thing
break;
// case System.Net.WebExceptionStatus.Timeout:
//do some thing
break;
// case System.Net.WebExceptionStatus.ProtocolError:
switch (((System.Net.HttpWebResponse)ex.Response).StatusCode) …
Run Code Online (Sandbox Code Playgroud)