Java and AMF by AS3 in Flash

The interaction between Java and Flash
(part 2 - OpenAMF)


Download the jar and add the library in the web project.

Make a simple servlet and inside "processRequest" put this instruction

AMFDeserializer amfDeserializer = new AMFDeserializer(new DataInputStream(request.getInputStream()));

System.out.println("bodies String " + amfDeserializer.getAMFMessage().getBodiesString());

See at server.log and you understand that library works, so go deep inside in deserialization

Go to see other details in AMFMessage:

Iterator iterator = amfMessage.getBodies();
                AMFBody body = null;

                while (iterator.hasNext())
                    body = (AMFBody);
                    System.out.println("type description " +     
                    System.out.println("response " + body.getResponse());
                    System.out.println("service method name " +     
                    System.out.println("service name " + body.getServiceName());
                    System.out.println("target " + body.getTarget());
                    System.out.println("value " + body.getValue());
It works also!!wonderful
But Now I want to send an array thru action script:

so in the call funcion I pass an array

var oneArray:Array = new Array("a", "b", "c");"func_name",res,"a_array");

But I obtain the following error: Unknown/unsupported object type UNKNOWN: 0x10001

After some hours I found the problem.
I try to change in as3 client code the AMF encoding:

nc.objectEncoding = ObjectEncoding.AMF0;

And I discover that OpenAMF supports only the AMF0 encoding.
I see also at latest update in sourceforge: 
the date time is 2006 year. It seems and old solution and not maintained.

Switch to see in part3 other solution!


pseudoaleatorio said...
This comment has been removed by the author.
pseudoaleatorio said...

Here I have found some code that worked well for me; it uses the Adobe blazeds Java client which is open-source; make sure to get the latest version of the library from Adobe

Translate the blog