ElementList

时间:2016-02-12 12:13:04

标签: java android magento soap simple-framework

我收到错误

  

Android Magento Soap Api org.simpleframework.xml.core.PersistenceException:元素'结果'已经与@ org.simpleframework.xml.ElementList一起使用

当我使用Soap请求从Magento获取catalogProductMedia时。以下是XML文件和类。

CatalogProductAttributeMediaListResponse.xml

<message name="catalogProductAttributeMediaListResponse">
<part name="result" type="typens:catalogProductImageEntityArray"/>
</message>

CatalogProductAttributeMediaListResponse.java

    @Root(name = CatalogProductAttributeMediaListResponse.ROOT_NAME, strict = false)
public class CatalogProductAttributeMediaListResponse {

    public static final String ROOT_NAME = "n0:catalogProductAttributeMediaListResponse";

    @Element(required = false)
    @Path("Body/catalogProductAttributeMediaListResponse")
    private CatalogProductImageEntityArray result;
}

CatalogProductImageEntityArray.xml

<complexType name="catalogProductImageEntityArray">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="typens:catalogProductImageEntity[]"/>
</restriction>
</complexContent>
</complexType>

CatalogProductImageEntityArray.java

@Root(name = "catalogProductImageEntityArray", strict = false)
public class CatalogProductImageEntityArray {
    @ElementList(inline = true, entry = "item", required = false)
    private List<CatalogProductImageEntity> productImageEntityList;
}

CatalogProductImageEntity.xml

<complexType name="catalogProductImageEntity">
<all>
<element name="file" type="xsd:string"/>
<element name="label" type="xsd:string"/>
<element name="position" type="xsd:string"/>
<element name="exclude" type="xsd:string"/>
<element name="url" type="xsd:string"/>
<element name="types" type="typens:ArrayOfString"/>
</all>
</complexType>

CatalogProductImageEntity.java

@Root(name = "catalogProductEntity", strict = false)
public class CatalogProductImageEntity {
    @Element(required = false)
    private String url;
}

我只想获取网址,我已经生成了所有的getter和setter方法。请帮助我

1 个答案:

答案 0 :(得分:1)

尝试注释结果

@Element(required = false, inline=true)
@Path("Body/catalogProductAttributeMediaListResponse")
private CatalogProductImageEntityArray result;