gwt Server side communication with RestyGwt Defining and using your REST client

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

You should already have your backend REST resource available. On the client side (GWT) your need to

  1. Add RestyGwt dependency to your project with maven

    <dependency>
        <groupId>org.fusesource.restygwt</groupId>
        <artifactId>restygwt</artifactId>
        <version>2.2.0</version>
    </dependency>
    
  2. Add the inheritance to your module file

    <inherits name="org.fusesource.restygwt.RestyGWT"/>
    
  3. Create your client interface

    public interface PizzaService extends RestService {
        @POST
        @Path("pizzaorders")
        public void order(PizzaOrder request, 
                          MethodCallback<OrderConfirmation> callback);
    }
    
  4. Use your client where you want in you app

    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
    });
    


Got any gwt Question?