Description

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)

Description:

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 (flex.messaging.io.amf.client.AMFConnection), through the following code.

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

Comments

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 http://opensource.adobe.com/wiki/display/… 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 phparray-debug.zip 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.