Flex - 如何在没有 crossdomain.xml 文件的情况下调用 Web 服务
如何使用未明确创建 crossdomain.xml 的 Web 服务?
我知道这是为了安全并防止跨站点脚本,但这似乎确实是 Flex 框架的一个主要限制。
例如,如果我想使用一个与语言无关的 Web 服务,那么我就不能使用 Flex。 Web 服务/服务器必须专门为 Flex/Flash 准备。如果不是,则不能食用。
这不可能吧?
How can I consume a webservice that hasn't explicitely created a crossdomain.xml?
I understand it's for security and to prevent cross-site scripting, but it does seem like a major limitation to the Flex framework.
For example, if I want to consume a webservice, which is suppose to be language agnostic, then I can't with Flex. The webservice/server has to be specifically prepared for Flex/Flash. If it's not, then it cannot be consumed.
That can't be right can it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用 Apache 或 BlazeDS 等代理服务器将来自 SWF 的主机的请求转发到具有 Web 服务的主机。
Use a proxy server like Apache or BlazeDS to forward requests from the host the SWF originated from to the host with the web services.
如果您的网络服务位于另一个域,您将需要一个跨域文件。纯粹而简单。
我找到了两种解决此问题的方法:
选项 2 更复杂,但我更喜欢它。此链接应该可以帮助您使用ExternalInterface类:http://blog.flexexamples.com/2008/03/11/returning-values-from-javascript-in-your-flex-applications-使用-externalinterface-api/#more-555
If your webservice is on another domain, you'll need a crossdomain file. Pure and simple.
I have found two ways around this:
Option 2 is more complex, but I prefer it. This link should help you out with the ExternalInterface class: http://blog.flexexamples.com/2008/03/11/returning-values-from-javascript-in-your-flex-applications-using-the-externalinterface-api/#more-555
我所做的就是“放置一个中间人”。所以基本上,我放置了一个 php 脚本,它从另一端读取我需要的内容。是的,不幸的是,这需要一个“服务器”。您也可以尝试 JavaScript。
What I did was "put a middle man". So basically, I put a php script that reads from the other side what I need. Yes, unfortunately, that requires a "server". You could try a JavaScript as well.