Java and AMF by AS3 in Flash

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

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())
                {
                    System.out.println("---------------");
                    body = (AMFBody) iterator.next();
                    System.out.println("type description " +     
                    body.getObjectTypeDescription(body.getType()));
                    System.out.println("response " + body.getResponse());
                    System.out.println("service method name " +     
                                        body.getServiceMethodName());
                    System.out.println("service name " + body.getServiceName());
                    System.out.println("target " + body.getTarget());
                    System.out.println("value " + body.getValue());
                    System.out.println("----------------");
                }
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");
nc.call("func_name",res,"a_array");

But I obtain the following error:

java.io.IOException: Unknown/unsupported object type UNKNOWN: 0x10001
        at org.openamf.io.AMFDeserializer.readData(AMFDeserializer.java:350)
        at org.openamf.io.AMFDeserializer.readArray(AMFDeserializer.java:226)
        at org.openamf.io.AMFDeserializer.readData(AMFDeserializer.java:335)
        at org.openamf.io.AMFDeserializer.readBodies(AMFDeserializer.java:144)

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!

2 comments:

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

http://www.soapui.org/xref/com/eviware/soapui/impl/wsdl/panels/teststeps/amf/SoapUIAMFConnection.html