【发布时间】:2012-05-18 17:58:25
【问题描述】:
我有这个类颜色:
public class Color {
private String name;
private List<String> usedInShapes;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<String> getUsedInShapes() {
if (usedInShapes== null) {
return null;
}
return new ArrayList<String>(usedInShapes);
}
}
并且返回这个 bean 是在具有 Color 对象列表的包装器上返回的
public class ColorListResponse {
private final List<Color > colorList;
@XmlElement(required=true)
public List<Color> getColorList() {
return colorList;
}
}
当方法被调用时,用户会得到类似的响应
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getColorsResponse xmlns:ns2="http://example.com/ws">
<return>
<colorList>
<name>YELLOW</name>
</colorList>
<colorList>
<name>BLUE</name>
</colorList>
<colorList>
<name>RED</name>
</colorList>
<colorList>
<name>BROWN</name>
</colorList>
</return>
</ns2:getColorsResponse>
</S:Body>
</S:Envelope>
我需要的是这样的:
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
<S:Body>
<ns2:getColorsResponse xmlns:ns2="http://example.com/ws">
<return>
<colorList>YELLOW</colorList>
<colorList>BLUE</colorList>
<colorList>RED</colorList>
<colorList>BROWN</colorList>
</return>
</ns2:getColorsResponse>
</S:Body>
</S:Envelope>
我一直在尝试弄乱注释但没有成功...
【问题讨论】:
标签: java web-services soap jax-ws java-metro-framework