users@glassfish.java.net

Webservices and any type

From: <glassfish_at_javadesktop.org>
Date: Tue, 04 Dec 2007 04:26:58 PST

I try to return list of POJO objects of diferent types from webservice. I try something like this:

@Stateless
@WebService
public class TestSessionBean implements TestSessionLocal {
    @WebMethod
    public List test() {
        ArrayList list = new ArrayList();
        list.add(new TestValue("1","ok","ojojo"));
        list.add(new TestValueRoot("2","bad"));
        return list;
    }
}
Is it possible ? I have null pointer exception:

javax.servlet.ServletException: java.lang.reflect.InvocationTargetException at com.sun.enterprise.webservice.monitoring.WebServiceTesterServlet.doPost(WebServiceTesterServlet.java:340) at com.sun.enterprise.webservice.monitoring.WebServiceTesterServlet.invoke(WebServiceTesterServlet.java:121) at com.sun.enterprise.webservice.EjbWebServiceServlet.service(EjbWebServiceServlet.java:114) at javax.servlet.http.HttpServlet.service(HttpServlet.java:831) at com.sun.enterprise.web.AdHocContextValve.invoke(AdHocContextValve.java:114) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:87) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:206) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:150) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:632) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:577) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:571) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1080) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:270) at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:637) at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:568) at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:813) at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:339) at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:261) at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:212) at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265) at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sun.enterprise.webservice.monitoring.WebServiceTesterServlet.doPost(WebServiceTesterServlet.java:311) ... 27 more Caused by: com.sun.xml.ws.streaming.XMLStreamReaderException: unexpected XML tag. expected: {http://service.test.server.org/}testResponse but found: {http://schemas.xmlsoap.org/soap/envelope/}Envelope at com.sun.xml.ws.streaming.XMLStreamReaderUtil.verifyTag(XMLStreamReaderUtil.java:203) at com.sun.xml.ws.streaming.XMLStreamReaderUtil.verifyTag(XMLStreamReaderUtil.java:211) at com.sun.xml.ws.client.sei.ResponseBuilder$DocLit.readResponse(ResponseBuilder.java:514) at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:256) at com.sun.xml.ws.client.sei.SyncMethodHandler.invoke(SyncMethodHandler.java:224) at com.sun.xml.ws.client.sei.SEIStub.invoke(SEIStub.java:117) at $Proxy126.test(Unknown Source) ... 32 more

Marek Mosiewicz
http://www,jotel.com.pl
[Message sent by forum member 'marekmosiewicz' (marekmosiewicz)]

http://forums.java.net/jive/thread.jspa?messageID=248402