25.2. Preparing your component

To prepare a Seam component to be called with GWT, you must first create both synchronous and asynchronous service interfaces for the methods you wish to call. Both interfaces should extend the GWT interface com.google.gwt.user.client.rpc.RemoteService:
public interface MyService extends RemoteService { 
  public String askIt(String question);      
}
The asynchronous interface should be identical, except for an additional AsyncCallback parameter for each of the methods it declares:
public interface MyServiceAsync extends RemoteService { 
  public void askIt(String question, AsyncCallback callback); 
}
The asynchronous interface (in this case, MyServiceAsync) is implemented by GWT, and should never be implemented directly.
The next step is to create a Seam component that implements the synchronous interface:
@Name("org.jboss.seam.example.remoting.gwt.client.MyService")
public class ServiceImpl implements MyService {

  @WebRemote
  public String askIt(String question) {
   
    if (!validate(question)) {
      throw new IllegalStateException("Hey, this should not happen, " + 
                                      "I checked on the client, but " +
                                      "it's always good to double check.");
    }
    return "42. Its the real question that you seek now.";
  }
   
  public boolean validate(String q) {
    ValidationUtility util = new ValidationUtility();
    return util.isValid(q);
  }
}
The Seam component's name must match the fully-qualified name of the GWT client interface (as shown), or the Seam Resource Servlet will not be able to find it when a client makes a GWT call. Methods that GWT will make accessible must be annotated with @WebRemote.