GWT Convert RPC to JSON

My application uses GWT-RPC to communicate with the server. Is there anyway serialzie transparency of my data using JSON without changing the RPC level?

IMHO this can be achieved by modifying serializers and using autobean code in the user interface.

Why do I need it?

  • I want to make cross domain RPC calls
  • I want to call the server side from a non-GWT application without providing an additional layer on the server side.
+4
source share
2 answers

UPDATE I just stumbled upon http://code.google.com/p/gerrit/source/browse/README?repo=gwtjsonrpc which is actively supported (as part of Gerrit, the -review code used by the Android team)

Take a look at http://code.google.com/p/gwt-rpc-plus/ but it is no longer supported ...

If you really need it and you do not want to move away from GWT-RPC, then you should replace the GWT serializers: exactly what deRPC does ( com.google.gwt.rpc ). standard GWT-RPC ( com.google.gwt.user.rpc ), but it should do a little more than that (namely: generate serialization code for the client side, since there is no reflection at run time).

+3
source

This is a difficult task. I don’t think that changing serializers will work, GWT-RPC serializers work with input data as a stream (basically the data sent from the server is actually in JSON format, but they can only be analyzed by GWT-RPC). You will need to create a completely new generator that will create code for parsing and serializing / deserializing objects. In this case, AutoBean can be very useful. In the end, you can transfer from serializing GWT-RPC to another protocol without actually changing the current code that uses GWT-RPC services.

The biggest problem is cross-domain messaging. Usually you use JSONP, but the problem is that JSONP basically only allows GET requests, if you need to send a lot of data to another server, you may not be able to put everything in separate requests. You can solve this problem by exchanging messages between domains (for example, you will open an iframe that will download special javascript communications from a remote server, and you will use this iframe as a proxy for your service via postMessage ), but this function is not supported in IE7

+1
source

Source: https://habr.com/ru/post/1394193/


All Articles