Channel.Connect.Failed错误NetConnection.Call.BadVersion

时间:2011-07-16 10:10:03

标签: php mysql flex serialization flash-builder

好的 - 所以我一直在寻找各地试图纠正这个问题 - 但我一直在寻找不同的答案,坦率地说,试图解决这个问题变得非常令人沮丧。 Lemme发布了一些代码供您查看:

PHP脚本:

public function addNewCompany(CompanyVO $item) 
{
    $stmt = mysqli_prepare($this->connection,
    "INSERT INTO `companies` ('companyName') VALUES (?);");
    $this->throwExceptionOnError();

    mysqli_bind_param($stmt, 's', $item->companyName);
    $this->throwExceptionOnError();

    mysqli_stmt_execute($stmt);
    $this->throwExceptionOnError();

    $autoid = mysqli_stmt_insert_id($stmt);
    mysqli_stmt_free_result($stmt);
    mysqli_close($this->connection);
    return $autoid;
}

MXML主应用程序的部分内容:

protected function companysignupsheet1_addCompanyEventHandler(event:AddCompanyEvent):void
        {
            companyservicero.addNewCompany({Data:event.companyData});
        } 

<s:RemoteObject id="companyservicero"
                    source="CompanyServices"
                    destination="addNewCompany"
                    endpoint = "http://localhost/PHP_RO/public/gateway.php"
                    result="companyservicero_resultHandler(event)"
                    fault="companyservicero_faultHandler(event)"/>

Component的一部分代码:

            protected function button_submitNewCompany_clickHandler(event:MouseEvent):void
        {
            var companyData11:CompanyVO = new CompanyVO();
            companyData11.companyName = textinput_NewCompanyName.text;

            var eventObject:AddCompanyEvent = new AddCompanyEvent("addCompanyEvent", companyData11);
            dispatchEvent(eventObject);
        }

活动:

     package events
     {
    import flash.events.Event;


    import valueObjects.CompanyVO;

    public class AddCompanyEvent extends Event
    {

    public var companyData:CompanyVO;

    public function AddCompanyEvent(type:String, companyData:CompanyVO)
    {
        super(type);
        this.companyData = companyData;
    }
}
}

如果我需要发布更多内容,我将很乐意这样做。另外 - 我知道尝试以这种方式发送一个文本值有点过分,但是当我开始工作时会有更多,更多的东西 - 我只是想集中在哪里问题是。哦 - 我不知道它是否有帮助......但是目前我可以从附加到的mySQL数据库中检索记录(虽然我没有通过RemoteObject方式这样做) - 我也可以添加到同一个表使用上面PHP的精确副本的旧拖放(连接到数据/服务)功能(尽管信息是用硬编码的(IE公司名= testtest))。

并完成所有关闭 - 早些时候我没有为参数定义数据类型:

public function addNewCompany($item){.....

对于addNewCompany - 它DID在数据库中添加一条记录,虽然它是空白的,它仍会弹出一条包含整个Channel.Connect等的错误消息.....现在在Zend Server的日志中它说的是数据将在stdClass包装器中传输,并且在CompanyVO数据类型中需要它。

我对这一切感到非常沮丧 - 我已经坚持这种类型的问题大约2-3天了,我放弃了!请帮忙。非常感谢你的时间和帮助!

-CS

编辑 - 更多信息

GATEWAY.PHP

<?php
ini_set("display_errors", 1);
$dir = dirname(__FILE__);
$webroot = $_SERVER['DOCUMENT_ROOT'];
$configfile = "$dir/amf_config.ini";
$servicesdir = $dir.'/../services';
$librarydir = $dir.'/../library';
//default zend install directory
$zenddir = $webroot.'/ZendFramework/library';
//Load ini file and locate zend directory
if (file_exists($configfile)) {
    $arr = parse_ini_file($configfile, true);
    if (isset($arr['zend']['webroot'])) {
        $webroot = $arr['zend']['webroot'];
        $zenddir = $webroot.'/ZendFramework/library';
    }
    if (isset($arr['zend']['zend_path'])) {
        $zenddir = $arr['zend']['zend_path'];
    }
    if (isset($arr['zend']['library'])) {
        $librarydir = $arr['zend']['library'];
    }
    if (isset($arr['zend']['services'])) {
        $servicesdir = $arr['zend']['services'];
    }
}
// Setup include path
// add zend directory, library and services to include path
set_include_path(get_include_path()
    .PATH_SEPARATOR.$zenddir
.PATH_SEPARATOR.$librarydir
.PATH_SEPARATOR.$servicesdir);
// Initialize Zend Framework loader
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true)-                          >suppressNotFoundWarnings(true);
// Load configuration
$default_config = new Zend_Config(array("production" => false), true);
$default_config->merge(new Zend_Config_Ini($configfile, 'zendamf'));
$default_config->setReadOnly();
$amf = $default_config->amf;
// Store configuration in the registry
Zend_Registry::set("amf-config", $amf);
// Initialize AMF Server
$server = new Zend_Amf_Server();
$server->setProduction($amf->production);
if (isset($amf->directories)) {
    $dirs = $amf->directories->toArray();
    foreach ($dirs as $dir) {
        if ($dir == "./") {
            $server->addDirectory($webroot);
        } else 
            if (realpath("{$webroot}/{$dir}")) {
                $server->addDirectory("{$webroot}/{$dir}");
            } else 
                if (realpath($dir)) {
                    $server->addDirectory(realpath($dir));
                }
    }
}
// Initialize introspector for non-production
if (! $amf->production) {
    $server->setClass('Zend_Amf_Adobe_Introspector', '', 
    array("config" => $default_config, "server" => $server));
    $server->setClass('Zend_Amf_Adobe_DbInspector', '', 
    array("config" => $default_config, "server" => $server));
}
// Handle request
echo $server->handle();

AMF_CONFIG

[zend]
;set the absolute location path of webroot directory, example:
;Windows: C:\apache\www
;MAC/UNIX: /user/apache/www
 webroot = "C:/Zend/Apache2/htdocs"

;set the absolute location path of zend installation directory, example:
;Windows: C:\apache\PHPFrameworks\ZendFramework\library
;MAC/UNIX: /user/apache/PHPFrameworks/ZendFramework/library
zend_path ="C:/Zend/Apache2/htdocs/.metadata/.plugins/org.zend.php.framework.resource/resources/ZendFramework-1/library"
library ="C:/Zend/Apache2/htdocs/PHP_RO/library"
services ="C:/Zend/Apache2/htdocs/PHP_RO/services"

[zendamf]
amf.production = false
amf.directories[]=PHP_RO/services

1 个答案:

答案 0 :(得分:1)

Channel.Connect.Failed错误NetConnection.Call.BadVersion通常在PHP回复amf响应的错误或警告时发生。 Flex获取一条amf消息,附加了“警告第X行出错”并且无法解析它的内容。 在Flash Builder中打开网络监视器并查看最新的原始响应。您将看到使用html标签格式化的错误。