views:

1447

answers:

6

I am looking for some good links with best practices and sample code on creating RESTful web services using .NET.

Also, any other input you might have regarding REST would be greatly appreciated.

+8  A: 

Windows Communication Foundation supports REST model since .NET 3.5.

You can find documentation and code samples on MSDN:

REST and POX

Some resources to learn REST:

aku
The Windows platform has been supporting the REST model since they incorporated the TCP/IP stack and HTTP protocol back in the 90's. REST is an approach to solving a problem not a library or framework that you plug in and it all happens magically.
Darrel Miller
Darrel Miller, you should carefully read questions. User asked about REST support in .NET
aku
Sorry, I was distracted by your use of a sledgehammer to crack a nut. HttpListener and HttpWebRequest are more than sufficient to support REST. .Net 2.0 is quite capable.
Darrel Miller
+7  A: 

The best introduction I have read is the RESTful Web Services book, which goes beyond explaining the model and principles and actually shows you how to design a RESTful web service. Most useful is its checklist for how to write/specify an REST API:

  1. Figure out the data set [i.e. specify the data model].
  2. Split the data set into resources. For each kind of resource:
  3. Name the resources with URIs.
  4. Expose a subset of the uniform interface [i.e. specify which HTTP methods are used and what they do].
  5. Design the representations(s) accepted from the client [e.g. the XML format you can PUT or POST].
  6. Design the representations(s) served to the client [e.g. the XML you get back].
  7. Integrate this resource into existing resources, using hypermedia links and forms.
  8. Consider the typical course of events: what's supposed to happen? [This is like a use case main success scenario.]
  9. Consider error conditions. [This is like use case exception scenarios.]
Peter Hilton
While it gets a little redundant near the end, I second the recommendation for this book. It is very helpful in understanding REST.
rp
+20  A: 

ADO.Net Data Servcies makes it really easy to build and consume RESTful web services in the .Net world but nevertheless understanding the concepts is important. Compared to WCF (which added REST support later), ADO.Net Data Services was built primarily for REST.

Guidelines for Building RESTful Web Services has all the info on the resources you need.

This is another useful blog entry:

The uniform interface constraints describe how a service built for the Web can be a good participant in the Web architecture. These constraints are described briefly as follows :

1) Identification of resources: A resource is any information item that can be named and represented (e.g. a document, a stock price at a given point in time, the current weather in Las Vegas, etc). Resources in your service should be identified using URIs.

2) Manipulation of resources via representations: A representation is the physical representation of a resource and should correspond to a valid media type. Using standard media types as the data formats behind your service increases the reach of your service by making it accessible to a wide range of potential clients. Interaction with the resource should be based on retrieval and manipulation of the representation of the resource identified by its URI.

3)Self-descriptive messages: Following the principles of statelessness in your service's interactions, using standard media types and correctly indicating the cacheability of messages via HTTP method usage and control headers ensures that messages are self descriptive. Self descriptive messages make it possible for messages to be processed by intermediaries between the client and server without impacting either.

4)Hypermedia as the engine of application state: Application state should be expressed using URIs and hyperlinks to transition between states. This is probably the most controversial and least understood of the architectural constraints set forth in Roy Fielding's dissertation. In fact, Fielding's dissertation contains an explicit arguments against using HTTP cookies for representing application state to hammer this point home yet it is often ignored.

Gulzar
+3  A: 

The articles from the "RESTful Web" series at xml.com are a great introduction.

The author (Joe Gregorio, of The Atom Publishing Protocol fame) also regularly publishes insightful articles about all things REST on his weblog. "RESTify DayTrader" (REST Architecture applied to a benchmark stock trading application) is a good starting point. I also like "Why so many Python web frameworks?", which shows the implementation of a small restful web framework in Python.

8jean
+1  A: 

Saw Dan Rigsby give a presentation on RESTing on the Web with WCF.

He has some solid examples, and his presentation explained the whole REST concept very clearly.

mattruma