Re: External Server communication with HTTP requests

57 views
Skip to first unread message

Daniel Kurka

unread,
Oct 30, 2012, 6:06:22 AM10/30/12
to google-we...@googlegroups.com
Please read up on the same origin policy. (For apps this does not apply, you can use a proxy for development)

2012/10/29 John P <devel...@gmail.com>
Hello,

I need support for the communication with external services like Google Maps API.
The following code and websites includes my concerns.

At first I want to get a google map with a HTTP request.
The following website shows the information for my intention.

How can I get Google Maps over HTTP requests?

Another point is the geocoding API from google. 
I want to get information with the geoCodeStr.
I tried this string with my browser and get information which you can see under the HTTP request code.
The problem of my project is that I get no response.
The status code is 0.

I hope someone can give me some advice?

Thanks.

requestBuilder = new RequestBuilder(RequestBuilder.GET, geoCodeStr);
try {
requestBuilder.sendRequest(null,
new RequestCallback() {
public void onError(Request request, Throwable exception) {
Window.alert("Request timeout or no connection to server: "
+ exception.getMessage());
}

public void onResponseReceived(Request request,
Response response) {
System.out.println(response.getHeadersAsString());
System.out.println(response.getText());
if (200 == response.getStatusCode()) {
System.out.println(response.getText());
} else {
Window.alert(""+response.getStatusText());
}
System.out.println(Integer.toString(response.getStatusCode()));
}
});
} catch (RequestException e) {
Window.alert("No connection with server: "+e.getMessage());
}
}

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "1600",
               "short_name" : "1600",
               "types" : [ "street_number" ]
            },
            {
               "long_name" : "Amphitheatre Pkwy",
               "short_name" : "Amphitheatre Pkwy",
               "types" : [ "route" ]
            },
...

--
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/-/X_vIMWxc78sJ.
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.

Joseph Lust

unread,
Oct 30, 2012, 11:27:53 AM10/30/12
to google-we...@googlegroups.com
Consider the JSONPRequestBuilder if you need to access a JSON API cross origin.

Sincerely,
Joseph

Sebastian Rothbucher

unread,
Nov 3, 2012, 6:40:22 AM11/3/12
to google-we...@googlegroups.com
Hi, one of the below posts already mentioned the "same origin" policy which is indeed not to be circumvented (except in apps). What you can do is create an image URL or IFRAME URL and create the respective image or iframe with setUrl("http://someotherserver....") Good luck!
Reply all
Reply to author
Forward
0 new messages