我正在使用Resteasy處理RestWebService。基本實現工作正常。知道我試圖通過休息返回一個複雜對象... 其實它很容易..我想。我得到一個問題,因爲我嵌套的對象(地址)的...TomEE Resteasy JAX-B - >無法獲取嵌套對象
我嘗試是這樣的:
@XmlRootElement(name = "person")
@XmlAccessorType(XmlAccessType.FIELD)
public class Person implements Serializable {
private static final long serialVersionUID = 1199647317278849602L;
private String uri;
private String vName;
private String nName;
private Address address;
.....
@XmlElementWrapper(name="Former-User-Ids")
@XmlElement(name="Adress")
public Address getAddress() {
return address;
}
....
地址如下:
@XmlRootElement(name = "address")
@XmlAccessorType(XmlAccessType.FIELD)
public class Address {
private String uri;
private String street;
private String city;
public String getCity() {
return city;
}
public String getStreet() {
return street;
}
....Restservice看起來像這樣。它完美無地址對象..
@Path("/getPersonXML/{personNumber}")
@GET
@Produces(MediaType.APPLICATION_XML)
public Patient getPatientXML(@PathParam("personNumber") String personNumber) throws ParseException {
Address a1 = new Address("de.person/address/" + "432432","Teststret12","TestCity", "32433", "TestCountry", "081511833");
Patient p1 = new Person();
p1.setAddress(a1);
p1.setUri("de.spironto/person/"+ "432432");
p1.setnName("Power");
p1.setvName("Max");
return p1;
}
目前,我總是得到一個
javax.xml.bind.JAXBException:
什麼想法?