如何将工作流服务异常传递给客户端
我正在使用 WCF 工作流服务应用程序 (DeclarativeServiceLibrary)。我有一个 Windows 窗体客户端与工作流服务通信。我能够使用 TryCatch 块处理已知错误。 但是,如果程序遇到任何未知异常并进入 catch 块,我想向客户端返回一条通用消息。有人可以帮助我实现这一目标吗?
I am using a WCF Workflow service application (DeclarativeServiceLibrary). I have a Windows Forms client talking to the workflow service. I am able to handle known errors using TryCatch blocks.
But in case the program meets any unknown exception and comes to the catch block, I want to return a Generic message to the client. Could anybody help me in achieving this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们有一个示例演示了 WCF 服务和 WorkflowServices 的这一点,请查看。
We have a sample that demonstrates this for WCF Services and WorkflowServices check it out.
如果在工作流中捕获异常,则您应该使用提供故障异常的 SendReply 活动。您的服务契约还需要定义故障契约,否则客户端收到的异常将使通道出现故障。
If the exception is caught within the workflow, then you should use a SendReply activity that provides the fault exception. Your service contract also needs to define the fault contract otherwise the exception received on the client will fault the channel.