I am a new comer in terms of web services. I am tasked to convert an existing software component to a web service. I did some research and I decided to use JAX-RS. I am having a difficulty to decide when to use @QueryParam and when to use @Consume because they seems to be able to achieve the same goal.
For example, let say I have a method named read() and it takes a book as an argument.
public class AReader { public void read(Book book){...} }
public class Book { public String author; public String name; }
When translating this using JAX-RS annotation, I could either
- Use @POST and @QueryParam to accept the author and name parameter or
- Use @POST and @Consumes to consume a text representation of Book in XML or JSON format in the body.
My question is what is the common usage for @QueryParam and @Consume. Is this just a personal preference or there is a common practice?
I found a lot information about usage of @PathParam and @QueryParam but not @QueryParam and @Consumes.
Thanks in advance...