开发者

Flex - How to call a webservice without crossdomain.xml file

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, t开发者_运维百科hen it cannot be consumed.

That can't be right can it?


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.


If your webservice is on another domain, you'll need a crossdomain file. Pure and simple.

I have found two ways around this:

  1. Use an HTTPService
  2. Use external interface calls to Javascript embedded on your flash file's container page, which will then call the web service

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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜