About Question enthuware.ocejws.v6.2.288 :

Moderators: Site Manager, fjwalraven

Post Reply
himaiMinh
Posts: 358
Joined: Fri Nov 29, 2013 8:26 pm
Contact:

About Question enthuware.ocejws.v6.2.288 :

Post by himaiMinh »

Regarding to this explanation, "you can easily create two new methods in the current JAX-RS resource by adding @Produces annotations."
I think there is another alternative, which is content negotiation:

Code: Select all

  // an example to convert a JAXBSource into XML/JSON/text
   @Produce({"application\xml", "application\json", "text\plain", "text\html"})
     public JAXBSource getResult(){
                ....
     }

fjwalraven
Posts: 429
Joined: Tue Jul 24, 2012 2:43 am
Contact:

Re: About Question enthuware.ocejws.v6.2.288 :

Post by fjwalraven »

Both are examples of static content negotiation. With the latter option according to the Accept header you will get the right content back. The implementation of which content to send back to the client is then put in the MessageBodyReader and MessageBodyWriter instead of the web service method implementation.

If I add this example it will add extra complexity to the explanation.

Regards,
Frits

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests