7 Replies Latest reply on Jun 23, 2009 11:15 AM by deleted user

    How to use JAXB or Aegis in a FUSE CXF JAX-RS web service?

    Oren Livne Novice

      Dear All,

       

      How do I marshal a result from a RESTful web service method into XML using JAXB or Aegis just like CXF automatically does for me when i use it outside the esb? My endpoint configuration is as follows:

       

            

                <jaxrs:providers>

      *               

       

      My web method looks like this:

       

       

           /**

             

      • @param message

             

      • @return

             

      • @see edu.utah.further.fqe.fqe_bc_ws.FqeServiceFrontEnd#sayHello(java.lang.String)

            */

           @GET

           @ProduceMime("application/xml")

           @Path("/hello/The specified item was not found./xml")

           public SimpleBean sayHelloInXml(@PathParam("message") final String message)

           {

                if (logger.isDebugEnabled())

                {

                     logger.debug("sayHelloInXml(" + message + ")");

                }

                SimpleBean result = new SimpleBean();

                result.setMessage(simpleService.sayHello(message));

                return result;

           }

       

      Its return type is annotated with Aegis annotations:

      /*******************************************************************************

       

      • Source File: SimpleBean.java

      ******************************************************************************/

      package edu.utah.further.fqe.fqe_bc_ws;

       

      import org.apache.cxf.aegis.type.java5.XmlElement;

       

      /**

       

      • ...

       

      • <p>

       

      • -----------------------------------------------------------------------------------<br>

       

      • (c) 2008-2009 FURTHeR Project, Health Sciences IT, University of Utah<br>

       

       

      • Biomedical Informatics, 26 South 2000 East<br>

       

      • Room 5775 HSEB, Salt Lake City, UT 84112<br>

       

      • Day Phone: 1-801-213-3288<br>

       

      • -----------------------------------------------------------------------------------

      *

       

       

      • @version Jun 22, 2009

      */

      public class SimpleBean

      {

           private String message;

       

           @XmlElement(name = "message", nillable = false)

           public String getMessage()

           {

                return message;

           }

       

           public void setMessage(final String message)

           {

                this.message = message;

           }

       

      }

       

      However, in the browser I get a text message representing simpleBean.message instead of a serialized XML of the whole bean. This example uses Aegis, but I rather use JAXB. How do I do that?

       

      Thank you!

      Oren