From: Robert P. <rl...@lo...> - 2013-01-18 11:47:45
|
Don't do it man. I'm not gonna pretend to be able to explain it as well as Bill Burke in RESTful Java with JAX-RS or Roy Fields in his doctoral dissertation, but my feeble understanding is that you don't want to do this because: 1) Your violating visibility (i.e. the things in the middle don't know what RESET means. Is it bad if it gets sent a second time? Can I cache the results etc....) Though, in the case of "RESET" you probably want it to act like a POST and that is probably what you would get. 2) You client application could experience problems with it's libraries similar to the one your facing. 3) Your throwing away the wisdom gained in the entire online world using the heck out of the already defined methods. 4) The fact that developers of client applications already know the predefined methods. A big part of REST is about sticking to the verbs we already know to take action on Entities as we define them. In this case you may want to consider sending a POST (possibly even a PUT) of a reset request entity. If reset takes time, you may find yourself then using GET to monitor the progress of your "reset". Alternatively, you might want to consider if RESET is simply a change of state for an existing entity. In which case you probably want to just PUT the entity with an updated state reflecting the fact it has been reset. But my highest advise is to read (....or at least the first chapter of it, which introduces the theory): • RESTful Java with JAX-RS • By: Bill Burke • Publisher: O'Reilly Media, Inc. • Pub. Date: November 27, 2009 • Print ISBN-13: 978-0-596-15804-0 Also, browse RFC 2616, especially section 9 defining the existing methods. If you already know all of this then I sent my apologies for being presumptuous, but you sound like you are where I was a few years ago, using RESTEasy like it was a lightweight version of SOAP. Thankfully, I got smacked down just enough to prompt me to go study. REST has serious advantages. Should you elect to ignore them, be certain it is an informed decision. On Jan 18, 2013, at 5:23 AM, Dave Minter <da...@pa...> wrote: > > > > I'd like to use custom HTTP verbs with resteasy running under Tomcat. Is this possible? If it is possible is it sensible? > > I'm using resteasy 2.3.4.Final with Spring 3.1.2-RELEASE and I've created a custom HttpMethod annotation for the new verb: > > @Target({ ElementType.METHOD }) > @Retention(RetentionPolicy.RUNTIME) > @HttpMethod("RESET") > public @interface RESET { > } > > Spring is configured in the servlet application context with the default resteasy config thus: > > <tx:annotation-driven /> > <import resource="classpath:springmvc-resteasy.xml" /> > > The new method in the controller is implemented thus: > > @RESET > @Path("/{uuid}") > public void reset(@PathParam("uuid") final String uuid) { > // Reset the model state... > } > > My other controller methods work fine for the normal GET,PUT,POST,DELETE verbs but for the custom verb I get the following error message from Tomcat: > > HTTP Status 501 - Method RESET is not defined in RFC 2068 and is not supported by the Servlet API > > That message seems to be the same one that you get with a default servlet implementation so I presume I need to configure the ResteasyHandlerMapping somehow...? > > ------------------------------------------------------------------------------ > Master HTML5, CSS3, ASP.NET, MVC, AJAX, Knockout.js, Web API and > much more. Get web development skills now with LearnDevNow - > 350+ hours of step-by-step video tutorials by Microsoft MVPs and experts. > SALE $99.99 this month only -- learn more at: > http://p.sf.net/sfu/learnmore_122812_______________________________________________ > Resteasy-developers mailing list > Res...@li... > https://lists.sourceforge.net/lists/listinfo/resteasy-developers |