JAX-RS XML Example With JAXB Using Jersey

In this article i will give you an example on how a RESTful web service produces XML response using Jersey. Basically JAX-RS supports conversion of java objects into XML with the help of JAXB. As Jersey it self contains JAXB libraries we no need to worry about JAXB-Jersey integration stuff.

Steps Need to be Followed

  • Add ‘jersey-server.jar‘ to your Maven pom.xml which includes all JAXB supporting libraries into your class path
  • Annotate your service method with @Produces(MediaType.APPLICATION_XML)

Required Files

  • pom.xml
  • web.xml






You Might Also Like

  ::. About the Author .::

- Full Stack Java/J2EE & UI Web Developer
Founder of Java4s - Get It Yourself, A popular Java/J2EE Programming Blog, Love Java and UI frameworks.
You can sign-up for the Email Newsletter for your daily dose of Java tutorials.


7 Responses to “JAX-RS XML Example With JAXB Using Jersey”
  1. Pranab Kumar Sahoo says:

    Thanks Sivateja

  2. venu says:

    Can you please post one example on Restful web service security.

  3. varun says:

    Can you please post one example on web services security

  4. vajreshwari says:

    Hi sivateja,

    I want to pass the query parameter as Map<String,List>. can u plz suggest how to pass these parameters.

  5. trinadh says:

    Please send more rest full web services in jersey examples in my mail id ASAP

  6. amar says:

    Thanks Sivateja !! your tutorial is so easy to understand. Thanks a lot! keep it up…

  7. kishor says:

    Purpose of @XmlRootElement ..can you please explain


By posting your answer, you agree to our comments policy.
Most Recent Posts from Top Categories
Hibernate Spring Struts
Contact | About Us | Privacy Policy | Advertise With Us

© 2010 - 2018 Java4s - Get It Yourself.
The content is copyrighted to Sivateja Kandula and may not be reproduced on other websites.