У меня есть этот XML:
<account-holder>
<first-name>John</first-name>
<last-name>Doe</last-name>
<address>
<street1>123 anystreet</street1>
</address>
</account-holder>
<shipping>
<first-name>Manon</first-name>
<last-name>Mertens</last-name>
<address>
<street1>Rue de la Loi 1</street1>
</address>
<shipping-method>home_delivery</shipping-method>
</shipping>
Как видите, у меня есть в 2 местах тег address
.Это JAXB, который я использую:
Основной класс:
@XmlRootElement(name = "payment")
@XmlAccessorType(XmlAccessType.FIELD)
public class AuthorizeRequest {
@XmlElement(name = "account-holder")
public AccountHolder accountHolder;
@XmlElement(name = "shipping")
public Shipping shipping;
}
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class AccountHolder {
....
@XmlElement(name = "address")
private Address address;
}
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Shipping {
....
@XmlElement(name = "address")
private Address address;
}
Адрес:
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Address {
@XmlElement(name = "street1")
private String street1;
@XmlElement(name = "street2")
private String street2;
}
Но я получаю исключение:
Two classes have the same XML type name "{http://www.elastic-payments.com/schema/payment}address". Use @XmlType.name and @XmlType.namespace to assign different names to them.
Знаете ли вы, как я могу решить эту проблему?