我试图用来Spring RestTemplate检索员工记录列表,例如:
public List<Employee> getEmployeesByFirstName(String firstName) {
return restTemplate.getForObject(employeeServiceUrl + "/firstname/{firstName}", List.class, firstName);
}
Run Code Online (Sandbox Code Playgroud)
问题是Web服务(被调用)返回以下XML格式:
<employees> <employee> .... </ employee> <employee> .... </ employee> </ employees>
所以当执行上面的方法时,我得到以下错误:
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**
Run Code Online (Sandbox Code Playgroud)