REST - Introduction Based on material from InfoQ.com (Stefan Tilkov) And slides from MindTouch.com (Steve Bjorg) 1.

Slides:



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

Give it a REST already Arnon Rotem-Gal-Oz VP R&D xsights
Representational State Transfer (REST) Paul Townend 8 th February 2007.
REST - Representational State Transfer
REST Vs. SOAP.
REST Introduction 吴海生 博克软件(杭州)有限公司.
Building and using REST information services Rion Dooley.
Introduction to Web Services
REST (Representational State Transfer)
Reinventing using REST. Anything addressable by a URI is called a resource GET, PUT, POST, DELETE WebDAV (MOVE, LOCK)
Hypertext Transfer PROTOCOL ----HTTP Sen Wang CSE5232 Network Programming.
COM vs. CORBA.
SOAP Quang Vinh Pham Simon De Baets Université Libre de Bruxelles1.
Chapter 3: Programming Web Services Service-Oriented Computing: Semantics, Processes, Agents – Munindar P. Singh and Michael N. Huhns, Wiley, 2005.
Why RESTafarians live shorter Lyntale Javazone 8. september 2010 André Wiik Seniorkonsulent Webstep AS.
Copyright 2004 Monash University IMS5401 Web-based Systems Development Topic 2: Elements of the Web (g) Interactivity.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Controling instrument in the RESTful way
RESTful Publish Subscribe Xiang Su
Rensselaer Polytechnic Institute CSC-432 – Operating Systems David Goldschmidt, Ph.D.
CS 415 N-Tier Application Development By Umair Ashraf July 6,2013 National University of Computer and Emerging Sciences Lecture # 9 Introduction to Web.
Data Access Patterns. Motivation Most software systems require persistent data (i.e. data that persists between program executions). In general, distributing.
Web Architecture & Services (2) Representational State Transfer (REST)
REST.  REST is an acronym standing for Representational State Transfer  A software architecture style for building scalable web services  Typically,
Wyatt Pearsall November  HyperText Transfer Protocol.
Microsoft Visual Studio 2010 Muhammad Zubair MS (FAST-NU) Experience: 5+ Years Contact:- Cell#:
1 Dr Alexiei Dingli Web Science Stream Introducing Rails.
Overview Web Session 3 Matakuliah: Web Database Tahun: 2008.
A Limited Definition of Web Services Paul Kopacz CIS* Service Oriented Architecture Instructor: Qusay H. Mahmoud, Ph.D. February.
SNOWTAM Trial: REST Interface. AIXM XML Developers' Seminar 2 Contents Digital-SNOWTAM Trial Introduction REST Introduction REST in the Digital-SNOWTAM.
1 Seminar on Service Oriented Architecture Principles of REST.
RESTful Web Services.
Web Architecture update for WSAWG/WSDL TAG published Principles of the Web Contents: –Identifiers Most of the work –Formats Not much –Protocols Summary.
API Crash Course CWU Startup Club. OUTLINE What is an API? Why are API’s useful? What is HTTP? JSON? XML? What is a RESTful API? How do we consume an.
2007cs Servers on the Web. The World-Wide Web 2007 cs CSS JS HTML Server Browser JS CSS HTML Transfer of resources using HTTP.
Advanced Web Technologies Lecture #4 By: Faraz Ahmed.
Representational State Transfer (REST). What is REST? Network Architectural style Overview: –Resources are defined and addressed –Transmits domain-specific.
RESTful Web Services What is RESTful?
Web Services An Introduction Copyright © Curt Hill.
Web Technologies Lecture 10 Web services. From W3C – A software system designed to support interoperable machine-to-machine interaction over a network.
© 2008 IBM Corporation Presentation URLs from Resource URLs Last updated Sep. 22, 2008.
Copyright © 2004, Keith D Swenson, All Rights Reserved. OASIS Asynchronous Service Access Protocol (ASAP) Tutorial Overview, OASIS ASAP TC May 4, 2004.
/16 Final Project Report By Facializer Team Final Project Report Eagle, Leo, Bessie, Five, Evan Dan, Kyle, Ben, Caleb.
Representational State Transfer COMP6017 Topics on Web Services Dr Nicholas Gibbins –
REST API Design. Application API API = Application Programming Interface APIs expose functionality of an application or service that exists independently.
Protocol Bindings Joint oneM2M Call, 31 Aug 2016.
Tiny http client and server
Introduction to .NET Florin Olariu
The Client-Server Model
Thoughts on Architecture for the Internet of Things
REST: Web Services Abel Sanchez.
REST- Representational State Transfer Enn Õunapuu
Node.js Express Web Services
Advanced Web-based Systems | Misbhauddin
Representational State Transfer
Ashish Pandit IT Architect, Middleware & Integration Services
WEB API.
Lecture 1: Multi-tier Architecture Overview
$, $$, $$$ API testing Edition
Service-Oriented Computing: Semantics, Processes, Agents
A gentle introduction to RESTful APIs
The Power of a Great API Damian Brady
REST APIs Maxwell Furman Department of MIS Fox School of Business
RESTful Web Services.
REST på Microsoft-stacken
WEB SERVICES From Chapter 19, Distributed Systems
A gentle introduction to RESTful APIs
Chengyu Sun California State University, Los Angeles
REST API Design Borrowed heavily from:
Presentation transcript:

REST - Introduction Based on material from InfoQ.com (Stefan Tilkov) And slides from MindTouch.com (Steve Bjorg) 1

Key REST principles REST is a set of principles that define how Web standards, such as HTTP and URIs, are supposed to be used The principles: ‒ Give every “thing” an ID ‒ Link things together ‒ Use standard methods ‒ Resources with multiple representations ‒ Communicate statelessly 2

Give every “thing” an ID Everything that should be identifiable should obviously get an ID On the Web, there is a unified concept for IDs: The URI. URIs make up a global namespace, and using URIs to identify your key resources means they get a unique, global ID. It is not a pre-requisite in REST to construct human readable URIs, but it makes it easier to use. Use URIs to identify everything that merits being identifiable, specifically, all of the “high-level” resources that your application provides, whether they represent individual items, collections of items, virtual and physical objects, or computation results. 3

Give every “thing” an ID What is the difference betweens the URIs in the first box compared to the second box?

Link things together “Hypermedia as the engine of application state”, HATEOAS Hypermedia: the idea of links – as in HTML 5 23 An application can get information about product and customer by following the links Use links to refer to identifiable things (resources) wherever possible.

Use standard methods The standard methods (verbs) of HTTP are: ‒ GET (request a resource) ‒ POST(usually create new resource) ‒ PUT(update or create ressource) ‒ DELETE(delete ressource) ‒ HEAD and OPTIONS Using HTTP ensures that the opponent knows what you mean. Also the HTTP methods, except POST, are idempotent, so you may call a method, e.g. GET, again if you don’t receive a response RESTful services must obey the restrictions of HTTP But is that really a problem? See next slide 6

Example Traditional service interfaces: The services and operations are connected to a specific resource Therefore the client must have specific knowledge of the interface/ application protocol 7

Example (procurement) RESTful In a RESTful HTTP approach, you would have to get by with the generic interface that makes up the HTTP application protocol. The specific operations of the service are mapped to the standard HTTP methods E.g. A GET on a URI that identifies a customer is just as meaningful as a getCustomerDetails operation 8

Compare traditional services and RESTful services The triangle: Pick any two In traditional services you might have many operations, many data types but few instances (Services, remote objects, endpoints etc.) In RESTful services you have a limited number operations (4), many data types and many instances (could be any thing on the web, i.e. http servers, gateways, providers like Google, Yahoo, Live, etc.) Recap: For clients to be able to interact with your resources, they should implement the default application protocol (HTTP) correctly, i.e. make use of the standard methods GET, PUT, POST, DELETE. 9

Resources with multiple representations How does a client know how to deal with the data it retrieves, e.g. as a result of a GET or POST request? The approach taken by HTTP, is to allow for a separation of concerns between handling the data and invoking operations. In other words, a client that knows how to handle a particular data format can interact with all resources that can provide a representation in this format. 10 How does this differ from OOP?

Resources with multiple representations Using HTTP content negotiation, a client can ask for a representation in a particular format: 11 GET /customers/1234 HTTP/1.1 Host: example.com Accept: application/vnd.mycompany.customer+xml GET /customers/1234 HTTP/1.1 Host: example.com Accept: text/x-vcard You can also do it explicit in the URI, e.g. /customers/1234?vcard or /customers/1234/vcard

Resources with multiple representations Ideally, the representations of a resource should be in standard formats ‒ If a client “knows” both the HTTP application protocol and a set of data formats, it can interact with any RESTful HTTP application in the world in a very meaningful way. ‒ Unfortunately, we don’t have standard formats for everything, but you can create some for your own ecosystem. Of course all of this does not only apply to the data sent from the server to the client, but also for the reverse direction ‒ A server that can consume data in specific formats does not care about the particular type of client, provided it follows the application protocol. 12

Resources with multiple representations If you provide both xml and html, you can turn your application’s Web UI into its Web API API design is often driven by the idea that everything that can be done via the UI should also be doable via the API. 13 GET /customers/1234 HTTP/1.1 Host: example.com Accept: application/vnd.mycompany.customer+xml GET /customers/1234 HTTP/1.1 Host: example.com Accept: text/html

Communicate statelessly Most applications are not stateless But the state should be kept in the client or in an resource It means that the server should not maintain state for each client One reason is that it makes the client independent of changes on the server side, and even makes it possible to use another server if the first one crashes during a transaction. Another reason is scalability. It affect the servers performance if it must keep client state for a huge number of clients. Therefore it not RESTful to use the session object 14

REST by Example Some slides from from MindTouch.comMindTouch.com

Problem Statement Customer wants to update his order with ACME Enterprises

REST Example Wile E. Coyote /customers/coyote GET Get the customer

REST Example open... /customers/coyote/customers/coyote/orders GET Get a list of customer’s orders

REST Example open ACME Rocket /customers/coyote/customers/coyote/orders/orders/1234 GET Get a specified order

REST Example open ACME Rocket /customers/coyote/customers/coyote/orders/orders/1234 GET PUT Change the specified order

REST Example /customers/coyote/customers/coyote/orders/orders/1234 GET Simple resource-centric few verbs Scalable resource discovery stateless protocol Layered cacheable results intelligent intermediaries GET PUT