WCF 4.0 SOA 提交作为事务
在 WCF 4.0 中,如何将 3 个不同的服务操作作为单个事务提交? (在 SOA 中提交)
我有 3 个不同的 WCF 服务,如下所示,每个服务方法都会调用数据库操作
service1.CreateEmployee();
service2.SendSetupRequestForEmployee();
service3.GiveOfficePermissionToEmployee();
即使一个操作失败,整个事情也应该回滚...任何帮助表示赞赏。
In WCF 4.0, How can I commit 3 different service operation as a single Transaction? (Commit in SOA)
I have 3 different WCF service like below, Each service method invokes DB operation
service1.CreateEmployee();
service2.SendSetupRequestForEmployee();
service3.GiveOfficePermissionToEmployee();
Even if one operation fails entire thing should be rolled back...any help appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简短的回答是:在
TransactionScope
下进行服务调用,并确保调用本身设置为在事务下运行。TLDR请在此处阅读这篇文章。
基本上,您需要这样装饰您的操作合约方法:
服务方法调用自身:
TransactionScope
下调用并在配置文件中的 绑定,将 transactionFlow 设置为
true:
The short answer: Make your service calls under a
TransactionScope
, and make sure the calls themselves are set up to run under transactions.TLDR read this article here.
Basically, you need to decorate your Operation Contract method as such:
and the service method call itself with:
and call under a
TransactionScope
in your config file for the bindings, set transactionFlow to
true
: