Monday, June 13, 2016

Re: Newbie Help - how to retrieve data from another website?



On Monday, June 13, 2016 at 9:40:34 AM UTC+2, Hans Dampf wrote:
Hi everyone,

opening an URL like http://randomserver.com/file?get=randomXML returns a XML-file. I don't have access to the server.
Now i am trying to receive this data and give it out in my gwt-app.
I have tried modifying the code from this tutorial : http://www.gwtproject.org/javadoc/latest/com/google/gwt/jsonp/client/JsonpRequestBuilder.html but i failed miserably.
Can anyone kindly give me a hint on what to implement / how to do it properly in order to read the XML and put its content in an object that i can modify / give out in my gwt-app?
Thanks in advance!

If the other server sends CORS headers in the response, then you can just use XMLHttpRequest or RequestBuilder: http://caniuse.com/#feat=cors
Otherwise, you'll have to make the request from your server (acting as a proxy) to workaround the same-origin policy.
JSON-P, despite what its name suggests, is simply about retrieving a JavaScript and having it executed in the current web page using a <script> tag; so it (obviously) won't work for XML.

--
You received this message because you are subscribed to the Google Groups "GWT Users" 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 https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment