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:
-- 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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd "><html xmlns="http://www.w3.org/1999/xhtml ">
<head></head>
<body>
<p>Any Old Song Will Do..</p>
</body>
</html>
private final String url = "http://samewebsite/" + "BROADCAST" + "/cyberobjects/RemoteUpdate.html?LTA=MBONAIR<N=MOBILE";
RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, URL.encode(url));
try {
@SuppressWarnings("unused")
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<N=MOBILE
RequestBuilder Success: getText (is blank)
RequestBuilder Success: getHeadersAsString (is blank)
RequestBuilder Success: getStatusText() (is blank)
RequestBuilder Success: toString()com.google.gwt.http.client.Request$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.
ThanksEd
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 google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment