users@jersey.java.net

Re: [Jersey] MessageBodyWriter Example for XML

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 23 Mar 2010 16:47:10 -0400

Take a look at the entity-provider sample for an example of a MessageBodyWriter:

https://jersey.dev.java.net/source/browse/jersey/trunk/jersey/samples/entity-provider/

You'll need work out how to write the portalXMLDoc to an OutputStream in your writeTo method.

Marc

On Mar 23, 2010, at 3:58 PM, Jay_K wrote:

>
> I am trying to generate and return an XML using below class
>
> @Path("/portaldetails")
> public class PortalResource {
> @GET
> @Produces({MediaType.APPLICATION_XML})
> public Document getLeaveDetails(@QueryParam("portalId") String portalId) {
>
> Few steps to generate XML document using Dom4J
> return portalXMLDoc;
> }
> }
> I am getting below exception
>
> [3/23/10 15:52:19:982 EDT] 00000023 ContainerResp E A message body writer
> for Java type, class org.dom4j.tree.DefaultDocument, and MIME media type,
> application/xml, was not found
>
> Could anyone, please provide me either a sample class implementing
> MessageBodyWriter for above scenario or any material to get details about
> the same.
> Thanks for the help.
> --
> View this message in context: http://n2.nabble.com/MessageBodyWriter-Example-for-XML-tp4786769p4786769.html
> Sent from the Jersey mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>