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 sam开发者_JS百科e 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?
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.
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:
- Edit sample.xmlintosample.jsto contain the same information in JSON with a callback, and reference it with ascripttag
- Compile your website using the cross-site loader (see Controlling Compiler Output), put your index.htmlatb.com/index.html, put all the rest of your files ona.com. Then all your RPC calls can go tob.com, but this means the user would have to navigate tob.cominstead ofa.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
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论