使用 2.0 样式和 WCF 代理进行正确的错误处理

发布于 2024-09-08 05:16:00 字数 261 浏览 5 评论 0原文

Microsoft 提供的有关此问题的信息数量惊人地少,或者我对该问题的了解不够,无法找到文档。

当使用传统的 VS2005 和 .NET 2.0 Web 服务代理使用 Web 服务时,除了故障异常之外,还可以抛出哪种类型的通信异常以及通过哪些程序集/命名空间。

我很难从 System.ServiceModel 中找到与 WCF 的 ServiceActivationException 和 CommunicationException 等效的内容 - 这些是相同的异常吗?

Microsoft has provided surprisingly small amounts of information regarding this issue or I do not know enough about the problem to locate the documentation.

When consuming web services using the traditional VS2005 and .NET 2.0 web service proxies, aside from FaultExceptions, what sort of communication exceptions can be thrown and through which assemblies/namespaces.

I am having difficulty locating the equivilent to WCF's ServiceActivationException and CommunicationException from System.ServiceModel - are these the same exceptions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

醉生梦死 2024-09-15 05:16:00

几乎所有与 WCF 相关的异常都源自 CommunicationException,因此如果您查阅 MSDN 文档中的后代类列表,您应该会有所了解。

例外是通用的 TimeOutException(来自 System.Net 命名空间)和 QuotaExceeded 来自 System.ServiceModel 命名空间的异常,令人惊讶的是,它并非源自 CommunicationException - 为什么是这样的,我不知道。

Pretty much all WCF related exceptions descend from CommunicationException so if you consult the list of descendant classes in the MSDN documentation, you should be covered.

Exceptions are the generic TimeOutException (from the System.Net namespace) and the QuotaExceeded exception from the System.ServiceModel namespace which surprisingly does not descend from CommunicationException - why that is the case, I don't know.

凉城凉梦凉人心 2024-09-15 05:16:00

ASMX 代理可以抛出 SoapExceptionHttpWebRequest 可以抛出的任何异常。

然而,你必须问自己:你为什么关心?对于一种异常类型和另一种异常类型,您将采取哪些不同的做法?您实际上可以处理任何这些异常吗,或者您只是记录它们并让它们传播(我希望您不会捕获它们然后忽略它们)。

An ASMX proxy can throw SoapException, or anything that can be thrown by HttpWebRequest.

However, you have to ask yourself: why do you care? What are you going to do differently between one exception type and another? Can you actually handle any of these exceptions, or will you simply log them and let them propagate (I hope you're not going to catch them and then ignore them).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文