Groups | Blog | Home
all groups > macromedia flash flash remoting > april 2004 >

macromedia flash flash remoting : Must SWF be at same domain as Gateway?


mcarlson
4/12/2004 2:54:28 PM
I've written an MP3 player application in Flash. It uses Flash Remoting to
connect to a web service which provides the artists, albums and songs from a
database. This all works fine when the SWF is run from the same domain as the
Gateway server, but when I access it from a different domain on the same
server, the data never loads.

My code for setting up the connections looks like this:


NetServices.setDefaultGatewayURL("http://www.mydomain.com/flashservices/gateway"
);
gatewayConnnection = NetServices.createGatewayConnection();
jukeboxService =
gatewayConnnection.getService("http://www.mydomain.com/web_services/jukebox.cfc?
wsdl");

If I run the the SWF from http://www.mydomain.com/jukebox.swf everything works
fine.

If I run it from a different domain on the same server -
http://www.myotherdomain.com/jukebox.swf - the data never loads.

Do the domains need to be the same? This seems like it would extremely
limiting. Is there something else I'm doing wrong? Any help would be
appreciated.

Thanks.
- Michael

Pete
4/12/2004 4:41:52 PM
This restriction exists for a very good reason - it's important to stop
attacks like cross site scripting (JavaScript has this restriction too,
fwiw).

You can, however, in Flash Player 7 set up a trusted policy with a remote
server, but that remote server has to agree to let flash files served from
your domain to connect to them. To establish such a policy, you just need to
setup an appropriate crossdomain.xml file in the webroot of the remote
server.

See this article for details:

http://www.macromedia.com/devnet/mx/flash/articles/fplayer_security.html



[quoted text, click to view]
NetServices.setDefaultGatewayURL("http://www.mydomain.com/flashservices/gate
way"
[quoted text, click to view]
gatewayConnnection.getService("http://www.mydomain.com/web_services/jukebox.
cfc?
[quoted text, click to view]

RusD
4/15/2004 10:52:56 AM
Hi !
I have the same problem and no solution.
I use Flash Remoting written on php from www.amfphp.org.
It is working when swf is placed at same domain or runned locally , but not if
I use it from another domain .
http://members.lycos.co.uk/rusdobrov/examples2.html

I head any times about crossdomain.xml file and placed it everywhere as
possible, but with no positive result.
Where to place this file if I use

var myServer =
NetServices.createGatewayConnection("http://members.lycos.co.uk/rusdobrov/remote
/gateway.php");

and services are placed at

http://members.lycos.co.uk/rusdobrov/remote/services/

I realy can't find out how to use this Flash Remoting from another domain

Thanks for help

Ruslan




Pete
4/15/2004 11:42:33 AM
Where are you putting the crossdomain.xml file?

By default, it would have to be placed at the webroot, i.e.
http://www.myserver.com/crossdomain.xml, but in Flash Player 7 r 19 (yes,
r19 was released after r14), a new API was added so that this location could
be changed.


System.security.loadPolicyFile("http://www.mysite.com/flash/myPolicy.xml");

RusD
4/16/2004 11:40:05 AM
[quoted text, click to view]
Thanks for your help
System.security.loadPolicyFile helped
klchio
4/16/2004 3:52:20 PM
Pete Thomas
7/9/2004 5:38:05 PM
Pete if you have time can you layout the exact steps requiried to achieve data
across domain, its something i tried a countless times but never got it working
and gave it up, though i was using combination of adddomain and crossdomain.xml

Have you actually got this going with remoting and not just loadvars?? If so I
would really like to revisit this as this could solve a lot of problems by
providing dynamic data to flash without the need for CF hosting (hmmmm)

cheers
AddThis Social Bookmark Button