在我的web服务,我想返回对象的集合取决于例如客户端请求对象的集合(字符串的集合,定制类..), 我的代码:返回从JAX_WS Web服务
@XmlRootElement(name="ResultObject")
public class ResultObject
{
private Object _Contents; // this object should contain the collection
private int _ErrorCode;
.....
}
而是试图返回一个ArrayList或字符串数组以下异常出现时:
二零一二年十二月三十日下午5时49分21秒 com.sun.xml.ws.transport.http.servlet。 WSServletDelegate doGet SEVERE: catch throw javax.xml.ws.W ebServiceException: javax.xml.bind.MarshalException - 带有链接的异常:[javax.xml.bind.JAXBException:类java.util.ArrayList或其任何超类已知此 上下文。] at com.sun .xml.ws.message.jaxb.JAXBMessage.writePayloadTo(JAXBMessage.java:322) at com.sun.xml.ws.message.AbstractMessageImpl.writeTo(AbstractMessageImpl.java:142) at com.sun.xml.ws .encoding.StreamSOAPCodec.encode(StreamSOAPCodec.java:108) at com.sun.xml.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:265) at com.sun.xml.ws.transport.http.HttpAdapter .encodePacket(HttpAdapter.java:320) at com.sun.xml.ws.transport.http.HttpAdapter.access $ 100(HttpAdapter.java:93) at com.sun.xml.ws.transport.http.HttpAdapter $ HttpToolkit.handle(HttpAdapter.java:454) at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:244) at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:135) at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doGet(WSServletDelegate.java:129) at com.sun.xml.ws.transport.http.servlet.WSServletDelegate.doPost(WSServletDelegate.java:160) at com.sun.xml.ws.transport.http.servlet.WSServlet.doPost(WSServlet.java: 75) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:641) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
搜索解决方案后的一些帖子建议使用注释,但_Contents对象是动态收集,我无法修复它的内容。
请指教,谢谢。