错误处理 Web 服务

发布于 2024-10-03 00:53:07 字数 309 浏览 0 评论 0原文

我正在为一个大学项目提供银行网络服务,该服务接收帐户信息和金额,以便我们从帐户中提取资金,作为响应,我们发送一条确认消息。

我正在寻找的是如何管理客户端的错误,因为我可以进行交易,但如果由于任何原因客户端失败,资金就会丢失,我怎么知道客户端操作是否成功?

- 编辑 - 例如 : 银行 A - 其他,银行 B - 我。 一个人去银行 A 存入银行 B 的支票,因此他使用我的网络服务进行交易,我进行提款并返回 OK 消息,但在银行 A 设法将钱添加到帐户之前,< em>某件事失败了。现在我提款了,但是那个人并没有真正有钱,因为A银行交易失败了。

I'm doing a bank web service, for a college project, which receives the account information and the amount so we do the withdrawal of the money from the account, and as a response we send a confirmation message.

What I'm looking for is how to manage errors from the client side, because I could do my transaction but if for any reasons the client fails, that money is lost, how could I know if the client side operation was successful?

-- edit --
For example :
Bank A - other, Bank B - me.
A person goes to Bank A to deposit a check from Bank B, so he uses my web service to do a transaction and I do the withdrawal and return a OK message, but then before Bank A manages to add the money to an account, something fails. So now I did the withdrawal, but the person doesn't really has the money because Bank A failed the transaction.

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

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

发布评论

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

评论(2

ˉ厌 2024-10-10 00:53:07

如果我理解的话,您希望使用网络服务为客户提供从您的“银行”提款的能力。

我会使其成为交易性的,例如,他们致电服务以开始提款,然后您确认交易已开始并且您的服务期望提取该金额。 (也许锁定这笔钱,直到交易结束才可以提取,并计时,这样交易在 x 秒后自动失败)

然后,客户端使用该信息执行任何操作,例如调用第二个“银行”。当他们收到另一家银行发来的消息称金额已添加时,他们会调用您系统的服务来“提交”交易,实际上是提取金额。

If I understand, you want to use web services to provide the ability for a client to make a withdrawal from your "bank".

I would make it so that it is transactional, say, they make a call to the service to start a withdrawal, then you confirm that the transaction has started and that your service is expecting that amount to be withdrawn. (Maybe lock that money to not be available to be withdrawn until the transaction ends, and time it, so the transaction automatically fails after x seconds)

The client then does whatever with that information, say calls the second "bank". When they receive a message from the other bank saying that the amount was added, then they call the service with your system to "submit" the transaction, actually withdrawing the amount.

凉世弥音 2024-10-10 00:53:07

问题是你相信客户会从一家银行取出钱并将其存入另一家银行。真的吗?凉爽的!我将进行一些 API 调用,声称我刚刚“收到”了很多钱。呜哇哈哈哈哈!

认真地说,应该发生的是客户收到支票并将其交给银行 A(一个 API 调用)。然后,银行 A 将支票交给银行 B 并获得资金。 (另一个 API 调用)。然后客户也许可以联系 A 银行来验证他们的账户余额是否增加了。客户在任何时候都不应联系银行 B。然后,客户仅进行一次 API 调用,并且他们不可能像您的示例中那样破坏系统。

The problem is you are trusting the client to take the money out from one bank and put it in the other. Really? Cool! I'm going to be making some API calls claiming I've just "received" lots of money then. Mwuahahahaha!

Seriously, what should happen is that the client takes the cheque and presents it to bank A (One API call). Bank A then presents the check to Bank B and gets the funds. (Another API call). Then maybe the client can contact Bank A to verify their account balance has gone up. At no point should the client be contacting Bank B. Then, the client only makes one API call and it's not possible for them to break the system as in your example.

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