Presentation is loading. Please wait.

Presentation is loading. Please wait.

REST (REpresentational State Transfer)

Similar presentations


Presentation on theme: "REST (REpresentational State Transfer)"— Presentation transcript:

1 REST (REpresentational State Transfer)
Youn-Hee Han

2 What is REST? REST (Representational State Transfer)
대규모 네트워크 시스템을 위한 설계패턴 또는 아키텍처 웹을 기반으로 하는 대규모 네트워크 시스템 설계 및 구현을 위한 일종의 원칙들의 모음 2000년 Roy Fielding의 박사 학위 논문에서 처음 제안. Architectural Styles and the Design of Network-based Software Architectures (DOCTOR OF PHILOSOPHY) 최근 추가된 뜻 XML과 HTTP를 사용하는 단순한 웹 기반 인터페이스를 지칭 (즉, REST의 원칙을 따르는 Web Services)

3 All Resources on WEB are represented as XML by URL (Representation)
What is REST? 왜 Representational State Transfer 이라고 명칭을 붙였나? All Resources on WEB are represented as XML by URL (Representation) CLICK URL 표현 (다른 URL 포함) Representational State Transfer은 잘 디자인된 웹 어플리케이션이 어떻게 동작하는 지에 대한 이미지를 떠올리게 하기 위한 용어이다. 즉 웹을 거대한 Virtual State Machine이라고 생각하면 우리는 그 웹의 상태를 XML등으로 표현된 것으로 확인할 수 있고 그 전에 알고 있던 또는 XML에 포함된 링크를 선택/호출함으로써 Machine내에 존재하는 State가 전이되고 새로운 표현 (New State Representation)이 보여지게 된다

4 What is REST? 좀 더 현실적인 REST의 설명
Web Service를 구현하는 기존 방식인 SOAP, XML-RPC보다 매우 간단 최근 Open API 구현에 많이 사용 많은 웹2.0 회사들이 Open API의 구현 방법으로 많이 사용. 구글, 플리커, 아마존 등의 Open API가 REST 방식으로 구현되어 공개 서비스의 서버 플랫폼 구축에 있어 필수적인 아키텍쳐로 인식됨 REST는 실제 표준은 아니지만 HTTP/URL/MIME Type같은 웹 표준만을 사용 구글이 오랫동안 제공해온 SOAP 기반 검색 API 서비스가 2006년 12월 5일 부로 중단 대신 구글은 REST 기반의 Ajax Search API를 대안으로 제시

5 What is REST? REST is not a standard REST is just a design pattern
You will not see the W3C REST specification. You will not see IBM or Microsoft or Sun selling a REST developer's toolkit. REST is just a design pattern You can only understand it and design your Web services according to its rules. REST does prescribe the use of standards: HTTP URL XML/HTML/JSON/GIF/JPEG/etc. (Resource Representations) text/xml, text/html, image/gif, image/jpeg, etc. (Resource Types, MIME Types)

6 What is REST? REST의 성공 요인 상태를 유지하지 않는 (Stateless) 클라이언트/서버 구조를 가진다.
작고 어디에서나 적용되는 인터페이스를 가진다. GET, POST, PUT, DELETE PUT과 DELETE 메소드는 HTTP스펙에는 존재하지만 지원하는 브라우저는 거의 없다. 모든 자원은 URL를 이용하여 유일하게 지칭될 수 있다. 자원들의 표현(Representation)들이 URL을 통해 서로 연결되어 있다. REST의 원칙에는 쿠키나 세션을 사용하지 않는다.

7 CRUD Operations in REST
URL을 통해 필요한 자원을 계속해서 추적하여… 얻어(GET) 가거나 생성(POST) 하거나 삽입(PUT) 삭제(DELETE) 할 수 있게 분류 설계한다. CRUD/HTTP 사이의 대응 전체 시스템은 단지 다음 4개의 명령을 사용해서만 동작한다. 애플리케이션 작업 HTTP 명령 Create POST (non idempotent) Read GET (safe, idempotent) Update PUT (idempotent) Delete DELETE (idempotent)

8 REST vs. RPC (Remote Procedure Call)-style
REST vs RPC-style (Java RMI, CORBA, DCOM, SOAP…) REST URL 서버 주소/서비스 이름/자원 Examples 잘 된 구성 - (O) 잘못 된 구성 - (X)

9 Web Design, Axiom 0 (Tim Berners-Lee, director of W3C)
Axiom 0: all resources on the Web must be uniquely identified with a URI. resource1 URL1 resource2 URL2 resource3 URL3

10 Example1: Airline Reservation Service
The airline wants to ensure that its premier members get immediate service, its frequent flyer members get expedited service and all others get regular service There are two main approaches to implementing the reservation service…

11 Approach 1 "Press 1 for Premier, Press 2 for…“
The airline provides a single telephone number. Upon entry into the system a customer encounters an automated message, "Press 1 if you are a premier member, press 2 if you are a frequent flyer, press 3 for all others." Premier Customer Representative Premier Members F.F. Customer Representative Answering Machine Airline Reservations Frequent Flyer Members Regular Customer Representative Regular Members

12 Approach 2 " Telephone Numbers are Cheap! Use Them!”
The airline provides several telephone numbers - one number for premier members, a different number for frequent flyers, and still another for regular customers. Premier Customer Representative 1-800-Premier Premier Members F.F. Customer Representative 1-800-Frequent Frequent Flyer Members Regular Customer Representative 1-800-Reservation Regular Members

13 Approach 2: URLs are Cheap! Use Them!
The airline provides several URLs - one URL for premier members, a different URL for frequent flyers, and still another for regular customers. Premier Member Reservation Service client Premier Members Frequent Flyer Reservation Service client Frequent Flyer Members Regular Member Reservation Service client Regular Members

14 Approach 2 Advantages The different URLs are discoverable by search engines and UDDI registries. It's easy to understand what each service does simply by examining the URL. There is no need to introduce rules. Priorities are elevated to the level of a URL. "What you see is what you get." It's easy to implement high priority simply assign a fast machine at the premier member URL. There is no bottleneck. There is no central point of failure. Consistent with Axiom 0.

15 Three Fundamental Aspects of the REST Design Pattern
Resources Every distinguishable entity is a resource. A resource may be a Web site, an HTML page, an XML document, or a Web service, etc. URL can identify Resources Every resource is uniquely identified by a URL. This is Tim Berners-Lee Web Design, Axiom 0. CRUD operations Resources URLs Simple Operations (CRUD)

16 HTTP status codes HTTP Response Status codes
It indicate the result of the HTTP request (참고: 대표 응답 코드 1XX – informational 2XX – success 200: (일반적인) 성공 GET, PUT 요청 성공시에 보내는 응답 코드 201: 성공적으로 요청되었으며 서버가 새 리소스를 생성했음 POST 요청 성공시에 보내는 응답 코드 204: 성공적으로 요청되었으며 관련된 자원 정보는 존재하지 않음 DELETE 요청 성공시에 보내는 응답 코드 3XX – redirection 301: 영구이동 302: 임시이동 304: 수정되지 않음. 클라이언트는 안심하고 캐시된 정보를 활용함

17 HTTP status codes HTTP Response Status codes 대표 응답 코드
4XX - client error 400: 요구되는 파라미터(QueryString) 부재 403: 요청 금지. 서버의 요청 거부 404: 요청된 자원을 찾을 수 없음 GET, PUT, DELETE 요청에 대하여 해당 자원을 찾을 수 없을때 보내는 응답 코드 409: 서버가 요청을 수행하는 중에 충돌 발생 POST에 의하여 이미 존재하는 리소스에 대한 생성 요청에 대한 응답 코드 5XX - server error 500: 내부 서버 오류 503: 일시적인 서버 오류. 요청이 너무 많아서 처리할 수 없을 때

18 HTTP Media Types “Accept” and “Content-Type” HTTP headers “Accept”
used to describe the content being sent or requested within an HTTP request. “Accept” Clients may set “Accept” to application/json if it is requesting a response in JSON. “Content-Type” Conversely, when sending data, setting “Content-Type” to application/xml tells the client that the data being sent in the request is XML.


Download ppt "REST (REpresentational State Transfer)"

Similar presentations


Ads by Google