带有 MessageContracts 的故障合约
我正在将 MessageContracts 用于我的 WCF 服务;我将各种 DataContracts 分组为一个 MessageContracts。我的基本响应包含 - isOperationSuccess (bool)、exceptionMessage (Exception)。如果在服务级别发生错误,我将分配给 exceptionMessage 并将 isOPerationSuccess 设置为 false;并返回响应。
我是否仍然需要在客户端处理/捕获FaultContract(我的服务包含FaultContract 属性)?
我的问题是我需要在哪里将FaultContract 与MessageContracts 一起使用?
I am using MessageContracts for my WCF services; I am grouping various DataContracts into a single MessageContracts. My base response is contains - isOperationSuccess (bool), exceptionMessage (Exception). If an error occurs at service level, I am assigning into exceptionMessage and setting the isOPerationSuccess to false; and returning the response.
Do I still have to handle / catch the FaultContract at client (my service includes a FaultContract attribute?
My question is where do I need to use FaultContract with MessageContracts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果该操作具有
FaultContract
属性,则它可能会返回错误。当然,你的客户应该处理这个问题。If the operation has a
FaultContract
attribute on it, then it may return a fault. Of course your client should handle that.如果该操作具有
FaultContract
属性,则它可能会返回错误。当然,你的客户应该处理这个问题。当然,客户必须处理它;但如果您查看我的响应消息,它包含一个异常对象,我将在其中填充服务器异常。在这种情况下,我是否有任何条件可以获得故障合同?
If the operation has a
FaultContract
attribute on it, then it may return a fault. Of course your client should handle that.Of course client has to handle it; but if you look at my response message, it includes an exception object into which I am filling the server exception. In this scenario, do I have any condition where I'll get a FaultContract?