GWT Convierte RPC a JSON

My application uses GWT-RPC to communicate to the server. Is there anyway to transparentlly serialzie my data using JSON without changing the RPC layer?

IMHO this could be acheived by changing the serializers and using autobean codex in the UI.

¿Por qué necesito eso?

  • I want to make cross domain RPC calls
  • I want to call the server side from a non GWT-app without providing an extra layer in server side.

preguntado el 01 de febrero de 12 a las 14:02

This is the reason I switched away from GWT-RPC entirely. Now I just use GWT's AutoBean and Request classes, and I've never regretted it. -

2 Respuestas

ACTUALIZACIÓN Acabo de tropezar con http://code.google.com/p/gerrit/source/browse/README?repo=gwtjsonrpc which is actively maintained (as it's part of Gerrit, the code-review tool used by the Android team)

Echa un vistazo a http://code.google.com/p/gwt-rpc-plus/ but it's no longer maintained...

If you really need it and don't want to move away from GWT-RPC, then replacing GWT's serializers should be possible: that's exactly what deRPC (com.google.gwt.rpc) does re. standard GWT-RPC (com.google.gwt.user.rpc), but it needs to do a bit more than that (namely: generate the serialization code for the client-side, as there's no reflection at runtime).

Respondido 03 Feb 12, 15:02

Nice project, I'll give it a try. - Jordi PS

This going to be a hard task. I don't think the changing of serializers will work, GWT-RPC serializers are working with input as with a stream (basically data sent from server are in fact in JSON format, but they can be parsed only by GWT-RPC). You will have to create totally new generator, which will create code for parsing and object serialization/deserialization. AutoBean framework might be very helpful in this case. In the end you should be able to to migrate from GWT-RPC serialization to some other protocol without actually changing current code, which is using GWT-RPC services.

The biggest problem is cross-domain messaging. Normally you would use JSONP, but the problem is that JSONP basically allows only GET requests, if you need send a lot of data to the other server, you might not be able to fit everything into single requests. You can solve such problem with cross domain document messaging (e.g. you will open iframe, which will load special communication javascript from remote server, and you will use this iframe as proxy for your service via postMessage) , but this feature is not supported in IE7.

Respondido 01 Feb 12, 20:02

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.