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

Issue Type: Bug Created: 2009-05-22T02:09:31.000+0000 Last Updated: 2009-06-03T00:52:11.000+0000 Status: Resolved Fix version(s): - 1.8.3 (09/Jun/09)

Reporter: Sunil (sunilbg) Assignee: Wade Arnold (wadearnold) Tags: - Zend_Amf

Related issues: Attachments: -


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


Posted by Sunil (sunilbg) on 2009-05-22T02:10:36.000+0000

This is using Java

Posted by Sunil (sunilbg) on 2009-05-22T02:11:27.000+0000

This is using flex

Posted by Wade Arnold (wadearnold) on 2009-05-22T08:30:59.000+0000

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

Thanks! Wade

Posted by Stanislav Malyshev (stas) on 2009-05-22T10:03:17.000+0000

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?

Posted by Sunil (sunilbg) on 2009-05-25T00:32:24.000+0000

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

Posted by Sunil (sunilbg) on 2009-05-25T00:35:41.000+0000

The java project to test

Posted by Sunil (sunilbg) on 2009-05-25T00:37:07.000+0000

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

Posted by Stanislav Malyshev (stas) on 2009-06-01T08:56:15.000+0000

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?

Posted by Sunil (sunilbg) on 2009-06-01T09:56:16.000+0000

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

Posted by Sunil (sunilbg) on 2009-06-01T10:18:01.000+0000

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.

Posted by Stanislav Malyshev (stas) on 2009-06-03T00:52:10.000+0000

Fixed, thanks.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.