简体   繁体   English

运行查询并从外部站点检索XML

[英]Running a query and retrieving XML from an external site

I am trying to use Ajax to submit a query to an external database (http://foreignserver:1234/database?query="SELECT FROM WHERE"). 我正在尝试使用Ajax向外部数据库提交查询(http:// foreignserver:1234 / database?query =“ SELECT FROM WHERE”)。 The query will run and create an XML file which I would like to be returned. 该查询将运行并创建一个我想返回的XML文件。 The external server is running on Apache Tomcat. 外部服务器在Apache Tomcat上运行。 I have done some research on cross-site scripting, but: 我已经对跨站点脚本进行了一些研究,但是:

-CORS is not an option because IE7 has to be supported. -CORS不是一个选项,因为必须支持IE7。 It also seems unnecessarily difficult to do in Tomcat. 在Tomcat中似乎也不必要地困难。

-easyXDM is not an option. -easyXDM不是一个选择。

-I am trying to do this with XML, and JSONP seems to be a JSON thing? -我正在尝试使用XML执行此操作,而JSONP似乎是JSON?

-There will be a lot of data coming back, so iFrames probably are not an option. -将会有很多数据返回,因此iFrame可能不是一个选择。

What to do? 该怎么办?

  • JSONP would be better for this task as JSON syntax is light especially if you have a lot of data. JSONP对于此任务而言会更好,因为JSON语法比较轻巧,尤其是在您有大量数据的情况下。 Also, JSONP already bypasses SOP and is purely client-side, besides the fact that the server encodes the data as JSON. 而且,除了服务器将数据编码为JSON的事实之外,JSONP已经绕过SOP且仅是客户端。 However, you'd have to use JSON instead of XML. 但是,您必须使用JSON而不是XML。

  • If you really insist using XML, you can have your server assist you to fetch the remote page. 如果您确实坚持使用XML,则可以让服务器协助您获取远程页面。 This means the browser at your domain requests the page from your server on the same domain, then your server reads the remote page and returns it to the browser. 这意味着您所在域的浏览器从同一域中的服务器请求页面,然后服务器读取远程页面并将其返回给浏览器。 Your server will be a proxy that bypasses SOP. 您的服务器将成为绕过SOP的代理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM