See https://docs.google.com/a/banshee.com/document/d/1JfUN4C7yj7NL9jJwBwwoCKx0SmWjAhJHqJN6PJmI75E/edit?hl=en_US for the Guice servlet cheatsheet

package com.google.gwt.sample.stockwatcher.client;

import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;

@RemoteServiceRelativePath("stockPrices")
public interface StockPriceService extends RemoteService {

 StockPrice[] getPrices(String[] symbols);
}

Create an interface

@RemoteServiceRelativePath says where this call goes

Client side will have a matching interface with a name ending in Async (StockPriceServiceAsync)

package com.google.gwt.sample.stockwatcher.server;

import com.google.gwt.sample.stockwatcher.client.StockPrice;
import com.google.gwt.sample.stockwatcher.client.StockPriceService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;

public class StockPriceServiceImpl extends RemoteServiceServlet implements StockPriceService {

 public StockPrice[] getPrices(String[] symbols) {
   // TODO Auto-generated method stub
   return null;
 }

}

Server-side

extends RemoteServiceServlet and implements the interface that extends RemoteService

Methods can throw exceptions - add a throws clause to the method.  Handled clientside by onFailure(Throwable caught)

No modifications to web.xml

The normal documentation includes changes to web.xml to support hooking up the servlet.  Use the Guice servlet instead.

package com.google.gwt.sample.stockwatcher.client;

import com.google.gwt.user.client.rpc.AsyncCallback;

public interface StockPriceServiceAsync {

 void getPrices(String[] symbols, AsyncCallback<StockPrice[]> callback);

}

Eclipse automates this

Create an interface ending with -Async that matches the interface for the server.  In this case, StockPriceService/StockPriceServiceAsync.

The GWT compiler does special things based on this naming convention.