WCF异常处理 [英] WCF Exception Handling

查看:123
本文介绍了WCF异常处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在我的WCF服务中发生异常,那么将该错误传达给客户端的最佳方式是什么?

If an exception occurs in my WCF service, what is the best way to communicate that error to the client?

我应该将其记录在服务上并重新启动肥皂例外?
或者我应该记录它并返回一个用户友好的消息?

Should I log it on the service and rethrow a soap exception? Or should I log it and return a user friendly message?

推荐答案

使用强类型或非类型的FaultException是一个完成这个的方法。
有一个很好的文章简化WCF:使用异常作为故障,介绍如何使用每个。正如文章指出的,根据您的服务的复杂性,您可以选择更简单的无类型的FaultException,并将异常信息传递给客户端。

Using strongly typed or non-typed FaultException is a way to accomplish this. There is an excellent article Simplifying WCF: Using Exceptions as Faults that describes how to use each. As the article points out, depending on complexity of your service you may opt to choose simpler untyped FaultException and pass exception info to the client.

这篇关于WCF异常处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆