What is REST?
ReST is the abbreviation of Representation State Transfer so I chose to write it like ReST rather than REST. It is an architectural style that focuses on resources and structured ways to access those resources via the web. It deals with sending data as XML message over the HTTP. Like SOAP it doesn't hold Header, Body or Envelop to wrap the payload. Its more of URI based for e.g. such a service would be available to me at the following URI: http://host.com/ServiceDomainName/ServiceName. This is just an example.
Does it support the authentications and other security?
ReST services doesn't keep any information like SOAP headers does. But the authentication can be implemented using the some customization in URI by embedding some Hashed security token in it. Common places/situations where ReST can be preferred to use:
-
Where the service is not complicated, (i.e. no requirements of security and state)
-
When high level of scalability/performance is needed. (ReST allows for caching to increase the scalability)
-
Bandwidth is of importance and needs to be limited. (In SOAP we are passing a lot of extra data all the time, ReST allows for URI based identification of resources)
-
ReST allows easy aggregation of services.
Designing ReST service
The ReST service itself has its development cycle. You don't want to skip the designing phase if you've decided to use the ReST service in your application. This phase includes a very important aspect of ReST; i.e. Resouce or Actor and URI templates. The first step in designing a ReSTful service is to identify the resources the service will expose. For e.g.
-
User
-
Notes
These two resources can be further manipulated for multiple operations that would help us designing the URI template later on. So the possible combination of these resources with operations could be:
-
Individual User
-
Individual User Profile
-
Individual Note
-
Collection of all public Notes
-
User's Private Notes
-
User's All Public Notes
Now the next phase would be the deciding and defining the design of URI template. So considering the above resources we'll have the following URI in our ReST service:
Here we've used the ?title={title} just to filter specific notes by title rather than showing all notes as there could be a number of notes in the record. This is all up to your design strategy; this was just to show you how to use the approach. I hope this would ensure you covering everything with their scope.
ReST can perform following operations using the HTTP interface:
This is all information that would help you understanding the ReST first. For further detailed reading here is the MSDN white paper.
ReST in WCF 4.0
Now lets get started with some hands on exercise on ReST. To start with the ReST services development I recommend you to download and Install the WCF ReST template from Microsoft WCF team that'll save your lots of time Download from here.
There you might be surprising that few files would be missing that you used to have in your simple WCF web service:




Join the conversation! Your thoughts help the community grow.