Issue Details (XML | Word | Printable)

Key: ZF-6775
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Wade Arnold
Reporter: Sunil
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Google issue summary
Zend Framework

Unable to send arrays through AMF from Java

Created: 22/May/09 02:09 AM   Updated: 03/Jun/09 12:52 AM   Resolved: 03/Jun/09 12:52 AM
Return to search "Fixed in 1.5.1"
Component/s: Zend_Amf
Affects Version/s: 1.8.1
Fix Version/s: 1.8.3

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive PHPArray-debug.zip (4 kB)
2. Zip Archive TestAMF.zip (3 kB)

Image Attachments:

1. UsingAMFConnection.JPG
(59 kB)

2. UsingFlex.JPG
(51 kB)


 Description  « Hide

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.

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 = amfConnection.call(null, 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



Sunil added a comment - 22/May/09 02:10 AM

This is using Java


Sunil added a comment - 22/May/09 02:11 AM

This is using flex


Wade Arnold added a comment - 22/May/09 08:30 AM

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

Thanks!
Wade


Stanislav Malyshev added a comment - 22/May/09 10:03 AM

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?


Sunil added a comment - 25/May/09 12:32 AM

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/blazeds/download+blazeds+trunk 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


Sunil added a comment - 25/May/09 12:35 AM

The java project to test


Sunil added a comment - 25/May/09 12:37 AM

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


Stanislav Malyshev added a comment - 01/Jun/09 08:56 AM

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?


Sunil added a comment - 01/Jun/09 09:56 AM

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


Sunil added a comment - 01/Jun/09 10:18 AM

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.


Stanislav Malyshev added a comment - 03/Jun/09 12:52 AM

Fixed, thanks.