Web 服务中的 Oracle 事务回滚

发布于 2024-12-26 07:15:55 字数 812 浏览 1 评论 0原文

我有几个事务将表单数据插入到 oracle 表中。

if (InsertQuarterly() == true)
            {
                InsertMeasures();
            }

如果 insertmeasures 过程成功执行,那么我必须调用另一个过程。 在 InsertQuarterly 中,我调用一个 Web 服务方法将数据插入到 Oracle 表中 例如

sOUT = ws_service.InsertQuarterly(txtQ2dTarget.Text, txtQ3dTarget.Text)

,对于 InsertMeasures 我正在调用 webservice

sOUT = ws_service.InsertMeasures(txtachieveGold.Text, txtachieveDia.Text)

我的问题是如果 InsertQuarterly 执行成功,但如果 InsertMeasures 在事务期间失败,那么我想回滚 InsertQuarterly 也可以。 我怎样才能实现这个目标?我可以将 OracleTransactiontransaction.Rollback() 一起使用。 但我使用不同的网络服务方法进行交易。 这里如何管理回滚和提交?

处理交易的最佳程序是什么?

I have several transactions to insert form data into oracle table.

if (InsertQuarterly() == true)
            {
                InsertMeasures();
            }

And if insertmeasures procedure executed successfully then I have to call another procedure.
Within InsertQuarterly I am calling a webservice method to Insert data into Oracle table
for eg

sOUT = ws_service.InsertQuarterly(txtQ2dTarget.Text, txtQ3dTarget.Text)

and for InsertMeasures I am calling webservice

sOUT = ws_service.InsertMeasures(txtachieveGold.Text, txtachieveDia.Text)

My problem is if InsertQuarterly executed successfully but if InsertMeasures failed during transaction then I want to rollback InsertQuarterly also.
How can I achieve this? I can use OracleTransaction with transaction.Rollback().
But am using different webservice methods for transactions.
How to manage rollback and commit here.?

What is the best procedure to handle Transactions?

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

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

发布评论

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

评论(1

美胚控场 2025-01-02 07:15:55

您需要Web服务提供商的配合。

Web 服务标准确实允许服务提供商跨服务调用提供事务行为。根据我的经验,支持事务性的服务作者相对较少。如果您使用的服务提供此类功能,那么您将需要阅读在您的环境中使用 WS-AtomicTransaction 的详细信息。

然而,提供此类交易服务会产生相当大的管理费用和操作复杂性,这很可能就是很少有人这样做的原因。我的首选解决方案是提供一个结合了 InsertQuarterly 和 InsertMeasures 功能的单一粗粒度服务 - 该实现可以非常轻松地在单个服务调用中管理 Oracle 事务。

另一种可能性是开发幂等服务(可以安全地多次调用的服务)。然后,客户端有责任重复调用 InsertQuarterly() 和 InsertMeasures() 直到两者都起作用,只有在服务正常运行时才能安全地重复调用。幂等的。

所有这些方法都需要您的服务提供商实现一些合适的方法,您无法纯粹在客户端代码中解决这个问题。

You need the cooperation of the Web Service provider.

The Web Services standards do permit service providers to offer transactional behaviours across service invocations. In my experience comparatively few service authors do support transactionality. If the services you use offer such capability then you will need to read up on the specifics of using WS-AtomicTransaction in your environment.

However, there are considerable overheads and operational complexities in providing such transactional services, which may well be why few people do so. My preferred solution would be to provide a single coarse-grained service combining the capabilities of InsertQuarterly and InsertMeasures - that implementation can then very easily manage the Oracle transaction within the single service call.

A further possibility is to develop idempotent services (srevices that can safely be called more than once.) The client then has responsibility to call InsertQuarterly() and InsertMeasures() repeatedly until both work, the calls can only safely be repeated if the services are idempotent.

All of these approaches require your service provider to implement some suitable approach, you cannot solve this problem purely in your client code.

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