This is highly unlikely to work unless you plan on emulating a browser
in which to run the code. The client side RPC code uses lots of JSNI
to eke the maximum performance out of the browser.
> 2) Write a custom Java library to communicate with the service. This
> would obviously require more development effort, but it would result
> in a thinner client. However, I'm not sure how feasible it is, since I
> haven't found any documentation on the actual wire protocol used by
> GWT.
This is likely to be a big pain in all relevant body parts. The GWT
RPC protocol is deliberately opaque, I think. It was designed with
the goal of getting Java objects back and forth between a GWT client
and a Java server-side with minimum fuss and maximum performance. In
fact, the client-server wire format is different from the
server-client format in order to best take advantage of the
peculiarities of each situation.
Also, the RPC wire format is likely to change in 1.6 (I say, as
someone with no actual control over the feature list of any release)
because the current implementation is susceptible to slow script
warnings. Tracking a deliberately undocumented wire format is likely
to be a pain.
> Has anyone else looked into this? Are there other, better
> alternatives?
I'd suggest using some other method of serializing object graphs onto
the wire, and using a shim on the server side that deserializes the
request, calls into your service implementation (it is necessarily a
public method on an arbitrary class), and then serializes the result
back onto the wire in a format that is convenient for you. Since
you'd be talking JVM-to-JVM, I'd put money down saying that the
easiest way to serialize things would be using Java's built-in
serialization.
If that suggestion doesn't work because you want the Java client to
talk to the server using some sort of Foo-over-HTTP protocol, then I'd
still suggest writing your own shim but instead of using Java-native
serialization over sockets, or something, I'd use a RESTful interface
behind a set of URLs distinct from the URL through which you expose
your GWT service. I'd choose a RESTful interface because I believe
the hype that REST is the best way to scale Foo-over-HTTP
communication to "web scale". Feel free to choose your own value of
Foo.
Ian