Windows 工作流程 - 无法处理 ReceiveActivity 中的异常

发布于 2024-08-15 12:20:59 字数 395 浏览 1 评论 0原文

我有一个顺序工作流,它作为工作流服务托管在 IIS 中。

我的工作流程从 ReceiveActivity 开始,并在 ReceiveActivity 内部使用 SendActivity 调用 WCF 服务。如果此调用收到异常,则我的 ReceiveActivity 上有一个FaultHandlerActivity,它用于处理该调用,并将默认值发送回客户端。

我的客户端中发生的情况是,即使我的FaultHandlerActivity 正在运行,SendActivity 上的异常也会作为FaultException 冒泡回客户端(我通过在故障处理程序中记录单个CodeActivity 的开头和结尾来验证这一点)

我的问题是:如何吞掉 SendActivity 中发生的异常,而不将FaultException 返回给客户端?

I have a sequential workflow, which is hosted in IIS as a Workflow Service.

My workflow starts with a ReceiveActivity, and inside the ReceiveActivity a call is made to a WCF service with a SendActivity. If this call receives an exception, there is a FaultHandlerActivity on my ReceiveActivity which is meant to handle the call, and send a default value back to the client.

What is happening in my client is that an exception on the SendActivity is bubbling back to the client as a FaultException, even though my FaultHandlerActivity is running (I verified this by logging the beginning and end of the single CodeActivity in my fault handler)

My question is: How can I swallow exceptions ocurring in the SendActivity, without a FaultException being returned to the client?

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

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

发布评论

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

评论(1

江南月 2024-08-22 12:20:59

好吧,我明白了。

我的 receiveActivity 上直接有一个错误处理程序。然后会发生的情况是,如果任何子活动引发异常,则会调用接收活动上的故障处理程序,并且它也会设置为“故障”状态,并且接收到的异常将返回到客户端应用程序 - 无论我是否愿意。

解决方案是在 receiveActivity 中添加一个序列活动,在序列活动中执行所有处理,然后向 Sequence 添加一个 failureHandlerActivity,这会设置我的默认返回值。

接收活动永远不会出错,并且异常不会返回给我的客户端,但会返回在 Sequence 的FaultHandler 中设置的默认值。

希望这能帮助其他人解决同样的问题

OK, I figured it out.

My receiveActivity had a fault handler directly on it. What happens then is that if any child activity raises an exception, the fault handler on the receive activity is invoked, and it is also set to a Faulted state, and the exception received is returned to the client application - whether I wanted that or not.

The solution was to add a sequence activity inside the receiveActivity, do all of the processing inside the sequence activity, and add a faultHandlerActivity to the Sequence, which sets up my default return value.

The receive activity is never faulted, and the exception is not returned to my client, but the default value set up in the Sequence's FaultHandler is returned.

Hopefully this will help someone else with the same issue

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