【发布时间】:2011-04-15 19:49:13
【问题描述】:
我正在尝试使用Spring RestTemplate 来检索员工记录列表,例如:
public List<Employee> getEmployeesByFirstName(String firstName) {
return restTemplate.getForObject(employeeServiceUrl + "/firstname/{firstName}", List.class, firstName);
}
问题是 Web 服务(被调用)返回以下 XML 格式:
.... 员工> .... 员工> 员工>
所以在执行上面的方法时,我得到以下错误:
org.springframework.http.converter.HttpMessageNotReadableException: Could not read [interface java.util.List]; nested exception is org.springframework.oxm.UnmarshallingFailureException: XStream unmarshalling exception; nested exception is com.thoughtworks.xstream.mapper.CannotResolveClassException: **employees : employees**
【问题讨论】:
-
我确实将属性“aliases”设置为包含一组值(如“employees”)和我们想要的结果类“org....Employees”的映射。希望能有所帮助。
标签: spring xstream resttemplate