Zend Framework

Unable to send arrays through AMF from Java

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.8.1
  • Fix Version/s: 1.8.3
  • Component/s: Zend_Amf
  • Labels:
    None

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.

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

Activity

Hide
Sunil added a comment -

This is using Java

Show
Sunil added a comment - This is using Java
Hide
Sunil added a comment -

This is using flex

Show
Sunil added a comment - This is using flex
Hide
Wade Arnold added a comment -

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

Thanks!
Wade

Show
Wade Arnold added a comment - Not being a java guy can you upload your java files that I could use to test this? Thanks! Wade
Hide
Stanislav Malyshev added a comment -

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?

Show
Stanislav Malyshev added a comment - 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?
Hide
Sunil added a comment -

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

Show
Sunil added a comment - 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
Hide
Sunil added a comment -

The java project to test

Show
Sunil added a comment - The java project to test
Hide
Sunil added a comment -

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

Show
Sunil added a comment - The php files and the zend gateway.php file are part of this zip
Hide
Stanislav Malyshev added a comment -

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?

Show
Stanislav Malyshev added a comment - 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?
Hide
Sunil added a comment -

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

Show
Sunil added a comment - 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
Hide
Sunil added a comment -

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.

Show
Sunil added a comment - 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.
Hide
Stanislav Malyshev added a comment -

Fixed, thanks.

Show
Stanislav Malyshev added a comment - Fixed, thanks.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: