GWT gives us great way to build RIA interface application. This application works on client side and has to exchange data using backend services. If your server uses java, then you have no problem - you simply write java code, deploy it, and GWT application will work perfect.
But a lot of services use php based background.
The simplest way is to use RequestBuilder class to send requests to server and receive results.
Here is a few line sof code:
1. Create request builder object
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));
2. Run it using method sendRequest. This method requires: request parameters and call back object to process result.
Call back object can be represented by inner class, like this:
builder.sendRequest(null, new RequestCallback() {
//if server was contacted, but returns HTTP error
public void onError(Request request, Throwable exception) {
echo.setText("Error with HTTP code: " + exception.getMessage());
}
//if everything is ok (HTTP code 200)
public void onResponseReceived(Request request,
Response response) {
echo.setText(response.getText());
}});
That's all. Now you can interact with PHP backend easily.
Download example source code from SF.net
DOWNLOAD
Readme will explain how to deploy it on your server for tests