cross-domain policy

Apr 14, 2010 at 9:34 AM
Edited Apr 14, 2010 at 10:28 AM

Hey,

I'm trying to get WCF Flash Remoting working with Flash CS4/AS3 and need a little helping hand. Im using 2 PCs, the first one to host wcf and the second one for developing flash. The wcf-service seems to be working corretly, if im calling http://myPC1/WcfService/NoteService.svc/amf from pc2 manually I get

message must be either 'AmfMessage' or 'AmfMultipleMessage'.
WcfFlashRemoting, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
 
So the endpoint seems to work. In Flash CS4 it doesn't seem to connect, the connection status is false and the Flash output gives me "Error opening URL 'http://myPC1/WcfService/NoteService.svc/amf'
call failed". My code is the same as the as3 sample code:
var remotingGateway:String="http://myPC1/WcfService/NoteService.svc/amf";
_netConnection = new NetConnection();

//Use NetStatus event to handle an incorrect gateway URL.
_netConnection.addEventListener(NetStatusEvent.NET_STATUS, connectionHandler);
//Add url
_netConnection.connect(remotingGateway);
trace("Connectionstatus: " + _netConnection.connected);
 
I first thought it's an cross-domain error, I added an cross-domain-file in my project dir (d:\projects\...\myproject) but it didn't help. I copied the project, so both the swf (with html) and the service were in the same dir (http://myPC1/myProject). It didn't help.
Any ideas? I'm a .Net-Developer and this is nearly my first Flash-App.
thanks a lot
Coordinator
Apr 14, 2010 at 2:44 PM

In my experience, the "message must be either 'AmfMessage' or 'AmfMultipleMessage'" error is due to passing the wrong parameters to the call; your cross-domain policy shouldn't be the issue in this case.

If you give the parameters for your .NET method I should be able to form an actual call to drop into AS2 or AS3.  (I'm working on a tool for it, but it currently only works for MessageContracts.)

Apr 15, 2010 at 9:07 AM
Edited Apr 15, 2010 at 9:08 AM

The problem ist not the "message must be either 'AmfMessage' or 'AmfMultipleMessage'" error. This was just for testing with the browser if the amf-service is responding anything at all and the answer was "yes it is". So i think the server-side is fine.

The problem ist "_netConnection.connect(remotingGateway);" because it isn't connecting at all. The "_netConnection.connected" is false.

Apr 16, 2010 at 9:14 AM
Edited Apr 16, 2010 at 9:40 AM

Ok, got it working. The "_netConnection.connected"-attribute seems to be always false. From the as3 reference: NetConnection.connected - "Indicates whether the application is connected to a server through a persistent RTMP connection (true) or not (false). When connected through HTTP, this property is false, except when connected to Flash Remoting services on an application server, in which case it is true."

 

My probelm was the wrong call. I tried "_netConnection.call("HelloWorld", responder);" but it must be "_netConnection.call("WcfService.MyService.HelloWorld", responder);"

That's really really stupid, because there weren't any error, nor timeouts or exceptions. narf

Coordinator
Apr 16, 2010 at 4:18 PM

I must admit; I haven't tried using the NetConnection class - I've used the mx.remoting.Service class.  You can find documentation for it here:

http://wcfflashremoting.codeplex.com/wikipage?title=Action%20Script%202.0%20Sample