Flex从Zend AMF反序列化通用对象,而不是严格类型化的对象 [英] Flex is deserializing generic objects from Zend AMF instead of strictly typed objects
问题描述
我正在使用Zend AMF将远程对象发送到Flex。
我已经定义了 Constant
类并创建 getASClassName()
方法。然后,我在flex中创建了Action脚本类。
对象已成功发送,但在Flex中反序列化为通用的 Objects
而不是特定的对象。
编辑:在Flex的网络监视器上,我可以看到AMF值设置为 com.my.project.valueobjects.Constant
。尽管来自 event.result
的数组包含对象
。
我在做什么错?
Php类声明:
<?php
名称空间Project\Entity;
类常数
{
public $ id;
公共$ name;
公共$说明;
公有价值;
公共功能getASClassName(){
返回com.my.project.valueobjects.Constant;
}
}
flex中的类定义:
package com.my.project.valueobjects {
[Bindable]
[RemoteClass(alias = Constant )]
公共类常量{
public var id:Number;
public var name:String;
public var description:String;
public var value:String;
}
在php中处理Amf的部分代码:
$ server = new Zend_Amf_Server();
$ server = $ server-> setClass( AmfService);
$ server-> setClassMap( com.my.project.valueobjects.Constant, Constant);
来自php的对象数组(使用 print_r $ c $创建的转储c>):
[2012年3月4日14:23:08]数组
(
[0] =>项目\实体\常量对象
(
[id] => 1
[name] =>名称
[description] => ; desc
[value] => 5
[_explicitType] => com.my.project.valueobjects.Constant
)
$ b $ pre>
解决方案在Flex / PHP远程处理领域的另一个自我解答。 b
解决方案非常简单-我需要将
com.my.project.valueobjects.Constant
更改为Constant
希望这对以后的工作有所帮助。
I'm using Zend AMF to send my remote objects to Flex.
I've defined a
Constant
class and createdgetASClassName()
method. Then I've created Action script class in flex.Objects are send successfully, but they are deserialized to generic
Objects
in Flex instead of specific ones.EDIT: On network monitor in Flex I can see that AMF value is set to
com.my.project.valueobjects.Constant
. Although array fromevent.result
containsObjects
.What am I doing wrong?
Php declaration of class:
<?php namespace Project\Entity; class Constant { public $id; public $name; public $description; public $value; public function getASClassName(){ return 'com.my.project.valueobjects.Constant'; } }
Class definition in flex:
package com.my.project.valueobjects{ [Bindable] [RemoteClass(alias="Constant")] public class Constant{ public var id:Number; public var name:String; public var description:String; public var value:String; }
Part of code handling Amf in php:
$server = new Zend_Amf_Server(); $server = $server->setClass("AmfService"); $server->setClassMap("com.my.project.valueobjects.Constant", "Constant");
Array of objects from php (dump made using
print_r
):[04-Mar-2012 14:23:08] Array ( [0] => Project\Entity\Constant Object ( [id] => 1 [name] => name [description] => desc [value] => 5 [_explicitType] => com.my.project.valueobjects.Constant )
解决方案Another self-answer in the area of Flex/PHP remoting.
Solution was pretty easy - I needed to change
com.my.project.valueobjects.Constant
toConstant
in PHP side and it was everything.Hope this helps someone in the future.
这篇关于Flex从Zend AMF反序列化通用对象,而不是严格类型化的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!