java - 无法解析复杂类型的属性

标签 java web-services jaxb

我正在使用 eBay 的查找服务,除了解析 unitPrice 之外,一切正常。它说here :

eBay uses the UnitType and UnitQuantity

所以在我的 UnitPriceInfo.java 中我有这个:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "UnitPriceInfo", propOrder = { "type", "quantity", "any" })
public class UnitPriceInfo
{
    @XmlElement(name = "UnitType")
    protected String type;
    @XmlElement(name = "UnitQuantity")
    protected Double quantity;
    @XmlAnyElement(lax = true)
    protected List<Object> any;

但是,UnitPriceInfo 对象仍然被实例化,但它们的类型和数量字段始终为空。

我需要将类型从 String 和 Double 更改为 UnitTypeUnitQuantity 吗?如果没有,问题出在哪里?

最佳答案

这些元素被命名为typequantity,如下所示:

  <unitPrice>
    <quantity> double </quantity>
    <type> string </type>
  </unitPrice>

您应该将注释更改为 @XmlElement(name="type")@XmlElement(name="quantity")

关于java - 无法解析复杂类型的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24888135/

相关文章:

java - 替换字符串中的连续字符

java - 我怎样才能让我的输出反向读取我的二进制数?

java - REST Web 服务与 JSON 服务

java - 用于使用 SOAP - WSDL 的命令行 java 客户端

java - Android依赖性Symja将不会在gradle中加载

java - 如何在java中读取在unix中声明的变量

java - 通过 Web 服务和重复间隔进行 BIP 调度

maven - Axis2 数据绑定(bind) jaxbri + Maven : JAX-B RI JARs not on classpath

java - 无法使用 XMLReader 访问特定的 XML 元素

java - @XmlElements 和@XmlJavaTypeAdapter 不能一起工作