GWT RPC 数据格式 [英] GWT RPC data format

查看:27
本文介绍了GWT RPC 数据格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google Web Toolkits (GWT) RPC 调用的数据格式如何以及 IsSerializable 对象如何传输.我知道 Java Serializable 传输某种二进制格式,但 GWT 也是这种情况吗?(因为我不希望它与 JavaScript 兼容,或者至少需要一些额外的解析).

解决方案

Brian Slesinsky 刚刚记录了协议(通过对代码进行逆向工程):https://docs.google.com/document/d/1eG0YocsYYbNAtivkLtcaiEE5IOF5u4LUol8-LL0TIKU/edit>

首先,GWT-RPC 协议是非对称的,因此它始终针对客户端进行优化:快速反序列化来自服务器的内容,并快速序列化要发送给它的内容.

正如您所怀疑的那样,它显然不是二进制的,而是基于文本的.客户端到服务器协议是管道分隔的,而服务器到客户端基于 JSON(带有 //OK//EX 前缀来判断请求是否成功或失败).两者都使用可序列化类的常识来进行序列化/反序列化;例如,双方都知道类 X 有两个字段,一个整数和一个字符串,按该顺序序列化,因此他们都写入/读取一个整数,然后是一个字符串,无需在编码格式中指定它是哪个字段约.

GWT-RPC 协议是版本化的(它会随着新 GWT 版本的发布而定期更改),并使用类的哈希值和可序列化字段的名称来确保客户端和服务器都使用相同版本的类(这意味着您每次更改可序列化类时都必须重新编译和重新部署客户端代码).

最好的文档是代码,但您可以在这些幻灯片中找到请求格式的概述:https://www.owasp.org/images/7/77/Attacking_Google_Web_Toolkit.ppt

RequestFactory 与 GWT-RPC 不同,它使用基于对称 JSON 的协议(基于 AutoBean 的 JSON 序列化),即使不是从相同的代码编译,客户端和服务器也可以进行通信(好吧,取决于您在版本之间所做的更改,当然),因为它们传递类和属性名称.

How does the data format for Google Web Toolkits (GWT) RPC calls look and how are IsSerializable objects transmitted. I know that Java Serializable transmits some kind of binary format, but is this the case with GWT too? (Since I don't expect it to be compatible with JavaScript, or at least require some additional parsing).

解决方案

EDIT: Brian Slesinsky just documented the protocol (by reverse-engineering the code): https://docs.google.com/document/d/1eG0YocsYYbNAtivkLtcaiEE5IOF5u4LUol8-LL0TIKU/edit

First, GWT-RPC protocol is asymmetric so that it's always optimized for the client-side: fast to deserialize something coming from the server, and fast to serialize something to send to it.

It's obviously not binary, as you suspected, but text-based. client-to-server protocol is pipe-delimited while server-to-client is based on JSON (with a //OK or //EX prefix to tell whether the request succeeded or failed). Both use the common knowledge of the serializable classes to serialize/deserialize; for instance, both sides know that class X has two fields, an integer and a String, serialized in that order, so they both write/read an integer, and then a String, with no need to specify in the encoded format which field it's about.

GWT-RPC protocol is versionned (it changes regularly as new GWT versions are released), and uses hashes of the class and serializable fields' names to ensure the client and server both use the same versions of the classes (which means you have to recompile and redeploy your client code each time you change a serializable class).

The best documentation is the code, but you'll find an overview of the request format in these slides: https://www.owasp.org/images/7/77/Attacking_Google_Web_Toolkit.ppt

RequestFactory, contrary to GWT-RPC, uses a symmetric JSON-based protocol (based on AutoBean's JSON serialization) where client and server can communicate even when not compiled from the same code (well, depending on the changes you made between versions, of course), because they pass around class and property names.

这篇关于GWT RPC 数据格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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