Getting the Fluorine AuthenticateWebApp to work with RemoteObjectAMF0

Posted by Dennis on Sep 12, 2007 in 3D, ActionScript, Flex, Remoting4 comments

I’ve been trying to set up the AuthenticeWebApp demo application that comes with the Fluorine .NET Flash Remoting Gateway. I used Flex 2 and .Net 2.0 for this. When I first ran the project with this remoteobject tag:


<mx:RemoteObject id="loginRO" destination="login" source="AuthenticateWebApp.MyLoginService">
<mx:method name="Login" result="loginResult(event)" fault="loginFault(event)" />
</mx:RemoteObject>

I got this error:


TypeError: Error #1034: Type Coercion failed: cannot convert Object@6b14841 to mx.messaging.messages.ErrorMessage.

After some Googling if found that Renaun’s RemoteObject implementation (RemoteObjectAMF0) should solve this problem. So I replaced the mx:RemoteObject tag with a renaun:RemoteObjectAMF0 tag:


<renaun:RemoteObjectAMF0
	id="loginRO"
	destination="login"
	endpoint="http://localhost/AuthenticateWebApp/Gateway.aspx"
	source="AuthenticateWebApp.MyLoginService"
	showBusyCursor="true"
	makeObjectsBindable="true"
	result="loginResult(event)"
	fault="loginFault(event)"/>

After a rebuild I got a new error:


com.renaun.rpc.RemotingConnection was unable to invoke callback RequestPersistentHeader. error=ReferenceError: Error #1069: Property RequestPersistentHeader not found on com.renaun.rpc.RemotingConnection and there is no default value.

Google came up with this discussion.. If you scroll down a little you can see a bit of code that alters the com.renaun.rpc.RemotingConnection class:


import flash.net.NetConnection;
import flash.net.ObjectEncoding;

public class RemotingConnection extends NetConnection
{
	private var originalUrl:String;
	private var urlSuffix:String;

	public function RemotingConnection(gatewayURI:String)
	{
			this.originalUrl = gatewayURI;
			this.objectEncoding = ObjectEncoding.AMF0;
			if (gatewayURI) super.connect(gatewayURI);
	}

	public function setCredentials(userId:String, password:String):void
	{
			super.addHeader("Credentials",false,{userid:userId,password:password});
	}

	public function AppendToGatewayUrl(urlSuffix:String):void
	{
			this.urlSuffix = urlSuffix;
			if (this.originalUrl == null)
			{
					this.originalUrl = uri; //???
			}
			var u:String = this.originalUrl + this.urlSuffix;
			super.connect(u);
	}

	private function ReplaceGatewayUrl(newUrl:String):void
	{
			super.connect(newUrl);
	}

	public function RequestPersistentHeader(info:Object ):void
	{
			super.addHeader(info.name, info.mustUnderstand, info.data);
	}
}

With this altered class it works like it should, without errors. I don’t know why this isn’t in the current RemoteObjectAMF0 implementation. If anybody knows more about this, please let me know!



Tags: , , ,


4 comments

» Comments RSS Feed
  1. Just curious why you’d rather use .NET & RemoteObjectAMF0 than AMFPHP?

  2. Hey Cayennecode,
    The company I work is specialized in .Net … no PHPers in the house :-)
    Dennis

  3. I will have to make the update, was not made aware of the issue. I tested Fluorine an never had the issue. But that was a long time ago.
    thx,

  4. Did this, worked, but now I’m getting the error : “ILoginCommand was not found…

    thx, Lieven Cardoen.

Leave a comment