让我勾勒一下情况。我有一个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 |
| |
+-----------------------------------------------+
通话期间可能会不时发生异常。大多数异常应该停止程序的执行并通知开发人员(我)。但是当 aTimeout
发生时,Window-ServiceA
应该尝试 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
.
问题:如果没有使用此处提到的消息(MSDN-Handle TimeoutException) ,是否有
过滤掉的原因。是否有任何字段可以指向底层异常的类型?SoapException
Timeout