我有一个服务方法定义为:
public JaxbList<Deal> getDeal() {
List<Deal> deals = new ArrayList<Deal>();
Deal type = new Deal();
type.setDealID(1);
type.setName("June Discounts");
deals.add(type);
JaxbList list = new JaxbList(deals);
System.out.println("List size -> " + list.getList().size());
return list;
}
我的客户定义为:
WebClient client = WebClient.create("....");
JaxbList deals = client.path("exampleservice/getDeal")
.accept("application/xml").get(JaxbList.class);
List<Deal> types = deals.getList();
当我在服务方法中打印出集合的大小时,结果返回为 1。但是,来自客户端的“类型”列表的大小为 0。当我在浏览器中打开时,显示 1 个交易。所以,这个问题似乎是我的客户。我不确定在哪里。
想法?
这是我的 JaxbList 类:
public class JaxbList<T>{
protected List<T> list;
public JaxbList(){}
public JaxbList(List<T> list){
System.out.println("Setting list...");
this.list=list;
}
@XmlElement(name="Item")
public List<T> getList(){
return list;
}
}