【发布时间】:2014-10-15 07:25:26
【问题描述】:
让我概述一下情况。我有一个 Windows 服务(让我们将其命名为 A),其中 calls 是一个 Web 服务(让他命名为 B)。 B 调用 不同的Web 服务本身。 (让我们将这些 Web 服务称为 WS1,WS2,WS3)
绘图:
//This is a Black Box (e.g. I can't change implementation)
+-----------------------------------------------+
| |
| ----> WS1 |
WindowsService A ----> | Webservice B ----> WS2 |
| ----> WS3 |
| |
+-----------------------------------------------+
在通话期间可能会不时发生异常。 大多数异常应该停止执行程序并通知开发者(我)。但是当 Timeout 发生时,Window-Service A 应该尝试 retry。
所以我写了以下代码:
try
{}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.Timeout)
{
//Wait some time before retry
//Log the exception
//Retry
}
else
{
//Log the exception
throw;
}
}
catch (Exception ex)
{
//Log the exception
throw;
}
如果 Web-Service B 中发生异常,则此代码将非常有效。然而,当timeout 出现在WS1,WS2,WS3;我收到了SoapException。
问题:
如果SoapException 的原因是Timeout 而不使用此处提到的消息(MSDN- Handle TimeoutException),是否仍然可以过滤掉。是否有任何字段可以指向底层异常的类型?
【问题讨论】:
标签: c# web-services soapexception