I\'m using GWT as web development framework. I need to access some REST services from my GWT client code. Also I need to parse JSON (or maybe XML) which is response format o
RequestBuilder is a low-level approach to make HTTP requests.
You can resort to a higher level approach working with Turbo GWT HTTP, a convenient API for managing client-server communication and performing requests fluently.
It fits better the REST style communication. Consider the following example:
Request request = requestor.request(Void.class, Book.class)
.path("server").segment("books").segment(1)
.get(new AsyncCallback() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(Book result) {
Window.alert("My book title: " + result.getTitle());
}
});
There's no need to map your REST services before calling them (which is conceptually required for RPC communication, but not for REST). You can just consume your services on demand.