JSON-WSP 或 JSON-RPC [英] JSON-WSP or JSON-RPC
问题描述
我们即将实现一个使用 JSON 对象作为传输方式的网络服务.我们打算让第三方组织连接到我们的网络,为此我们计划在未来使用标准化协议来简化集成.
对于 JSON,目前有两个规范:JSON-RPC 和 JSON-WSP.我想知道这两者之间的任何人的看法,以及如果您处于我的位置,您会使用什么.现在,我看到 JSON-RPC 已经存在了一段时间并且有多种语言的实现.JSON-WSP 处于早期阶段,但它的目标是取代 JSON-RPC(正在制定 RFC).我认为 JSON-WSP 从长远来看将是一个很好的解决方案,但我可能错了.
这两种协议的主要区别在于 JSON-WSP 可以使用 jsonwsp/描述对象.如果您希望您的客户端能够了解"您的 Web 服务,并且可能提供一个动态的客户端用户界面,当您更改服务方法时,该界面可以自动更改可视化,那么这很好.因此,服务器端更新可能会变得非常容易分发.
JSON-WSP 在规范中支持附件
JSON-RPC 支持批处理方法调用 - 在一个请求中调用多个方法.你也可以做无响应的请求(通知)
JSON-RPC 是两个协议中最古老的,因此它有更多的实现和庞大的社区.p>
所以我想这一切都归结为您的需求.
如果您正在构建基于浏览器的应用程序,则 JSON-WSP 使用官方 javascript 客户端提供了一种基于 Ajax 的高效机制.JavaScript json-wsp 客户端解析服务描述并生成一个代理对象,其中的方法将 1 对 1 映射到 json-wsp 方法:
http://ladonize.org/index.php/Python_Example#JavaScript_JSON-WSP_client
We're about to implement a webservice using JSON objects as the mode of transportation. We have an intent of having third-party organizations to connect to our network and for that we are planning to use a standarized protocol to ease integration in the future.
For JSON, there's two specifications at the moment: JSON-RPC and JSON-WSP. I would like to know about anyone's view between these two and what would you use if you're in my shoes. For now, I see that JSON-RPC has been around for a while and has implementations to multiple languages. JSON-WSP is at its early stages but it aims to supersede JSON-RPC (an RFC is in the works). I see that JSON-WSP will be a good solution in the long run but I might be wrong.
The main difference between the two protocols is that JSON-WSP can describe it's own service methods with the jsonwsp/description object. This is nice if you want your client to be able to "know" your webservices and maybe offer a dynamic client-side user-interface that can change visualisation automatically when you change the service methods. So server-side updates can potentially become very easy to distribute.
JSON-WSP has support for attachments in the specification
JSON-RPC has support for batch-method invocation - invoke several method in one request. Also you can do response-less requests (Notifications)
JSON-RPC is the oldest of the two protocols and therefore it has more implementations and a large community.
So I guess it all boils down to what your needs are.
If you are building a browser-based application JSON-WSP offers an efficient Ajax-based mechanism using the official javascript client. The JavaScript json-wsp client parses the service description and generates a proxy object with methods mapping 1-to-1 to the json-wsp methods:
http://ladonize.org/index.php/Python_Example#JavaScript_JSON-WSP_client
这篇关于JSON-WSP 或 JSON-RPC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!