ZF-6775: Unable to send arrays through AMF from Java


Summary: , I'm sending a Java Primitive Array(String[]) in Java and it is going as Array Reference and this is not being deserialized correctly by the Zend PHP framework, however it works fine when I call this from a Flex Project, where an Array is sent and not Array Reference. (Attached are the images which show the AMF request being sent)


I have a php class which has a method as shown below.

public function testarray($arr) { return $arr; }

I'm invoking this method using the AMFConnection class available as part of BlazeDS (, through the following code.

AMFConnection amfConnection = new AMFConnection(); amfConnection.setObjectEncoding(3); amfConnection.setInstantiateTypes(false);

Object[] args = new Object[1]; args[0] = new String[]{"a","b"}; amfConnection.connect("http://localhost/phpproject/gateway.php");

RemotingMessage message = new RemotingMessage(); message.setMessageId(flex.messaging.util.UUIDUtils.createUUID()); message.setOperation("testArray"); message.setBody(args); message.setSource("testPhp"); message.setDestination("GenericDestination");

returnValue =, message);

The return value from the server is the argument that is passed, i.e. I should get the array with strings a,b, but I'm getting 0 as the arguments were not passed correctly


This is using Java

This is using flex

Not being a java guy can you upload your java files that I could use to test this?

Thanks! Wade

I tested string arrays on flex (a = ["a", "b"]) and it works just fine. I can not test Java code here. Could you please have Flex example that reproduces the problem so I could test it?

It works only in Flex application, it does not work in Java. Attached are the Java and PHP files.

a. Import the attached TestAMF java project in eclipse b. download the blazeds.war file from… and extract that and add the following 2 jars in the libraries section of project properties. flex-messaging-core.jar and flex-messaging-common.jar c. extract the to your webroot and make sure your zend installation is there @ webroot d. run the applicaiton, notice the return value is 0 instead of the array a, b which is passed from Java

The java project to test

The php files and the zend gateway.php file are part of this zip

If it works with flex, then how do you know the problem is with our code? What Java does differently from flex so flex works but Java doesn't?

We are using the Java Implementation of flash's Netconnection as indicated in the earlier cmment which is the AMFConnection class. It is sending an ArrayReference. An ArrayReference in Java is just a reference to an already declared array in the AMF body. According to AMF protocol, any AMF supporting backend should support ArrayReferences too

Also, If you notice in the AMF message, the body returns the internal "parameters" list. There's also a parameters value that has the original "parameters" list as well which means that both "body" and "parameters" refer to the same object and the one that you are getting in the body is ArrayReference.

Fixed, thanks.