Tecnologia e Applicazioni Internet 2008/9

Similar documents
Misurazione performance. Processing time. Performance. Throughput. Francesco Marchioni Mastertheboss.com Javaday IV Roma 30 gennaio 2010

Session 6 Patterns and best practices in SOA/REST

ITIL v3 - Overview. Claudio Tancini Marzo 2015 INTERNAL USE ONLY

Designing RESTful Web Applications

TDD da un capo all altro. Matteo Vaccari (cc) Alcuni diritti riservati

Nuovi domini di primo livello - Registra nuove estensioni con FabsWeb_HOST

SOA and Virtualization Technologies (ENCS 691K Chapter 2)

Lezione 10 Introduzione a OPNET

Versione: 2.1. Interoperabilità del Sistema di Accettazione di SPT

Chi sono in quattro punti.

Programmable Graphics Hardware

Enabling REST Services with SAP PI. Michael Le Peter Ha

Mobility User mobility Service mobility 3GPP

New Media Advertising Agency

Stefan Tilkov. Stefan Tilkov, innoq Deutschland GmbH REST Introduction

TabCaratteri=" abcdefghijklmnopqrstuvwxyz._~ABCDEFGHIJKLMNOPQRSTUVWXYZ";

Advanced Networking Voice over IP & Other Multimedia Protocols Some SIP Advanced Topics

DIRECTORS AND OFFICERS PROPOSTA DI POLIZZA

Internetworking e applicazioni

From RPC to Web Apps: Trends in Client-Server Systems

A Comparison of Service-oriented, Resource-oriented, and Object-oriented Architecture Styles

Corso: Supporting and Troubleshooting Windows 10 Codice PCSNET: MW10-3 Cod. Vendor: Durata: 5

REST vs. SOAP: Making the Right Architectural Decision

How To Lock A File In A Microsoft Microsoft System

Lesson 4 (A1/A2) Present simple forma interrogativa e negativa FORMA. + infinito senza to. Does he / she / it. No, I / you / we / they don t.

Guidelines for Implementation of REST

Geo-Platform Introduction

A Comparison of Service-oriented, Resource-oriented, and Object-oriented Architecture Styles

ESERCIZIO PL/SQL e PSP

How To Test An Electronic Board With A Flying Probe Tester

User Manual ZMONITOR. Tool for managing parametric controllers

Converting the stay permit. from study to work

Web-Based Hazus-MH. A Conceptual Approach. Mourad Bouhafs, AVP ATKINS Atlanta mourad.bouhafs@atkinsglobal.com

Programma corso di formazione J2EE

By : Khalid Alfalqi Department of Computer Science, Umm Al-Qura University

An Oracle White Paper June RESTful Web Services for the Oracle Database Cloud - Multitenant Edition

DTI / Titolo principale della presentazione IPHONE ENCRYPTION. Litiano Piccin. 11 ottobre 2014

Dott. Ruggero Giorgianni. Gruppo Pre-intermediate. Il Futuro

Main Points. File layout Directory layout

Banners Broker è una. Compagnia di pubblicità online

Public Affairs & Communication Huawei Italia

IJISET - International Journal of Innovative Science, Engineering & Technology, Vol. 1 Issue 7, September

Corso: Administering Microsoft SQL Server 2012 Databases Codice PCSNET: MSQ2-1 Cod. Vendor: Durata: 5

Alberto Meneghini! Security Leader, IBM Italia! IBM Security IBM Corporation IBM Corporation

Come utilizzare il servizio di audioconferenza

MUSICIAN WEB-SERVICE USING RUBY-ON-RAILS, SOAP, FLEX & AJAX

Blogs.msdn.com/vstsitalia.

Corso: Mastering Microsoft Project 2010 Codice PCSNET: MSPJ-11 Cod. Vendor: Durata: 3

Industrial Control Systems Security. Denny Gregianin_Sales Area Manager

Converting the Stay Permit

This project was supported by Grant No DB-BX-K105 awarded by the Bureau of Justice, Office of Justice Programs in collaboration with the U.S.

Titoli delle qualifiche

Continuous Integration

Applicazioni Web 2014/15

Odoo 8.0. Le nuove API.

TRADING ONLINE E STATISTICA PDF

Beauty College Cartoon Denim

LOCAL ADVERTISING BOOK 2015

REST (Representa.onal State Transfer) Ingegneria del So-ware e Lab. Università di Modena e Reggio Emilia Do<. Marzio Franzini

Integrating Complementary Tools with PopMedNet TM

STAMPI PER CIOCCOLATO CATALOGO STAMPI PER CIOCCOLATO CHOCOLATE MOULDS CATALOG

REST web services. Representational State Transfer Author: Nemanja Kojic

Reti Informatiche. WireShark.

Security Testing For RESTful Applications


Multimedia im Netz Online Multimedia Winter semester 2015/16. Tutorial 03 Major Subject

APC-Pro sa Computer Service

Limiti verticali e classificazione Vertical limits and classification Amendola

Gli International Standard on Auditing e gli altri Standard Professionali Internazionali

2. After saying yes, sometimes there s no choice but to say no... From the tone you can tell that no means No! No

ACCESS TO GSE INTERNET PORTAL

ISTITUTO NAZIONALE DI FISICA NUCLEARE CONSIGLIO DIRETTIVO DELIBERAZIONE N

PREPOSITION OF PLACE

tel fax

Matrix Logic WirelessDMS Service 2.0

«Software Open Source come fattore abilitante dei Progetti per le Smart Cities»

Accessing Data with ADOBE FLEX 4.6

Source code security testing

Setting the World on FHIR

A RESTful Web Service for Whois. Andy Newton Chief Engineer, ARIN

Web Design and Development ACS-1809

INVESTIRE BITCOIN PDF

How To Test Pressure On A Hydromusic Pump

Laboratorio di Sistemi Digitali M A.A. 2010/11

KET SELF PLACEMENT TEST

Click on REGISTRAZIONE NUOVO UTENTE at the bottom of the page.

Organization Requested Amount ( ) Leading Organization Partner 1*

Best Practices for the Design of RESTful Web Services

C.S.E. Nodi Tipici Parametrizzati al /04/2015 Copyright (c) Castalia srl

Curated by Silvio Valpreda

ESERCIZI ESTIVI PER IL SUPERAMENTO DEL DEBITO CLASSI PRIME a.s. 2013/14

Session 9 Scalable Data Management: NoSQL & Map/Reduce

IBM System Storage DS3400 Simple SAN Express Kit PN U

1/20. MobiLab. 17 Luglio

Il Data Model di Europeana!

Method of Unified Communications and Collaboration Service in Open Service Platform based on RESTful Web Services

Leveraging Cloud Storage Through Mobile Applications Using Mezeo Cloud Storage Platform REST API. John Eastman Mezeo

APC-Pro sa Computer Service

IBM System Storage DS3400 Simple SAN Ready Express

IBM Bluemix, the digital innovation platform

Transcription:

Tecnologia e Applicazioni Internet 2008/9 Lezione 4 - Rest Matteo Vaccari http://matteo.vaccari.name/ matteo.vaccari@uninsubria.it

What is REST?

Roy Fielding Representational State Transfer Roy T. Fielding Architectural Styles and the Design of Network-based Software Architectures, Ph.D dissertation, 2000

REST is a Software Architecture Style a set of Constraints on Component Interaction that, when obeyed, cause the resulting Architecture to have certain properties Roy T. Fielding http://roy.gbiv.com/untangled/2008/on-software-architecture

Web Applications Information Flow HTTP OOP RDB MS Gabriele Lana, REST and Resource Oriented Architectures, PHP Con 2009

HTTP is REST the most common REST architecture HTTP OOP RDB MS Gabriele Lana, REST and Resource Oriented Architectures, PHP Con 2009

Impedance Mismatch HTTP OOP RDB MS Gabriele Lana, REST and Resource Oriented Architectures, PHP Con 2009

Accidental Complexity HTTP OOP RDB MS Gabriele Lana, REST and Resource Oriented Architectures, PHP Con 2009

Essential Complexity HTTP OOP RDB MS Gabriele Lana, REST and Resource Oriented Architectures, PHP Con 2009

RPC OOP RDB MS HTTP RPC Gabriele Lana, REST and Resource Oriented Architectures, PHP Con 2009

Resource Oriented Architectures HTTP ROA RDB MS Gabriele Lana, REST and Resource Oriented Architectures, PHP Con 2009

Not Today But... Yes, we Can HTTP ROA DATA Gabriele Lana, REST and Resource Oriented Architectures, PHP Con 2009

Uniform Ryan: We need to be able to talk to all machines about all the stuff that s on all the other machines. So we need some way of having one machine tell another machine about a resource that might be on yet another machine.... Wife: So how do the machines tell each other where things are? Ryan: The URL, of course. If everything that machines need to talk about has a corresponding URL, you've created the machine equivalent of a noun. http://tomayko.com/writings/rest-to-my-wife

What is REST? (a) Give a name to every Thing (b) Link Things together (c) Use standard methods (d) Communicate statelessly

(a) Give a name to every Thing A resource is any interesting concept in your domain Every resource should be identified by a URI Resources are the important parts of the application domain URIs are the nouns

Le più importanti invenzioni - IV http://www.example.org/ URI Uniform Resource Identifier

URI Uniform Resource Identifier Il nome di una risorsa rfc2396

URI Uniform Resource Identifiers (URI) provide a simple and extensible means for identifying a resource. Tim Berners-Lee, Roy Fielding, rfc2396

Esempi di URI ftp://ftp.is.co.za/rfc/rfc1808.txt gopher://spinaltap.micro.umn.edu/00/weather/california/los%20angeles http://www.math.uio.no/faq/compression-faq/part1.html mailto:mduerst@ifi.unizh.ch news:comp.infosystems.www.servers.unix telnet://melvyl.ucop.edu

What is a resource? A resource can be anything that has identity. Familiar examples include an electronic document, an image, a service (e.g., today's weather report for Los Angeles ), and a collection of other resources. Not all resources are network retrievable ; e.g., human beings, corporations, and bound books in a library can also be considered resources. Tim Berners-Lee, Roy Fielding, rfc2396

Altri esempi di risorse La versione 22.1 del software rilasciato L ultima versione del software rilasciato Il primo post del blog del 2 ottobre 2006 Il post dedicato a RESTful Web Services Una mappa di Varese Informazioni sui facoceri Il primo numero primo > 1024 I primi 5 numeri primi > 1024 La lista dei bachi aperti Richardson and Ruby, RESTful Web Services

Esempi di URI http://www.example.com/software/releases/22.1.tgz http://www.example.com/software/releases/latest.tgz http://www.example.com/blog/2007/10/2/0 http://www.example.com/blog/restful-web-services http://www.example.com/maps/it/va http://www.example.com/search?q=facoceri http://www.example.com/nextprime/1024 http://www.example.com/next-5-primes/1024 http://www.example.com/bugs/by-state/open Richardson and Ruby, RESTful Web Services

E che ci facciamo con le risorse? Having identified a resource, a system may perform a variety of operations on the resource, as might be characterized by such words as access, update, replace, or find attributes Tim Berners-Lee, Roy Fielding, rfc2396

URI e URL URI: Universal Resource Identifier URL: Univeral Resource Locator URL refers to the subset of URI that identify resources via a representation of their primary access mechanism (e.g., their network location ) Tim Berners-Lee, Roy Fielding, rfc2396

Addressability Un applicazione Web è indirizzabile se espone gli aspetti interessanti dei suoi dati come risorse

Google Mail è indirizzabile? https://mail.google.com/mail/#inbox/11dbe2460af15fe6 https://mail.google.com/mail/#label/aaa-agire https://mail.google.com/mail/#search/marco

Wordpress è indirizzabile? http://matteo.vaccari.name/blog/archives/138 http://matteo.vaccari.name/blog/archives/date/2008/10 http://matteo.vaccari.name/blog/archives/category/agile

(b) Link Things together Humans use the web by starting with a URL, and then following links Machines should do the same

<ul> <li><a href="/position/...?nextplayer=0">start play as "0"</a></li> <li><a href="/position/...?nextplayer=x">start play as "X"</a></li> </ul>

<table cellspacing="0" cellpadding="0"> <tr> <td class="right bottom"><a href='x...?nextplayer=0'>x</a></td> <td class ="right bottom"><a href='.x...?nextplayer=0'>x</a></td> <td class ="bottom"><a href='..x...?nextplayer=0'>x</a></td> </tr> <tr> <td class="right bottom"><a href='...x...?nextplayer=0'>x</a></td> <td class ="right bottom"><a href='...x...?nextplayer=0'>x</a></td> <td class ="bottom"><a href='...x...?nextplayer=0'>x</a></td> </tr> <tr> <td class="right"><a href='...x..?nextplayer=0'>x</a></td> <td class ="right"><a href='...x.?nextplayer=0'>x</a></td> <td ><a href='...x?nextplayer=0'>x</a></td> </tr> </table>

(c) Use standard methods GET POST PUT DELETE

GET /some/resource HTTP/1.1 HTTP/1.1 200 OK Dammi una rappresentazione di questa risorsa Safe & Idempotent

PUT /some/resource HTTP/1.1 \n some-representation-of-my-resource HTTP/1.1 201 Created Crea una nuova risorsa alla URI data Not Safe; Idempotent

PUT /some/resource HTTP/1.1 \n some-representation-of-my-resource HTTP/1.1 205 Reset Content Modifica una risorsa presistente alla URI data Not Safe; Idempotent

DELETE /some/resource HTTP/1.1 HTTP/1.1 204 No Content Cancella una risorsa Not Safe; Idempotent

POST /articles HTTP/1.1 \n some-representation-of-my-article HTTP/1.1 201 Created Location: /articles/12345 Crea una nuova risorsa sotto la URI data Not Safe; Not Idempotent La URI della risorsa creata viene decisa dal server

Create Read Update Delete

find create update destroy SELECT INSERT UPDATE DELETE

GET POST PUT DELETE find create update destroy SELECT INSERT UPDATE DELETE

POST /people/create GET /people/show/1 POST /people/update/1 POST /people/destroy/1

POST GET PUT /people /people/1 /people/1 DELETE /people/1

RPC style Steven Tilkov, http://www.infoq.com/articles/rest-introduction

Steven Tilkov, http://www.infoq.com/articles/rest-introduction

(d) Communicate Statelessly Two kinds of state: Resource state (on the server) Application state (on the client)

Representational State Transfer R1 R2 R3 R4 CLIENT State Application SERVER Resource State Gabriele Lana, REST and Resource Oriented Architectures, PHP Con 2009

REST design quiz Un ordine può essere in stato aperto oppure chiuso (a) PUT a new state to the resource (b) Move (logically) the resource from the open orders collection to the closed orders one (c) Create a new OrderClosure resource

REST design quiz (ii) Se un cliente POSTa un ordine, e non riceve una risposta, non sa se l ordine è stato ricevuto oppure no. Se lo POSTa di nuovo, rischia di mandare due ordini uguali (infatti POST non è idempotente). (a) Esponi la risorsa l ultimo ordine che ti ho mandato (b) Crea gli ordini con PUT (ma a quale URI?) (c) Includi nella POST un ID unico (ma come lo ottengo?)

So, what is REST?

REST = The Web as it should work... the motivation for developing REST was to create an architectural model for how the Web should work, such that it could serve as the guiding framework for the Web protocol standards http://www.ics.uci.edu/~fielding/pubs/dissertation/evaluation.htm

REST = the Web for humans and the Web for robots should work the same way

REST = Design your domain model around CRUD Before refactoring, IconBuffet had 10 controllers and 76 actions:... Now, without adding or removing any features, IconBuffet has 13 controllers and 58 actions. There are seven standard Rails actions: index, new, create, show, edit, update, and destroy. Everything else oddball actions are usually a clue that you re doing RPC. http://scottraymond.net/2006/7/20/refactoring-to-rest/

REST = Make your domain model a part of the Web

Extend Tris RESTfully

How to design a REST service? 1. Identify Resources in your Domain (Tris) 2. Design the URIs 3. For each Resource expose a subset of the Uniform Interface (GET, PUT, POST, DELETE) 4. For each Resource design the Representations 5. Design typical flows and error conditions Richardson & Ruby, RESTful Web Services, O Reilly

1. Identify resources in your domain Player Game Move Position

1. Identify resources in your domain X Player 0 Player From Position Game Move To Position

2. Design the URIs /position/0...x...0

2. Design the URIs /position/initial

2. Design the URIs /player/1737514

3. Expose the Uniform Interface POST /position/...0... HTTP/1.1 \n move=x8 HTTP/1.1 302 Found Location: /position/...0...x POST to let resources process information

3. Expose the Uniform Interface POST /game HTTP/1.1 \n X=/player/10304 0=/player/99383 HTTP/1.1 201 Created Location: /game/42 POST to create new resources