Phaedrus
Phaedrus

Reputation: 497

Is it possible to call a GWT servlet from native Java?

I have a GWT application, with a Native Java backend, and a compiled Javascript front-end (as usual).

My GWT service should also be accessible from other clients, including a java applet. Initially my idea was to double the GWT service as a SOAP service, and use a soap client from the applet to access the GWT service, but I am wondering if it might be possible to use the built-in GWT client infrastructure to call the server from Java.

Upvotes: 1

Views: 1456

Answers (2)

Bert F
Bert F

Reputation: 87623

The problem with this approach is serializing the request and deserialize the response so as to be compatible with the GWT service.

One solution is to use GWT SyncProxy:

which is explained here:

You can use it directly or, since they provide the source, you take a peek to see how they serialize the request and deserialize the response.

Upvotes: 3

Bert F
Bert F

Reputation: 87623

Another approach is to use Restlet to provide the services and then convert your GWT client to make REST calls. The Restlet people provide a GWT library to facilitate this.


Edit:

I only know RESTlet from evaluating it last year for my GWT project. I'm no expert and I didn't end up using it, but this is no reflection, good or bad, on RESTlet.

OP asks:

What would be the advantage of using the Restlet framework over JAX-RS ?

Essentially, JAX-RS is an just API (like JDBC) - you still need to pick an implementation or use the reference implementation Jersey. RESTLet has an extension for supporting JAX-RS API.

http://www.restlet.org/about/faq#07

7. What is the link between Restlet and JAX-RS (JSR-311)?
...
To summarize, both APIs have very different designs but are potentially complementary. The good news is that Jérôme Louvel (Restlet's creator) is an active member of the JSR-311 Expert Group and that an implementation of the JAX-RS API was made on top of the Restlet API. This "JAX-RS extension for Restlet" was developed by Stephan Koops in the context of his Master thesis and is one of the most advanced implementations available. For more documentation on this extension, please refer to this page.


OP asks:

Is it possible to use Tomcat / web.xml infrastructure instead of org.reslet.server

http://wiki.restlet.org/docs_2.0/13-restlet/275-restlet/312-restlet.html

This edition is aimed for development and deployment of Restlet applications inside Java EE application server, or more precisely inside Servlet containers such as Apache Tomcat.

Upvotes: 2

Related Questions