Apache flex FlexSOAP集合解码
有人知道为什么Flex 4.6 SOAP解码器会在对象中基于arraycollectionbased属性的第一个元素中添加解码的arraycollection吗 BarCollection从ArrayCollection扩展而来 预期:Apache flex FlexSOAP集合解码,apache-flex,soap,flex4.5,decoding,Apache Flex,Soap,Flex4.5,Decoding,有人知道为什么Flex 4.6 SOAP解码器会在对象中基于arraycollectionbased属性的第一个元素中添加解码的arraycollection吗 BarCollection从ArrayCollection扩展而来 预期: Object -- someProperty:BarCollection --[0] item:Foo --[1] item:Foo 得到: 该集合通过 SchemaTypeRegistry.getInstance.
Object
-- someProperty:BarCollection
--[0] item:Foo
--[1] item:Foo
得到:
该集合通过
SchemaTypeRegistry.getInstance.registerCollectionClass-方法
SchemaTypeRegistry.getInstance().registerCollectionClass(new QName("http://www.world.com/Foo", "BarCollection"), BarCollection);
乔里多
我回顾了我的步骤,发现我创造的东西和我从下面引用的样本中得到的东西之间的第二个差异似乎是真正的原因
我的ArrayCollection实例变量是由getter/setter函数创建的。当我将其更改为公共变量时,就像示例代码一样,它成功了!这是非常令人失望的,因为我现在必须考虑改变我的VO类。
为了不轻易放弃,我设想mx.rpc.xml类正在使用反射,因此也许我可以看看如何改变对的处理。在我的代码/数据和发布在该站点上的内容之间,我可以辨别出的关键区别是我在模式中声明集合/数组的方式
在我的模式中,我以以下方式声明了一个集合:
<complexType name="Things">
<sequence>
<element name="thing" type="ids:Thing" minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
<complexType name="ParentThing">
<complexContent>
<sequence>
<element name="things" type="Things"/>
</sequence>
<complexContent>
</complexType>
在上面链接的站点的代码中,集合的声明更直接:
<xs:complexType name="example">
<xs:sequence>
...
<xs:element name="items">
<xs:complexType>
<xs:sequence>
<xs:element name="item" type="item" maxOccurs="5"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
如果您被抛出,示例是示例代码中的一个类型和一个元素。在研究示例代码的工作方式时,这让我很扫兴。我更喜欢只将类型/类大写的惯例
无论如何,示例代码是有效的,模式差异似乎是唯一重要的差异。看看他和我的XML实例,没有什么不同。每个集合都由一个具有复数名称的元素作为父对象。即有实例,而有实例
我很想知道您的模式和/或XML实例是什么样子的,如果您的案例中可以更改模式,是否可以更改它以匹配上面的示例来解决问题。谢谢您的回答 使属性成为ArrayCollection类型的公共变量似乎是可行的。 我没有设法在getter中实例化字段 你的意思是这样的
private var _collection:CustomCollection;
public function get collection():CustomCollection {
if(!_collection)
_collection = new CustomCollection()
return _collection;
}
public function set collection(value:CustomCollection):void {
_collection = value;
}
但这似乎只适用于纯数组集合。
我的CustomCollection扩展了CollectionBase,后者扩展了ArrayCollection。
如果我切换到自定义集合而不是ArrayCollection,上面列出的技巧似乎不起作用
如果有时间,我将再次运行XML解码器。JoriDor,对不起。即使使用ArrayCollection,我对上述需求初始化实例化的实现也无法正常工作。我还没有找到一个办法使它发挥作用。非常抱歉,好悲伤。。。评论超时。这是一种平衡:不过,公共getter/setter确实有效。setValue中XMLDecoder的第2213行将该值推送到现有iterable上,即TypeIterator.isIterableexistingValue evals为true。这就是罪犯。我认为逻辑应该集中于价值观,而不是推动价值观。
private var _collection:CustomCollection;
public function get collection():CustomCollection {
if(!_collection)
_collection = new CustomCollection()
return _collection;
}
public function set collection(value:CustomCollection):void {
_collection = value;
}