This is a mirror of official site: http://jasper-net.blogspot.com/

Create REST service with WCF and Consume using jQuery

| Sunday, April 17, 2011
What is REST ? 

Rest=Representational state transfer which is an architecture design to represent the resources. Rest provide the uniform interface through additional constraints around how to identify resources, how to manipulate resources through representations, and how to include metadata that make messages self-describing. Rest is not tied with any platform and technology but WEB is only platform which satisfy the all constrain. So any thing you build using Rest constrain, you do it on Web using HTTP. Following are the HTTP methods which are use full when creating Rest Services. 

HTTP Mehtods

GET - Requests a specific representation of a resource
PUT - Create or update a ersoure with the supplied representation
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
OPTIONS - Returns the methods supported by the identified resource
In this article I am going discuss how to design and consume REST web service using WCF framework of .net service. As Example I am going to create  REST service which create, update and select Employee. Now start following the steps given below. 

Designing of the URI 

To designing Rest services you need to design URI, so for that you need to list out the resources that going to be exposed by the service.  As I am going to design Employee Create,updae and select service, so resource is

Employee
Now to be more specific towards the operation
List of Employees
A Employee by Id
Create Employee
Update Employee
Delete Employee 
For example service is hosted on on local IIS server  and URL to locate it is     

In below discussion I am going to design the URL presentation for each operation

List  Employees   
URL is to get list of all employee                

But there are no. of Employee in system and to apply filter on Employees   

Note : In above url get list of employee of the type specified {type} of url.         

To Get single Emplyee by using uniqid of Employee.    

Note : In above URL {EmployeesID} is get replaced by ID of Employee.          

Extension to above scenario, If want to get employee by using id with the type 

Create Employee 
          URL is to create employee is             

Read more: Codeproject

Posted via email from Jasper-net

0 comments: