HTTP verbs
HTTP defines methods (sometimes referred to as verbs) to indicate the desired action to be performed on the identified resource. What this resource represents, whether pre-existing data or data that is generated dynamically, depends on the implementation of the server. I have listed down some of the major HTTP verbs.
Method | Description |
---|---|
GET | Requests a specific representation of a resource. Requests using GET should only retrieve data and should have no other effect. |
PUT | Update the resource if the URI refers to an already existing resource else create it. |
DELETE | Deletes the specified resource. |
POST | Submits data to be processed by the identified resource. |
HEAD | Similar to GET but only retrieves headers and not the body. This is useful for retrieving meta-information written in response headers, without having to transport the entire content. |
OPTIONS | Returns the HTTP methods that the server supports for the specified URL. This can be used to check the functionality of a web server by requesting '*' instead of a specific resource. |
WebInvoke Verbs To Use With Restful WCF Service
// Get an employee by ID - GET - employee/id (
[WebGet(UriTemplate = "/employee/{id}")] )
[WebGet(UriTemplate = "/employee/{id}")] )
// Create a new employee - POST - employee
[WebInvoke(Method = "POST", UriTemplate = "/employee/{xml}")] )
[WebInvoke(Method = "POST", UriTemplate = "/employee/{xml}")] )
// Update an employee - PUT - employee/id
[WebInvoke(Method = "PUT", UriTemplate = "/employee/{xml}")]
[WebInvoke(Method = "PUT", UriTemplate = "/employee/{xml}")]
// Delete an employee - DELETE - employee/id
[WebInvoke(Method = "DELETE", UriTemplate = "/employee/{id}")]
Refer: http://www.codeproject.com/Articles/803409/REST-enabled-WCF-service
No comments:
Post a Comment