Reputation: 4747
I have a file, sample.xml
located at one web server. I want to access this file from a GWT application running at another server. I dont want to make RPC calls to the same server serving GWT application and access the required file on server side (like a proxy). I want to access the file directly from client side as my application is going to be hosted as static files in a web server.
Is there a way to do that?
Upvotes: 2
Views: 577
Reputation: 5402
You're trying to have your website (a.com/index.html
) reference b.com/sample.xml
. I see a few options.
If you have access to b.com
's servers:
sample.xml
into sample.js
to contain the same information in JSON with a callback, and reference it with a script
tagindex.html
at b.com/index.html
, put all the rest of your files on a.com
. Then all your RPC calls can go to b.com
, but this means the user would have to navigate to b.com
instead of a.com
If you don't have access to b.com
's servers:
- Simply provide a link for people to download sample.xml
- Host a.com
on a server with some kind of script support (PHP, Python, Ruby, Java, anything) and put a proxy to b.com/sample.xml
Upvotes: 0
Reputation: 46844
Sure - you must issue a XHR (XmlHTTPRequest) from the browser, and then parse the data.
In GWT you can do it using the RequestBuilder
class (see here).
Please note that some client side restrictions may apply (e.g. Single Origin Policy etc.)
You issue the request (GET or POST - GET in your case) and pass a callback instance.
The instance's onResponseReceived
method receives a Response
object, which by calling its getText
method returns the received contents.
Upvotes: 1