12. URIs RESTful Interface No need to distinguish get/update/delete, that’s what the HTTP Method is for Collection http://example.com/2011/Honda/ Resource http://example.com/2011/Honda/Civic/2.0
13. Return Types XML XHTML ATOM Publishing Protocol RSS Custom (should contain hyperlinks) JSON Custom
14. WCF and REST WCF 4 REST REST endpoints Uri templates for routing WCF Hosting (Console, IIS, etc) etc.
15. WCF 4 REST, Web Api Programming model for HTTP in WCF Access HTTP from top to bottom REST endpoints Uri templates for routing WCF Hosting (Console, IIS, etc) etc. Http Client Plug in any format / media type Typeless JSON support IQueryablesupport
20. WebRequest varhttpRequest = (HttpWebRequest)WebRequest.Create( "http://localhost/myservice"); using (varupStream = httpRequest.GetRequestStream()) { // some complicated logic to create the message } var response = httpRequest.GetResponse(); using (vardownStream = response.GetResponseStream()) { // some complicated logic to handle the response message. }
21. WebChannelFactory [ServiceContract] publicinterfaceITwitterService { [OperationContract] [WebInvoke(UriTemplate = "/friendships/create/{user}.xml")] TwitterUserCreateFriendship(string user); } using (var factory = newWebChannelFactory<ITwitterService>( newUri("http://www.twitter.com/"))) { factory.Credentials.UserName.UserName = username; factory.Credentials.UserName.Password = password; var proxy = factory.CreateChannel(); var user = proxy.CreateFriendship("userToFollow"); }
22. HttpClient var sample = newSample(); using (var client = newHttpClient()) { client.DefaultRequestHeaders.Accept.Add( newMediaTypeWithQualityHeaderValue("application/json")); client.Post( "http://localhost/myservice", newObjectContent(typeof(Sample), sample, Sample.JsonMediaType)); }
25. Implementations OpenRastaOpenRasta brings the concept of REST to the .NET platform in ways that allow it to be deployed alongside ASP.NET and WCF components. http://trac.caffeine-it.com/openrasta/wiki/Doc http://code.google.com/p/implementing-rest/wiki/ByLanguage