请求参数可以定义如下
@XmlAccessorType(XmlAccessType.FIELD)
public class WebServiceReq {
@XmlElement(name="PROP1", required = true)
private String prop1;
@XmlElement(name="PROP2", required = true)
private String prop2;
@XmlElement(name="PROP3")
private String prop3;
}
@XmlAccessorType(XmlAccessType.FIELD)
必须添加@XmlElement(name="PROP1", required = true)
,这里的name则是请求参数名称,默认为prop1,required
表示是否必须。
如果请求参数中包含List,那么可以定义如下
@XmlAccessorType(XmlAccessType.FIELD)
public class WebServiceReq implements Serializable {
@XmlElement(name="ITEM", required = true)
private List<Item> items;
public List<Item> getItems() {
return items;
}
public void setItems(List<Item> items) {
this.items = items;
}
}
@XmlAccessorType(XmlAccessType.FIELD)
public class Item {
@XmlElement(name="PROP1", required = true)
private String prop1;
@XmlElement(name="PROP2", required = true)
private String prop2;
@XmlElement(name="PROP3")
private String prop3;
...
}
需要注意得是,List中的泛型对象也需要添加@XmlAccessorType(XmlAccessType.FIELD)