2 Replies Latest reply on Jun 18, 2003 9:14 AM by Pablo

    How to return a Bean in a webservice method?

    Pablo Newbie

      Hi guys!!

      I'm new with webservices. I want to provide a webservice with a method like:

      ThingTO getThing(String name)

      Where ThingTO is a bean with get and set.

      I'm able to deploy the ear and I can see the webservice running and get the wsdl file. Using the WSDL2Java I have generated the stub files.

      But trying to run a client I got the error:

      12:03:20,014 ERROR [Engine] ----- Root Cause -----
      java.lang.LinkageError: loader constraints violated when linking javax/xml/soap/SOAPElement class
      at org.apache.axis.message.EnvelopeBuilder.(EnvelopeBuilder.java:84)
      at org.apache.axis.encoding.DeserializationContextImpl.(DeserializationContextImpl.java:170)
      at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:540)
      at org.apache.axis.Message.getSOAPEnvelope(Message.java:377)
      at org.apache.axis.handlers.soap.SOAPService$SOAPRequestHandler.invoke(SOAPService.java:176)
      at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:71)
      at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:156)
      at org.apache.axis.SimpleChain.invoke(SimpleChain.java:126)
      at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:437)
      at org.apache.axis.server.AxisServer.invoke(AxisServer.java:316)
      at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:701)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
      at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:335)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:551)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:509)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
      at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
      at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
      at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
      at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
      at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
      at java.lang.Thread.run(Thread.java:536)

      Someone can help me? What's wrong?

      I'll apreciate an example.

      Thanks,
      Pablo

        • 1. Re: How to return a Bean in a webservice method?
          Gerhard Stürmer Newbie

          Hi!

          I think that this works with soapattachments, but don't ask me how.

          BUT: Is it realy a good idea to you Classes in Webservices. I know that Java or.NET can handle that in a fine way. But how can COBOL or C handle Objects ??? There is no way for them to access to your webservice! So if you want to publish your service you restrict yourself.
          I normally return a XmlString which can be handled from every programming language (String exists everywhere).
          A Webservice should not have business logic so the only code in the webservice is to call a SessionBean/Class and bring the result in String(Xml)-format. The best way to do that would be a
          "String toXml()"- and a "static ThingTO parse(String xml)"-method in the ThingTO-Class.
          Thats the way I always do. What do you think?

          mfg Peda

          • 2. Re: How to return a Bean in a webservice method?
            Pablo Newbie

            Hi!

            I agree with you. But I have a question about it.

            Where can I publish the schema of my xmlBeans? How my client will know what is my XMLs? Because for them it will be just a String...

            Thanks

            Pablo
            Belo Horizonte-Brazil