在XML-RPC或SOAP中实现回调 [英] Implementing a callback in XML-RPC or SOAP

查看:296
本文介绍了在XML-RPC或SOAP中实现回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解如何使用SOAP或XML-RPC为我的产品创建一个远程的,开放的API。
问题是,我的API的一部分将要求我能够得到事件从我的服务器推送到客户端 - 我需要能够发送回调,而不仅仅是调用函数作为一部分的API。
在SOAP或XML-RPC中有很好的方法吗?

I am trying to get an understanding of how I can use SOAP or XML-RPC to create a remote, open API for my product. Problem is, part of my API will require me to be able to get events pushed from my server to the client - I will need to be able to "send a callback" and not only "call a function" as part of my API. Is there a good way to do that in SOAP or XML-RPC?

推荐答案

有两种方法在RPC系统中的通知:推模型和拉模型。在拉模型中,客户端将定期查询服务器是否有可用的通知。服务器需要存储它们,直到客户端提取它们(或直到它们过期)。作为变型,客户端可以具有阻塞RPC调用,阻塞直到下一个事件变为可用,然后立即返回。这对CORBA很好,但是对于SOAP或者XML-RPC来说效果并不好,因为HTTP实现通常不准备让连接打开几个小时。

There are two ways to do notifications in an RPC system: the push model, and the pull model. In the pull model, the client will periodically query the server whether any notifications are available. The server needs to store them until the client fetches them (or until they expire). As a variant, the client may have a blocking RPC call that blocks until the next event becomes available, and then returns right away. That works fine with CORBA, but doesn't work so well with SOAP or XML-RPC, since the HTTP implementations are typically not prepared to leave a connection open for hours.

在推送模型中,生产者将调用消费者上的RPC,使消费者成为服务器。这对SOAP或XML-RPC也不能太好,因为客户端通常不准备承担服务器角色,而防火墙可能会阻止回调。所以周期性拉动是最现实的方法。

In the push model, the producer will invoke an RPC on the consumer, making the consumer a server. That doesn't work too well with SOAP or XML-RPC, either, since the client is typically not prepared to take the server role, and firewalls may prevent the callback from getting through. So the periodic pull is about the most realistic approach.

您可能已经注意到我没有按照您的术语:您无法按下事件。事件是发生的事情。您只能推送通知,这是发生事件的信息。

P.S. you may have noticed that I didn't follow your terminology: you cannot push events. An event is something that happens. You can only push the notification, which is an information that an event did happen.

这篇关于在XML-RPC或SOAP中实现回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆