Introduction of REST Services
- We can define Representational State Transfer (REST) as an architectural style that sits on top of a series of principles.
- ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.
web applications offer to extend their functionalities through web api.
The principles of REST are Uniform Interface, Stateless, Cacheable, Client-Server, Layered System, and Code on Demand.
- Uniform Interface
- We can request the resource (the “things” that we want to manage using the API) with the URI. A resource may be a document, database table , pictures etc.
- we obtain is a representation of that requested resource in a particular format like XML, JSON, PNG, HTML etc.
- State Less
- Statelessness is a fundamental principle for a REST application; the server should never store information about the clients.
- Stateless also means that the server should never use sessions or other mechanisms to store client information, and every request is not correlated with past or future requests.
- Cachable
- The client can cache the resource, If we manage the cache correctly, we can save several trips to the server.
- Client Server
- What the client sees is the URI and the representation of the resource—that’s all. The client can’t see (and surely isn’t interested in seeing) where the resource is stored.
- Layered System
- The client knows very little about the server; it doesn’t know, for example, if it is directly connected to the server or if it arrived at the server by passing through a proxy or other intermediary server (balancer, etc.).
- Code on Demand
- The server can extend the functionality of the client by passing executable code. For example, a server can send JavaScript to the client so that it can do some type of operation on the data.
- An aspect of REST that contrasts with SOAP (RPC) is that the operation on the resource is based on the HTTP verb used in combination with the URI.
- These can be used with their semantic meaning, so when we need to read a resource, we can use the GET method, and when we need to delete a resource, we can use a DELETE, and so on.
Table : HTTP verbs and meanings
Verb | URI | Description
|
GET | /posts | Get the post list.
|
GET | /posts/42 | Get a single post (the one with id 42). |
DELETE | /posts/42 | Delete the post 42.
|
POST | /posts | Create a post.
|
PUT | /posts/42 | Update the post.
|
PATCH | /post/42 | Partial update.
|
OPTIONS | /post/42 | Retrieve the available operation on the resource. |
HEAD | /post/42 | Return only the HTTP header. |
sir how can we communicate or integrate REST API with any virtualization software like VMWARE??