I am trying to use ZendAMF to do remote method calls to a MySQL database from Flash and I keep recieving the NetConnection.Call.BadVersion error.
My Server is working correctly. Apache 2.2.14
My PHP is working correctly. PHP 5.2.11
My Database is working. MySQL 5.0
UPDATE: My first problem was a security error in Flash. If you try to run a local SWF from the Flash IDE to a web service online, you'll get a security warning which will throw the BadVersion error. However, the security error won't show up if you 'TEST MOVIE' so it took me a while to realize that. I changed my testing process to remove this variable. I am now able to implement my php class code successfully using AMFPHP, which essentially rules out my class as the issue (I think). It seems to be a problem with the Zend implemntation of AMF.
I have followed a tutorial from Lee Brimlow here: http://www.gotoandlearn.com/play.php?id=90 . I was unable to get this to work locally, and I've moved my content onto a web server and can call the Class and Method from my SWF. I've used Charles to view the response. When I go to validate the response in Charles I get this:
Validator: Failed to Parse XML Document.
Reason: An invalid XML character (Unicode: 0x0) was found in the CDATA section.
Line: 65 Column: 87
Any ideas how to fix this? Can it be handled in PHP?
Here is my ZendAMF code:
<?php
error_reporting(E_ALL|E_STRICT);
ini_set("display_errors", "on");
ini_set("include_path", "./frameworks");
require_once 'Zend/Amf/Server.php';
require_once 'Animal.php';
$server = new Zend_Amf_Server();
$server->setClass("Animal");
$server->setProduction(false);
$response = $server->handle();
echo $response;
?>
Here is my PHP Class code: (note no closing ?> tag.)
<?php
class Animal
{
public function __construct()
{
include "dbinfo.inc.php";
$linkID = mysql_connect('localhost', $username, $password) or die("Could not connect to host.");
mysql_select_db($database, $linkID) or die( "Unable to select database.");
}
public function getAnimalQuotes()
{
$result = mysql_query("SELECT * FROM AnimalQuotes");
$t = array();
while($row = mysql_fetch_assoc($result))
{
array_push($t, $row);
}
return $t;
}
}
I've updated my Flash Player to 10.1. I'm publishing my swf to Flash 10/AS3.
I'm still getting this error when I run my SWF.
Error #2044: Unhandled NetStatusEvent:. level=error, code=NetConnection.Call.BadVersion
at ZendAMF_fla::MainTimeline/frame1()
Here is my AS3 code:
import flash.net.*;
var nc:NetConnection = new NetConnection();
nc.connect("http://www.pbjs.com/2010/");
var res:Responder = new Responder(onResult, onFault);
nc.call("Animal.getAnimalQuotes", res);
function onResult(e:Object):void
{
trace (e);
}
function onFault(e:Object):void
{
for (var i in e){
trace(e[i]);
}
}