REST Applications in.NET Representational State Transfer Ben Dewey twentySix New York

Slides:



Advertisements
Similar presentations
Pierre-Johan CHARTRE Java EE - JAX-RS - Pierre-Johan CHARTRE
Advertisements

HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation
Give it a REST already Arnon Rotem-Gal-Oz VP R&D xsights
REST - Representational State Transfer
Representational State Transfer (REST): Representing Information in Web 2.0 Applications this is the presentation Emilio F Zegarra CS 2650.
REST Vs. SOAP.
Building and using REST information services Rion Dooley.
Introduction to Web Services
REST &.NET James Crisp.NET Practice Lead ThoughtWorks Australia.
WCF 3.5, REST ET AL. H OW TO ? Adnan Masood
Creating and Consuming RESTful Web Services with WCF
REST (Representational State Transfer)
How to Build a REST API Using ASP.NET Web API Fernando Cardenas 10/8/20131.
GET. Introduction, overview Best practices Roy T Fielding, PhD dissertation, 2000 Main characteristics Client-server Stateless Caching Layered architecture.
WHO AM I? REST? Dissertation by Roy Fielding 2000 Architectural Styles and the Design of Network-based Software Architectures ReST = Representational.
November 11, MCT, MCITP, MCTS, MCP SharePoint Architect for Planet Technologies. Working with SharePoint since – Administrator / Developer.
REST and JSON in WCF It is possible to implement and access REST services in WCF And still doing it object oriented This is a short presentation on how.
RESTful Web Services Senthil Chinnaiyan, Senior Architect
Supplement: RESTful Web service and JAX-RS Summer 2011 Dr. Chunbo Chu Week 3.
Background REST (Representational State Transfer) What does it mean to be RESTful? Why REST? WCF How does WCF support REST? What are the pieces we need.
GETTING STARTED WITH WINDOWS COMMUNICATION FOUNDATION 4.5 Ed Jones & Grey Guindon.
What are Web Services? How to use them?
Building a Simple Web Proxy
Hypertext Transfer PROTOCOL ----HTTP Sen Wang CSE5232 Network Programming.
.NET 3.5 SP1 New features Enhancements Visual Studio 2008 SP1 New features Enhancements Additional features/enhancements.
Presenter: James Huang Date: Sept. 29,  HTTP and WWW  Bottle Web Framework  Request Routing  Sending Static Files  Handling HTML  HTTP Errors.
Building RESTful Interfaces
Introduction to Computing Using Python CSC Winter 2013 Week 8: WWW and Search  World Wide Web  Python Modules for WWW  Web Crawling  Thursday:
Creating a RESTful Web Service for Microsoft SQL Server Patrick Mundy, Managing Partner Albert Factora, Managing Partner.
SOAP Overview Simple Object Access Protocol CSCI Topics in Software Engineering Web Infrastructure, Services, and Applications
XML in the real world (2) SOAP. What is SOAP? ► SOAP stands for Simple Object Access Protocol ► SOAP is a communication protocol ► SOAP is for communication.
SOAP SOAP is a protocol for accessing a Web Service. SOAP stands for Simple Object Access Protocol * SOAP is a communication protocol * SOAP is for communication.
Service-Oriented Architecture INF 123 – Software architecture 1.
SE 370: Programming Web Services Week 4: SOAP & NetBeans Copyright © Steven W. Johnson February 1, 2013.
Web Services Darshan R. Kapadia Gregor von Laszewski 1http://grid.rit.edu.
INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
SOAP Quang Vinh Pham Simon De Baets Université Libre de Bruxelles1.
.NET Framework V3.5+ & RESTful web services Mike Taulty Developer & Platform Group Microsoft Ltd
Darryl Burling Developer Evangelist Microsoft The age of connected applications Whats new in VS2008 WCF Background: WS*,.Net 3.0 and WCF ABC’s & improvments.
06 | Implementing Web APIs Jon Galloway | Tech Evangelist Christopher Harrison | Head Geek.
 What is it ? What is it ?  URI,URN,URL URI,URN,URL  HTTP – methods HTTP – methods  HTTP Request Packets HTTP Request Packets  HTTP Request Headers.
Jon Flanders INT303. About Me  Jon Flanders –  Independent consultant/trainer  BizTalk MVP.
WCF Services in Nutshell A Tutorial using WCF Mr. Michael Arnwine WCF using Service Oriented Architecture (SOA) and “Restful” Service.
Building Data Driven Applications Using WinRT and XAML Sergey Barskiy, Magenic Microsoft MVP – Data Platform Principal Consultant Level: Intermediate.
ADO.NET DATA SERVICES Mike Taulty Developer & Platform Group Microsoft UK
CSCI 6962: Server-side Design and Programming Web Services.
Visual Studio 2008 and.NET 3.5 provide seamless support for all of the protocols and techniques popular in Web 2.0-style applications. Visual Studio.
Web Service Programming with WCF 3.5 Eyal Vardi CEO E4D Solutions LTD Microsoft MVP Visual C# blog:
Telerik Software Academy Web Services & Cloud.
REpresentational State Transfer.  Resources  Representations  Verbs  Links  Headers  HTTP Status Codes.
REST and WCF 3.5 Glen Gordon Developer Evangelist, Microsoft
1 ADO.NET Data Services Mike Taulty Developer & Platform Group Microsoft Ltd
06 | HTTP Services with Web API Bruno Terkaly | Technical Evangelist Bret Stateham | Technical Evangelist.
RESTful Web Services What is RESTful?
Web Technologies Lecture 10 Web services. From W3C – A software system designed to support interoperable machine-to-machine interaction over a network.
.NET Mobile Application Development XML Web Services.
Feeling RESTful? Well, first we’ll define a Web Service –A web page meant to be consumed by a computer via an autonomous program as opposed to a web browser.
CS520 Web Programming Introduction to Web Services Chengyu Sun California State University, Los Angeles.
Miguel A. Castro Architect IDesign SESSION CODE: WEB310.
Windows Communication Foundation and Web Services
The Hypertext Transfer Protocol
Introduction Web Environments
Windows Communication Foundation and Web Services
WEB API.
HTTP Request Method URL Protocol Version GET /index.html HTTP/1.1
MIX 09 12/9/2018 6:08 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
REST på Microsoft-stacken
WCF Data Services and Silverlight
.NET Framework V3.5+ & RESTful web services
Chengyu Sun California State University, Los Angeles
Presentation transcript:

REST Applications in.NET Representational State Transfer Ben Dewey twentySix New York

Overview What is REST Rules and Guidelines Hosting a REST Service in.NET Consuming a REST Service with.NET Samples Discussion

What is REST? Roy Fielding – – Client-Server – Stateless – Cachable – Layered System – Code-on-demand (optional)

HTTP Methods

Courtesy of RESTful.NET by Jon Flanders

HTTP Status Codes Status RangeDescriptionExamples 100Informational100 Continue 200Successful200 OK 201Created 202Accepted 300Redirection301 Moved Permanently 304Not Modified 400Client error401 Unauthorized 402Payment Required 404Not Found 405Method Not Allowed 500Server error500 Internal Server Error 501Not Implemented

HTTP Messages GET / HTTP/1.1 User-Agent: Fiddler Host: localhost:9999 HTTP/ OK Content-Length: 256 Content-Type: application/xml; charset=utf-8 Server: Microsoft-HTTPAPI/2.0 Date: Tue, 17 Nov :11:11 GMT

URIs (Uniform Resource Identifiers) RPC (SOAP) Interface getYears getMakes getAutomobile updateAutomobile deleteAutomobile

URIs (Uniform Resource Identifiers) RESTful Interface – No need to distinguish get/update/delete, thats what the HTTP Method is for – Collection – Resource

Return Types XML – XHTML – ATOM Publishing Protocol – RSS – Custom (should contain hyperlinks) JSON Custom

WADL Web Application Definition Language WSDL for REST

WADL

Hosting REST in.NET Windows Communication Foundation (WCF) – Web* additions in.NET 3.5 WebHttpBinding, WebOperationContext, WebGet/Invoke Attributes, etc UriTemplates for Routing – REST Starter Kit Preview 2 – WCF Hosting (Console, IIS, etc) ASP.NET MVC – JsonResults and XmlResults for serialization – System.Web.Routing engine for routing

Hosting WCF (Catch-All Controller) [ServiceContract] public interface IAutomobileService { [OperationContract] [WebGet(UriTemplate = "*")] Message Get(); [OperationContract] [WebInvoke(Method = "PUT", UriTemplate = "*")] Message Put(Message data); }

Hosting WCF (UriTemplates) [ServiceContract] public interface IAutomobileService { [OperationContract] [WebGet(UriTemplate = "/{year}/{make}/{model}/{engine}")] Automobiles GetAutomobiles(string year, string make, string model, string engine); }

Hosting WCF (REST Starter Kit)

Hosting MVC routes.MapRoute( "Default", "{year}/{make}/{model}/{engine}", new { controller = "Main", action = "Main", year = "", make = "", model = "", engine = "" } ); public ActionResult Main(int? year, string make, string model, string engine) { if (!year.HasValue) { return Xml(AutomobileRepository.GetYears()); } else { /* … */ } }

Consuming REST in.NET WebRequest WCF Interface Mocking HttpClient – Ships with REST Starter Kit Preview 2

WebRequest var httpRequest = (HttpWebRequest)WebRequest.Create( " using (var upStream = httpRequest.GetRequestStream()) { // some complicated logic to create the message } var response = httpRequest.GetResponse(); using (var downStream = response.GetResponseStream()) { // some complicated logic to handle the response message. }

WCF Interface Mock [ServiceContract] public interface ITwitterService { [OperationContract] [WebInvoke(UriTemplate = "/friendships/create/{user}.xml")] TwitterUser CreateFriendship(string user); } using (var factory = new WebChannelFactory ( new Uri(" { factory.Credentials.UserName.UserName = username; factory.Credentials.UserName.Password = password; var proxy = factory.CreateChannel(); var user = proxy.CreateFriendship("userToFollow"); }

HttpClient using (var client = new HttpClient()) { var postData = new StringContent(""); var url = " var user = client.Post(url, postData).EnsureStatusIsSuccessful().Content.ReadAsXmlSerializable (); }

Samples/Demos

Resources Roy Fieldings Dissertation REST in Windows Communication Foundation (WCF) RESTful.NET by Jon Flanders REST on Wikipedia A Guide to Designing and Building RESTful Web Services with WCF Creating a RESTful Web Service Using ASP.Net MVC * These slides will be posted on my blog (

Discussion SOAP vs REST MVC vs WCF ATOM/RSS Easiest for JavaScript Consumption OAUTH WRAP

Session Wrap-Up Thoughts and Impressions – Positives and Deltas Discussion of Topics for Upcoming Meetings