aspose file tools*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes can you have both @GET and @POST on same resurce method ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "can you have both @GET and @POST on same resurce method ?" Watch "can you have both @GET and @POST on same resurce method ?" New topic
Author

can you have both @GET and @POST on same resurce method ?

Cosmin Nicolae Vacaroiu
Ranch Hand

Joined: Feb 10, 2011
Posts: 53

I read that you can't/shoudln't because it doesn't conform to the REST principles ..

I mean I know you can have two methods with the same Path and different method designators. But could you on the same method ?
GET should be idempotent, while POST not.

So what's true ? as in all mock tests they say you can.


SCJP 6 (93%), SQL Expert 11g (95%), SCWCD 6 (84%), OCE-EJBD 6 (98%), OCE-JPAD 6 (93%)
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1733
    
  25

Hi Cosmin,

The annotations @GET, @POST, @PUT etc are all of the @HttpMethod annotation type, for example @GET:
and the API of @HttpMethod clearly states that:

Annotation Type HttpMethod
Associates the name of a HTTP method with an annotation. A Java method annotated with a runtime annotation that is itself annotated with this annotation will be used to handle HTTP requests of the indicated HTTP method. It is an error for a method to be annotated with more than one annotation that is annotated with HttpMethod.

Regards,
Frits
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can you have both @GET and @POST on same resurce method ?