For example, I want to search/insert/get/delete data from database and I’m working with wcf RESTful service.
I have one method for getting data from the table, one method for searching in the table, one method for inserting data in the table and one method for deleting data from the table.
I know that every of these methods can be POST or GET.
But, what is smartest? What is the best practice?
My opinion is that the search and the get method should be GET. The insert and the DELETE method should be POST.
Am I right?
You are right. The thing about GET is that it should be idempotent as the client (browser) is free to send repeat GETs anytime they want. However the POST can only be sent once (according to the rules).
So anything that changes anything could be a POST. Strictly speaking the delete could be a GET as well, as the resend of the GET will not hurt the delete, but generally it’s better if you respect the spirit of the HTTP protocol. See the HTTP RFC 2616 for more details.