Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RequestBuilder returns empty response

Tags:

gwt

restlet

I am using RequestBuilder on the front end of GWT to send a HTTP GET request to a Restlet Web Service. However, the request can get into the web service and the web service return a String (in the format of JSON). The problem is no response is returned when I monitor the process through fireBug. Anybody knows why?

Here is the code:

String url = "http://localhost:8080/Books";

RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);

try {
  builder.sendRequest(null, new RequestCallback() {

    public void onError(Request request, Throwable exception) 
    {
      exception.printStackTrace();

      Window.alert("fail - " + exception.getMessage());
    }

    public void onResponseReceived(Request request, Response response) 
    {

      Window.alert("success - " + response.getText());
    }
  });
} catch (RequestException e) 
{
  e.printStackTrace();
}

response.getText() always return empty.

Thanks in advance!

Ike

like image 304
NARU Avatar asked Mar 08 '26 09:03

NARU


1 Answers

Do you do your call to a Restlet server on the same host and port that served the webpage that makes the request ?

I am guessing you are running into http://en.wikipedia.org/wiki/Same_origin_policy

like image 195
koma Avatar answered Mar 11 '26 05:03

koma