client code to make a rpc call
GreetingServiceAsync greetingService = GWT.create(GreetingService.class);
greetingService.greetServer(
"Test Message",
new AsyncCallback<String>() {
public void onFailure(Throwable caught) {
Window.alert("RPC failed");
}
public void onSuccess(String result) {
Window.alert("Successful. result="+result);
}
}
);
rpc interface definition, the endpoint is a relative path "greet.gwt"
package myapp2.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("greet.gwt")
public interface GreetingService extends RemoteService {
String greetServer(String name) throws IllegalArgumentException;
}
RPC asynchronous call class
package myapp2.client;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface GreetingServiceAsync {
void greetServer(String input, AsyncCallback<String> callback)
throws IllegalArgumentException;
}
the expected response content of "greet.gwt"
//OK[1,["hello Test Message"],0,7]