运行查询并从外部站点检索XML [英] Running a query and retrieving XML from an external site

查看:70
本文介绍了运行查询并从外部站点检索XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Ajax向外部数据库提交查询(http://foreignserver:1234/database?query ="SELECT FROM WHERE").该查询将运行并创建一个我想返回的XML文件.外部服务器在Apache Tomcat上运行.我已经对跨站点脚本进行了一些研究,但是:

I am trying to use Ajax to submit a query to an external database (http://foreignserver:1234/database?query="SELECT FROM WHERE"). The query will run and create an XML file which I would like to be returned. The external server is running on Apache Tomcat. I have done some research on cross-site scripting, but:

-CORS不是一个选项,因为必须支持IE7.在Tomcat中似乎也不必要地困难.

-CORS is not an option because IE7 has to be supported. It also seems unnecessarily difficult to do in Tomcat.

-easyXDM不能选择.

-easyXDM is not an option.

-我正在尝试使用XML做到这一点,而JSONP似乎是JSON吗?

-I am trying to do this with XML, and JSONP seems to be a JSON thing?

-将会返回大量数据,因此iFrame可能不是一种选择.

-There will be a lot of data coming back, so iFrames probably are not an option.

该怎么办?

推荐答案

  • JSONP对于此任务而言会更好,因为JSON语法比较轻巧,尤其是在您有大量数据的情况下.此外,除了服务器将数据编码为JSON的事实外,JSONP已经绕过SOP且仅是客户端.但是,您必须使用JSON而不是XML.

    • JSONP would be better for this task as JSON syntax is light especially if you have a lot of data. Also, JSONP already bypasses SOP and is purely client-side, besides the fact that the server encodes the data as JSON. However, you'd have to use JSON instead of XML.

      如果您确实坚持使用XML,则可以让服务器协助您获取远程页面.这意味着您所在域的浏览器从同一域中的服务器请求页面,然后服务器读取远程页面并将其返回给浏览器.您的服务器将是绕过SOP的代理.

      If you really insist using XML, you can have your server assist you to fetch the remote page. 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.

      这篇关于运行查询并从外部站点检索XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆