How to use JAXB or Aegis in a FUSE CXF JAX-RS web service?
oren Jun 22, 2009 6:16 PMDear 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>
Contact: Dr. Scott Narus<code><scott.narus@hsc.utah.edu></code><br>
Biomedical Informatics, 26 South 2000 East<br>
Room 5775 HSEB, Salt Lake City, UT 84112<br>
Day Phone: 1-801-213-3288<br>
-----------------------------------------------------------------------------------
*
@author Oren E. Livne <code><oren.livne@utah.edu></code>
@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