1

I am new to REST and I understand that the idea of resource is central to a RESTful service. Let's say I have created a RESTful service which allows users to create/read/update/delete some objects in my hashmap (an object say CustomerOrder, which has stuff like orderId and a list of dishes they have ordered).

This is easily translated to REST, I have GET to read an order, DELETE to delete one, POST to create a new one and PUT to update.

However, lets say my application has some method called processCustomerOrder(int orderId), which retrieves the order from the map and simply sends the order to another webservice that processes the order. I want my frontend website to have a button 'Process Order' which will call the method and my server will just return a string like "order processed successfully".

Am I right in saying this should simply be another GET method with a different path? e.g.:

path=restservice/processRequest 
httpmethod=GET 
param=orderId

or does this break the rules of RESTful design because I am not actually getting any resource?

1 Answer 1

1

Of course you can do this. In this case, the resource is the method (the method is a resource also, because you can do some processing, return a message or other entity, so it doesn't matter what kind of processing it is about).

String is a valid response entity (JAX-RS Response Entity Types).

You may be interested in subresource method locators: http://docs.oracle.com/javaee/6/tutorial/doc/gknav.html#gklag .

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.