views:

611

answers:

4

I have a regular Java application and want to access an GWT RPC endpoint. Any idea how to make this happen? My GWT application is on a GAE/J and I could use REST for example but I already have the GWT RPC endpoints and don't want to build another façade.

Yes, I have seen http://stackoverflow.com/questions/1330318/invoke-a-gwt-rpc-service-from-java-directly, but this discussion goes into a different direction.

+1  A: 

The Java implementation in GWT of the RPC protocol in the packages com.google.gwt.user.server.rpc and com.google.gwt.user.server.rpc.impl unfortunately only covers deserialization of requests and serialization of responses. The real work is done in the classes ServerSerializationStreamReader and ServerSerializationStreamWriter (each appr. 750 lines of code).

To implement a client, you obviously need to serialze the request and deserialize the response, but since there's no documentation available for the protocol and AFAIK no Java client implementations available, you probably would have to reverse-engineer the (de)serialization classes and write your own code to do everything "the other way around".

You can find some high-level info about the protocol here

jarnbjo
A: 

Unfortunately, I think jarnbjo is right about having to reimplement the browser's half of the RPC mechanism.

Alternately, if you end up having to write a REST interface for remote clients, you can switch your GWT app away from the RPCs and use the REST interface there too, and share your client library between the external clients and the GWT's client-side interface.

Steve Armstrong
A: 

GWT SyncProxy allows you to access GWT RPC services (e.g methods) from pure Java (not JSNI) code.

See http://www.gdevelop.com/w/blog/2010/01/10/testing-gwt-rpc-services/ for details.

Trung
A: 

You can find what you search in this article about GwtRpcCommLayer : http://googlewebtoolkit.blogspot.com/2010/07/gwtrpccommlayer-extending-gwt-rpc-to-do.html

Vinze