Why GWT HTTP client can't receive HTTP response

863 views
Skip to first unread message

Justin@GWT

unread,
Dec 26, 2011, 8:57:44 PM12/26/11
to Google Web Toolkit
I follow the example code provided by Google GWT to send a HTTP GET
request and receive the response. The GET request was sent out
successfully, but can't receive response message. Actually the
response message has been sent back, according to Wireshark trace.
Does anybody know why?

String urlCityList = "http://www.abcdeft.com/abc/def"; // Here is
just a fake url, but I used real url when trouble shooting.
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET,
URL.encode(urlCityList));


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

}

public void onResponseReceived(Request request, Response
response) {
//
Window.alert(Integer.toString(response.getStatusCode())); // I tried
to print out the status code.It's 0, means nothing is received. But
actually I can see the response message in wireshark tracing.
Window.alert("Could not get HTTP response."); // The code
goes to this branch.
//Window.alert(response.getText());
if (200 == response.getStatusCode()) {

text = response.getText();
parseMessage(response.getText());
//text = response.getStatusText();
} else {
//Window.alert(response.getStatusText());
//Window.alert(Integer.toString(response.getStatusCode()));

}
}
});
} catch (RequestException e) {

}
}

Alfredo Quiroga-Villamil

unread,
Dec 26, 2011, 11:11:15 PM12/26/11
to google-we...@googlegroups.com
See:


Look for SOP.

Regards,

Alfredo


--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.




--
Alfredo Quiroga-Villamil

AOL/Yahoo/Gmail/MSN IM:  lawwton


Justin@GWT

unread,
Dec 27, 2011, 12:24:55 AM12/27/11
to google-we...@googlegroups.com
Thanks.
Is there any workaround about the SOP? I would like to fetch some XML data, but not JSON data.
I tried to enable the cross-site host mode, but I was told "cross-site hosted mode not yet implemented" by GWT.

Best Regards,
Justin

Alfredo Quiroga-Villamil

unread,
Dec 27, 2011, 7:17:25 AM12/27/11
to google-we...@googlegroups.com

Unf. not a whole lot. Easiest might be to:

UI - Your server - XML API

Between the UI and your server you can use a variety of protocols. From your server, then consume the API you need and expose it to the client.

Regards,

Alfredo

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.

Jens

unread,
Dec 27, 2011, 8:20:35 AM12/27/11
to google-we...@googlegroups.com
1.) If the domain of the external URL is actually your production domain (the one where you would deploy and access the app for production) but you are developing using localhost as domain or similar, you can disable SOP in several browsers (google for "disable SOP"). But this is only useful for developing.

2.) Make a request from GWT client to your GWT server and your GWT server makes a request to the external URL.

3.) Use a reverse proxy where you can map any external URLs to URLs of your domain, e.g. a GWT client request to http://www.yourdomain.com/external/mydata may be redirected by the reverse proxy to http://www.mydata.com/api


-- J.

Alan Chaney

unread,
Dec 27, 2011, 11:20:31 AM12/27/11
to google-we...@googlegroups.com
If you can limit your target audience to ff 3.5+, Webkit 4+ (chrome,
safari) and ie8+ you can also use CORS.

See http://saltybeagle.com/2009/09/cross-origin-resource-sharing-demo/

If you need to support IE8/9 then you will have to add a few lines of
JSNI to provide M/S XDR support.


CORS is unbelievably easy to implement at the server end, because all
you have to do is add one or two extra headers to the output.

This assumes that you have some control over the server, or can get the
server's owners to make a small change. If they are serving to a public
community, its a change that they should make, IMHO, because the wide
scale deployment of CORS would solve many problems with SOP, which,
after all, is why it was invented!

HTH

Alan

> --
> You received this message because you are subscribed to the Google
> Groups "Google Web Toolkit" group.

> To view this discussion on the web visit

> https://groups.google.com/d/msg/google-web-toolkit/-/ot35lBGqwy4J.

Reply all
Reply to author
Forward
0 new messages