Making Restful Services Accessible to GWT Applications





Full room for RestyGwt + Jersey presentation by David Chandler @GwtCreate 2015, amazing !



1Add RestyGWT to your classpath

Download the latest stable RestyGWT jar

Or if you are a maven user, then just add the following dependency to your pom.xml.

<dependency>
    <groupId>org.fusesource.restygwt</groupId>
    <artifactId>restygwt</artifactId>
    <version>2.2.0</version>
</dependency>

2Add RestyGWT to you GWT module file

<inherits name="org.fusesource.restygwt.RestyGWT"/>

3Define your REST client interface

Use JAX-RS annotations to make it even simpler !

public interface PizzaService extends RestService {
    @POST
    @Path("pizzaorders")
    public void order(PizzaOrder request, 
                      MethodCallback<OrderConfirmation> callback);
}

4Use your client

PizzaService service = GWT.create(PizzaService.class);
service.order(order, new MethodCallback<OrderConfirmation>() {
    
    public void onSuccess(Method method, OrderConfirmation response) {
      //code your stuff here
    }
    
    public void onFailure(Method method, Throwable exception) {
      //code your stuff here
    });

A quick video to introduce RestyGWT



Want to know more ? Checkout the documentation or restygwt google group