Those days had problems on getting to work zend_amf on a production server.
On my developement machine everything was working fine. Services were working, sending strings, arrays and custom VO’s from and to flex was working like a charm.
Once uploaded via ftp to the production server I started testing and got into the famous “Unable to parse null body data…” error.
google(Unable to parse null body data zend_amf)
Magically after 5 hours reading blog posts and official zend’s jira i got myserlf lost. I had typed VO’s going our from the services but no way to send from flex a VO to a zend_amf Service.
The thing started working right when included directly the VO file in gateway.php
instanced in a variable and then echoed to the buffer file. see below Tweaked code
Once verified the class was instantiated and the trace was ok i switched back to the original gateway code and everything started working. see gateway.php
Now the question is.. is it a php5 common behaviour or a zend_amf problem?
Comments on this topic are welcome
Follows example code
Before tweak
[php]
require_once 'Zend/Amf/Server.php';
//include all the dao related files
require_once('include_dao.php');
$server = new Zend_Amf_Server();
$server->setProduction(true);
$server->addDirectory(dirname(__FILE__) .’/dao/’);
// as php
$server->setClassMap(‘User’,'User’);
echo($server->handle());
?>
[/php]
Tweaked
[php]
require_once 'Zend/Amf/Server.php';
//include all the dao related files
//require_once('include_dao.php');
// DO NOT IMPORT ALL THE CLASSES import directly the class
require_once('dao/vo/User.php');
$server = new Zend_Amf_Server();
$server->setProduction(true);
$server->addDirectory(dirname(__FILE__) .’/dao/’);
// as php
$server->setClassMap(‘User’,'User’);
// do not start server
//echo($server->handle());
// instance object
$myuser = new User();
// trace to page buffer
echo(print_r($myuser,true));
?>
[/php]
User.php in “dao/vo/”
[php]
/**
* Object representing record of table 'user'
*
* @author: MattiMatti
* @date: 2009-03-23 12:21
*/
class User{
// ZEND AMF DO NOT REQUIRE $_explicitType
function User(){
}
public $id;
public $code;
public $validated;
public $validationDate;
public $username;
public $password;
public $email;
}
?>
[/php]
include_dao.php in same folder as gateway.php
[php]
//include all DAO files
require_once('dao/DAOFactory.php');
require_once('dao/vo/User.php');
require_once('dao/UserController.php');
?>
[/php]
Tags: Actionscript, Bugs, Flex, php, Zend Amf
This entry was posted on Tuesday, March 24th, 2009 at 5:23 am
You can follow any responses to this entry through the RSS 2.0 feed.

Xing
LinkedIn
Twitter
Delicious
Facebook
Hi, gr8 post thanks for posting. Information is useful!
Bravo, very good idea