RemoteObject - 跨域问题

发布于 2024-07-07 15:46:15 字数 266 浏览 5 评论 0原文

我正在尝试从我的服务器获取数据,使用 RemoteObject 来完成它。 当我在本地主机上运行该应用程序时,它工作得很好,但是当我在我的服务器上使用它时,我收到一个 Channel.Security.Error(访问 URL 时出现安全错误)。

在服务器端日志中提到了跨域。 77.127.194.4 - - [23/Oct/2008 21:15:11] "GET /crossdomain.xml HTTP/1.1" 501

有人遇到同样的问题吗? 任何想法 ?

I am trying to get data from my server, used RemoteObject to accomplish it.
When I run the application on my localhost it works great but when iam using it on my server i get a Channel.Security.Error(Security Error accessing URL).

On the server side logs there is a mention about cross domain .
77.127.194.4 - - [23/Oct/2008 21:15:11] "GET /crossdomain.xml HTTP/1.1" 501

Any one encountered the same problem ? any idea ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

前事休说 2024-07-14 15:46:15

您是否尝试过将以下内容添加到您的 crossdomain.xml (您从中获取内容的地方):

<?xml version="1.0"?>
    <!DOCTYPE cross-domain-policy SYSTEM "http://www.YOUR_FRAME_WORK_CROSSDOMAIN_POLICY.com/xml/dtds/cross-domain-policy.dtd">
    <cross-domain-policy>
        <site-control permitted-cross-domain-policies="all"/>
        <allow-access-from domain="*.YOUR_SITE_GOES_HERE.com" secure="false" />
        <allow-access-from domain="*.YOUR_SITE_GOES_HERE.com" secure="false" />
    </cross-domain-policy>

您可能需要更改大写锁定中的内容以适应您的框架。 例如,我从与 Macromedia Flash 一起使用的那个复制了它。 我通常有“www.macromedia.com/xml/dtds/...”而不是“www.YOUR_FRAME_WORK_CROSSDOMAIN_POLICY.com/...”,

我不确定,但尝试调查一下,这可能是你的问题。对于跨域,您通常需要添加到服务器端(您的数据来源),以便其他站点获取它的权限。

Have you tried to add to your crossdomain.xml (where your fetching the stuff from) this:

<?xml version="1.0"?>
    <!DOCTYPE cross-domain-policy SYSTEM "http://www.YOUR_FRAME_WORK_CROSSDOMAIN_POLICY.com/xml/dtds/cross-domain-policy.dtd">
    <cross-domain-policy>
        <site-control permitted-cross-domain-policies="all"/>
        <allow-access-from domain="*.YOUR_SITE_GOES_HERE.com" secure="false" />
        <allow-access-from domain="*.YOUR_SITE_GOES_HERE.com" secure="false" />
    </cross-domain-policy>

The stuff in capslock you'll probably have to change to fit your framework. For example i copied that from the one i use with macromedia flash. Instead of "www.YOUR_FRAME_WORK_CROSSDOMAIN_POLICY.com/..." i normaly have "www.macromedia.com/xml/dtds/...

I'm not sure but try to investigate that, it's probably your problem. For cross-domain, you normaly need to add to the server side, where your fecthing stuff from, permission for other sites to get it.

荆棘i 2024-07-14 15:46:15

我已经找到了解决方案。 你对 crossdomain.xml 文件的看法是正确的,但不幸的是,Python SimpleXMLRPCServer 库默认不支持 GET 方法,因此我们需要实现它。

from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler

class ExtendedXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
  def do_GET(self):
    #only allow a request for the crossdomain file
    if self.path != '/crossdomain.xml':
      self.send_response(403)
      self.log_request(403)
      return

    #open the crossdomain file and read its contents
    response = open('crossdomain.xml', 'r').read()

    #write the data to the socket along with valid HTTP headers
    self.send_response(200)
    self.send_header("Content-type", "text/xml")
    self.send_header("Content-length", str(len(response)))
    self.end_headers()
    self.wfile.write(response)
    self.log_request(200)

I have found the solution. You are right about crossdomain.xml file, but unfortunately, the Python SimpleXMLRPCServer library does not support the GET method by default, so we need to implement this.

from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler

class ExtendedXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
  def do_GET(self):
    #only allow a request for the crossdomain file
    if self.path != '/crossdomain.xml':
      self.send_response(403)
      self.log_request(403)
      return

    #open the crossdomain file and read its contents
    response = open('crossdomain.xml', 'r').read()

    #write the data to the socket along with valid HTTP headers
    self.send_response(200)
    self.send_header("Content-type", "text/xml")
    self.send_header("Content-length", str(len(response)))
    self.end_headers()
    self.wfile.write(response)
    self.log_request(200)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文