Querying webservice which is on another server hosted on appengine

17 views
Skip to first unread message

Riyaz

unread,
Apr 22, 2011, 10:20:49 PM4/22/11
to Google Web Toolkit
Hi,

I just used the stockwatcher example for querying webservice which
return JSON data , but i dont get the response , i get a status code
of 0
The webservice is hosted on an appengine and is online, when i access
the URL directly on the browser i am able to get the data on the
browser.
I am quite sure that the code used is correct because when i changed
someother URL which is hosts webservice i get the proper response.
Is there any setting that has to be done on the appengine that hosts
the webservie

I used the following code snippet from stockwatcher for querying


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

Request request = builder.sendRequest(null, new RequestCallback() {

@Override
public void onResponseReceived(Request request, Response response) {
// TODO Auto-generated method stub
if (200 == response.getStatusCode()) {
String resp = response.getText();
System.out.println("Response "+resp);
} else {
displayError("Couldn't retrieve JSON (" +
response.getStatusText()
+ ")" + "Text "+response.getStatusText());
}


}

@Override
public void onError(Request request, Throwable exception) {
// TODO Auto-generated method stub

displayError("OnError: Couldn't retrieve JSON");

}
});

} catch (RequestException e) {
displayError("Couldn't retrieve JSON");
}


Thanks in advance
Riyaz

Seth Hollyman

unread,
Apr 23, 2011, 1:20:09 AM4/23/11
to google-we...@googlegroups.com
It sounds like you're running into the Same Origin Policy (SOP) issue, a browser security mechanism that restricts how cross-site requests get handled.

This GWT doc talks more in depth about the issue, with the bonus of also addressing it in the context of the stockwatcher example:


-seth

riyaz ahmed

unread,
Apr 25, 2011, 10:38:24 PM4/25/11
to google-we...@googlegroups.com
Thank you seth for the inputs

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



--
Riyaz
9916220381

Thomas Broyer

unread,
Apr 26, 2011, 3:48:58 AM4/26/11
to google-we...@googlegroups.com
That tutorial is outdated: there's been a JsonpRequestBuilder in GWT for a few versions now.

riyaz ahmed

unread,
Jun 6, 2011, 12:37:12 AM6/6/11
to t.br...@gmail.com, google-we...@googlegroups.com
Hi Thomas,

Earlier in this thread you had suggested me to use JsonpRequestBuilder for getting JSON output from webservice,
I have an issue with this now, 

My usecase is this i parse the JSON object recieved and add it to a cell table,  this works fine on my localsetup, but when i deploy it in to the appengine the data is not getting loaded , i get a processing symbol and doesnt go any further ? is it because the call made is asynchronous, is there any other alternative to this ?

Riyaz

On Tue, Apr 26, 2011 at 1:18 PM, Thomas Broyer <t.br...@gmail.com> wrote:
That tutorial is outdated: there's been a JsonpRequestBuilder in GWT for a few versions now.

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



--
Riyaz
9916220381
Reply all
Reply to author
Forward
0 new messages