Wednesday, March 27, 2013

Re: RequestBuilder Newbie Question

"samewebsite" is not necessarily the same "origin": an "origin" is defined as the triplet: scheme (http vs. https), host (note that hostname is not the same as IP address for the same machine) and port.
I bet you get getStatusCode() == 0, which is a symptom of cross-origin requests.

Solution: either use the same origin (easy fix: remove http://samewebsite" from the URL, just use /BROADCAST/etc.) or enable CORS on your server.

On Wednesday, March 27, 2013 4:13:28 PM UTC+1, Ed wrote:
HI All,

I am trying to implemet a call to server for data retreival using request builder.

The request builder does not throw errors but also does NOT return data.

When I run the url in a browser window it does return results

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ""><html xmlns="">
Any Old Song Will Do..</p>


private final String    url            = "http://samewebsite/" + "BROADCAST" + "/cyberobjects/RemoteUpdate.html?LTA=MBONAIR&LTN=MOBILE";

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

        try {
            Request response = builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable exception) {

                    System.out.println("RequestBuilder On Error: " + url);

                public void onResponseReceived(Request request, Response response) {
                    System.out.println("RequestBuilder Success: " + url);
                    System.out.println("RequestBuilder Success: getTxt" + response.getText());
                    System.out.println("RequestBuilder Success: getHeadersAsString" + response.getHeadersAsString());
                    System.out.println("RequestBuilder Success: getStatusText()" + response.getStatusText());
                    System.out.println("RequestBuilder Success: toString()" + response.toString());
                    System.out.println("RequestBuilder Success: toString()" + response.toString());



Yields the following results:

RequestBuilder Success: http://samewebsite/BROADCAST/cyberobjects/RemoteUpdate.html?LTA=MBONAIR&LTN=MOBILE
RequestBuilder Success: getText (is blank)
RequestBuilder Success: getHeadersAsString (is blank)
RequestBuilder Success: getStatusText() (is blank)
RequestBuilder Success: toString()$1@1380717c

I am wondering if I need to switch to json data retrieval or if I am constructing the response/request in a wrong way.



You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment