rest jersey xml response - RESTful java web service with XML Response

RESTful java web service with XML Response

Posted on

rest jersey xml response - RESTful java web service with XML ResponseIn my earlier submit I talk about about the right way to write a simple REST web service using jersey, at this time we talk about extra on it and reveal how one can create customized java class with JAXB and cope with XML response utilizing jersey.

Let’s first create eclipse Java EE venture and add all relying jersey jar recordsdata in classpath.

jersey xml response java - RESTful java web service with XML Response

Edit your net.xml to seem like much like following.

We create Automotive class and make it JAXB appropriate so it is going to be simple for jersey to return response in XML-format. Your class ought to like under. The annotation is self-explanatory.

Custom-made exception class for correct exception propagation to shopper.

Now write net service class which makes use of Automotive class and return response to shopper in XML format. We use @Produces (MediaType.APPLICATION_XML) annotation for returning XML format.

After publishing this net service you possibly can entry this by means of browser utilizing following URL.

http://localhost:8080/RESTfulTest/relaxation/xml/automobile/nano

rest webserv ce xml response - RESTful java web service with XML Response

Write java shopper to entry this net service…

Download Source

Supply techzoo.org