views:

392

answers:

3

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?

+1  A: 

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

mattdell
+1  A: 

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.

eipipuz
+1  A: 

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.

James Ward
BlazeDS looks like a good solution. Thanks for the pointer.
Stephane Grenier