REST &.NET James Crisp.NET Practice Lead ThoughtWorks Australia.

Slides:



Advertisements
Similar presentations
HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation
Advertisements

System Wide Information Management (SWIM)
An Introduction to the Internet and the Web Frank McCown COMP 250 – Internet Development Harding University Photos were obtained from the Web, and copyright.
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.
REST Applications in.NET Representational State Transfer Ben Dewey twentySix New York
How to Build a REST API Using ASP.NET Web API Fernando Cardenas 10/8/20131.
Safe Harbor Statement The following is intended to outline our general product direction. It is intended for information purposes only, and may not be.
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.
Building a Simple Web Proxy
Hypertext Transfer PROTOCOL ----HTTP Sen Wang CSE5232 Network Programming.
The Web Core Ideas and Technologies Resources and Objects (and Services tomorrow) HTTP MIME Types URIs ReST.
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 ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
HTTP By: Becky Fultz, Joe Flager, Katie Huston, Tom Packard, Allison Wilsey.
HTTP Hypertext Transfer Protocol. HTTP messages HTTP is the language that web clients and web servers use to talk to each other –HTTP is largely “under.
How the web works: HTTP and CGI explained
Hypertext Transfer Protocol Information Systems 337 Prof. Harry Plantinga.
2/9/2004 Web and HTTP February 9, /9/2004 Assignments Due – Reading and Warmup Work on Message of the Day.
Controling instrument in the RESTful way
Hypertext Transport Protocol CS Dick Steflik.
 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.
Rensselaer Polytechnic Institute CSC-432 – Operating Systems David Goldschmidt, Ph.D.
Beyond the UI Using Tools to Improve Testing Jeremy Traylor
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
HyperText Transfer Protocol (HTTP).  HTTP is the protocol that supports communication between web browsers and web servers.  A “Web Server” is a HTTP.
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
Designing and Implementing Web Data Services in Perl
REST.  REST is an acronym standing for Representational State Transfer  A software architecture style for building scalable web services  Typically,
Tools for Web Applications. Overview of TCP/IP Link Layer Network Layer Transport Layer Application Layer.
CollectionSpace Service REST-based APIs June 2009 Face-to-face Aron Roberts U.C. Berkeley IST/Data Services.
Web HTTP Hypertext Transfer Protocol. Web Terminology ◘Message: The basic unit of HTTP communication, consisting of structured sequence of octets matching.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
1 Seminar on Service Oriented Architecture Principles of REST.
2007cs Servers on the Web. The World-Wide Web 2007 cs CSS JS HTML Server Browser JS CSS HTML Transfer of resources using HTTP.
Operating Systems Lesson 12. HTTP vs HTML HTML: hypertext markup language ◦ Definitions of tags that are added to Web documents to control their appearance.
REpresentational State Transfer.  Resources  Representations  Verbs  Links  Headers  HTTP Status Codes.
The Basics of HTTP Jason Dean
Web Technologies Lecture 1 The Internet and HTTP.
Programming for WWW (ICE 1338) Lecture #2 Lecture #2 June 25, 2004 In-Young Ko iko.AT. icu.ac.kr Information and Communications University (ICU) iko.AT.
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.
Computer Networks with Internet Technology William Stallings Chapter 04 Modern Applications 4.1 Web Access - HTTP.
Simple Web Services. Internet Basics The Internet is based on a communication protocol named TCP (Transmission Control Protocol) TCP allows programs running.
Intro to REST Joe Gregorio Google. REST is an Architectural Style.
National College of Science & Information Technology.
How HTTP Works Made by Manish Kushwaha.
RESTful Sevices Distributed Objects Presented by: Shivank Malik
Hypertext Transfer Protocol
Content from Python Docs.
Better RESTFul API – Best Practices
REST- Representational State Transfer Enn Õunapuu
COMP2322 Lab 2 HTTP Steven Lee Feb. 8, 2017.
Advanced Web-based Systems | Misbhauddin
Hypertext Transfer Protocol
Hypertext Transport Protocol
What is REST API ? A REST (Representational State Transfer) Server simply provides access to resources and the REST client accesses and presents the.
HTTP Protocol.
Ashish Pandit IT Architect, Middleware & Integration Services
WEB API.
REST.
RESTful Web Services.
Chengyu Sun California State University, Los Angeles
Presentation transcript:

REST &.NET James Crisp.NET Practice Lead ThoughtWorks Australia

James Crisp

The Web

*-ilities

Scalability

Recoverability & Reliability

Security

Discoverability

How to bring to Web services?

Tunneling RPC URLs POX SOAP & WS-*

REpresentational State Transfer

REST contributes... the rationale behind the modern Web's software architecture Roy Fielding

Resources e.g. Person, Car, Post

Representations Bill Gates m

Addressability

Uniform Interface

GET POST HEAD PUT DELETE OPTIONS Support

GET GET /people/joe_citizen HTTP/1.1 Host: mysite.com Accept: application/xml

Response 200 OK Content-Type: application/xml Last-Modified: :00.. Joe Citizen 42 m

HEAD HEAD /people/joe_citizen HTTP/1.1 Host: mysite.com 200 OK Content-Type: application/xml Last-Modified: :00.. ETag: a32daf15-b33da2a4d Response

POST POST /people HTTP/1.1 Content-Type: text/xml Host: mysite.com.... Tina Jones 25 F

Response 201 CREATED Location: /people/tina_jones (optionally with body)

PUT PUT /people/tina_jones HTTP/1.1 Content-Type: text/xml Host: mysite.com.... Tina Jones 24 F

Response 200 OK Location: /people/tina_jones (optionally with body)

DELETE DELETE /people/joe_citizen HTTP/1.1 Host: mysite.com 200 OK Content-Type: application/xml joe_citizen Response

OPTIONS OPTIONS /people HTTP/1.1 Host: mysite.com 200 OK Allowed: GET,HEAD,POST Response

Status Codes

2xx = All good 200 – OK 201 – Created

3xx = Redirect 301 – Moved permanently 307 – Temporary redirect 304 – Not modified (ie, see cache)

4xx = Client error 400 – Bad request 401 – Unauthorized 403 – Forbidden 405 – Method not allowed 409 – Conflict

5xx = Server error 500 – Internal server error

Headers

Content-Type: text/html application/xml image/jpeg....

WWW-Authenticate: Authorization:

Last-Modified: If-Modified-Since: ETag: If-None-Match:

Location:

Describe your services?

URI Templates

Start URL + Links Tina Jones <link rel="history" href="/tjones/account_history"> <link rel="close" verb="delete" href="/tjones">

Microformats Tina Jones <link rel="transaction-search" href="account_history? from={date-from}& to={date-to}">

State Management Search google.com/ search?q=rest google.com/search?q=rest& start=10 Next Page Searching Searched More Results

Data Format?

XHTML Accounts <a rel="account_details" href="/tjones">Tina Jones.....

JSON { "account_name": "Tina Jones", "links": {"history": "/tjones/history"} }

Framework

Ordering Pizza

GET / HTTP/1.1 Host: epizza.com Content-Type: application/xml

Response 200 OK Location: Content-Type: application/xml Content-Length:... Welcome! <link rel="place-order" href="/orders" />

Let's see the menu! GET /menu HTTP/1.1 Host: epizza.com Content-Type: application/xml

200 OK Location: <link rel="place-order" href="/orders" /> Menu Response

Ordering time! POST /orders HTTP/1.1 Host: epizza.com Content-Type: application/xml Content-Length:...

201 Created Location: Content-Type:... <link rel="destination" href="/orders/413/address"> Place Order Response

Beer with that?

OPTIONS /orders/413 HTTP/1.1 Host: epizza.com 200 OK Allowed: GET, HEAD, POST, PUT

Add Beer POST /orders/413 HTTP/1.1 Host: epizza.com Content-Type: application/xml Content-Length:...

200 OK Location: Content-Type:... <link rel="destination" href="/orders/413/destination"> Response

Destination Address PUT /orders/413/address HTTP/1.1 Host: epizza.com Content-Type: application/xml Content-Length: Rue Rd Potts Point

Destination Response 200 OK Host: epizza.com Content-Type: application/xml Content-Length: Rue Rd Potts Point

200 OK Location: Content-Type:... GET /orders/413

Can we? OPTIONS /orders/413 HTTP/1.1 Host: epizza.com 200 OK Allowed: GET, HEAD

Too late!

Back at the ePizza Kitchen..

GET /orders

Implementation

Client var request = (HttpWebRequest) WebRequest.Create(URL); request.Method request.ContentType request.GetRequestStream() var response = (HttpWebResponse)request.GetResponse(); response.StatusCode response.Headers response.GetResponseStream()

Server

IHttpHandler public class RestHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/xml"; if (context.Request.HttpMethod == "GET") { context.Response.Write("... "); }

WCF REST [ServiceContract] public interface IPizzaService { [WebGet(UriTemplate="/orders/{orderId}")] [OperationContract] Order GetOrder(int orderId); }

Status codes? Headers? Links? Microformats?

ASP.NET MVC

Routing Table Controller Method ModelView

Routes In GlobalApplication : HttpApplication void RegisterRoutes(RouteCollection routes) { routes.MapRoute( "AddToOrder", "orders/{id}", new { controller = "Orders", action = "AddToOrder" }, new { httpMethod = new HttpMethodConstraint("POST")});... }

Controller public class OrdersController : Controller { public ActionResult AddToOrder(int id) { var order = Order.Load(id); var itemToAdd = CreateMenuItemFromRequest(); order.Items.Add(itemToAdd); order.Save(); // response.StatusCode = 200; return View(order); }

Model public class Order { public MenuItem[] Items { get {... }; } public Address DeliveryAddress { get; set; } }

View " /> <link rel="destination" href=...

MVC REST Wrinkles

See also... Slides & Code MVC RESTful Web Services

- web - bridge - web - defibrillator - padlocks - ws* stack - tunnel - fielding - bill gates - network plugs - speedometers - Petco explosion - letter - Eiffel tower - pizza restaurant - pepperoni pizza - corona - salad pizza boxes – REST book Image References

Questions?