• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doubt regarding deleting a resource in REST WS with or without DELETE method?

 
Ranch Hand
Posts: 440
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a doubt regardiing DELETE In Restful Web services....Suppose we are deleting a Resource using the Id, DELETE is the method for this ...but the same task can be performed with GET or POST by just passing the ID...and deleting that from the database....if so then what is the difference between these two apporaches..

Thanks...
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The point is that by using the DELETE HTTP method, you are maintaining architectural clarity.

Yes, you will see non-RESTful use of HTTP methods, especially GET and POST used for all possible functions all the time.

Elegant style versus sloppy style - - I think I will go with elegant.

Bill

 
Satyaprakash Joshii
Ranch Hand
Posts: 440
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bill for the clarification..Yes one is the elegant style and the other is the less Restful use of web service as you have clarified

..but using the second one..one advantage we are getting. .--->we dont need to have or database design in sync with the web service XMLs....because using the get or post we are just passing the unique id and then we have the flexibility of doing whatever we want on the server side..with the database ...Is it now so?
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Satyaprakash Joshii wrote:
..but using the second one..one advantage we are getting. .--->we dont need to have or database design in sync with the web service XMLs....because using the get or post we are just passing the unique id and then we have the flexibility of doing whatever we want on the server side..with the database ...Is it now so?



Sorry, that does not make any sense to me. What does database design have to do with it?

Bill
 
Satyaprakash Joshii
Ranch Hand
Posts: 440
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is the scenario and my doubt..I have Contacts POJO which has Customer Id ,Customer name,Customer contact info...I am using DELETE method as r.path(id).delete(ClientResponse.class); to delete the Contact...
After this step, the Contact with the paticular Id is already deleted and the resource no longer exists. Its done...But did I delete the contact from the database? No......So it still exists in the DB....So what is the significance of deleting it from the database as operation is already performed without deletion form the DB?

thanks..
 
Satyaprakash Joshii
Ranch Hand
Posts: 440
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got my answer for what is the difference.....If I am using DELETE method without deleting from DB...The resource is deleted..but since it is stateless thing, once we restart the server it still exists....
 
Satyaprakash Joshii
Ranch Hand
Posts: 440
4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I use DELETE method of REST WS..., the resource will be deleted but since it is stateless suppose server is restarted the record will still be there...So will have to go with GET or POST method in this case pass the customer Id and delete the record from the database...My doubt is that what would be the examples where DELETE method will server the purpose...Can you tell any example when deleting using DELETE method will be useful?(because in my case on restarting the server deleted record will still show due to statelessness)....

thanks..
 
William Brogden
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

the resource will be deleted but since it is stateless suppose server is restarted the record will still be there...



What in the world are you talking about? Are you thinking there is a magic DELETE method hidden somewhere? NO!

It is up to you to write your own DELETE method so if your DELETE method actually deletes the record from the database it will be gone gone gone.

Bill
 
reply
    Bookmark Topic Watch Topic
  • New Topic