Presentation is loading. Please wait.

Presentation is loading. Please wait.

Advanced Web-based Systems | Misbhauddin

Similar presentations


Presentation on theme: "Advanced Web-based Systems | Misbhauddin"— Presentation transcript:

1 Advanced Web-based Systems | Misbhauddin
Web Services REST Advanced Web-based Systems | Misbhauddin

2 Advanced Web-based Systems | Misbhauddin
Web Services Web services are web application components that provide an interface to the applications and not users Approaches XML-RPC SOAP REST Client / Server Web Services Advanced Web-based Systems | Misbhauddin

3 Advanced Web-based Systems | Misbhauddin
Web Scalability Issue The WorldWideWeb (W3) is a wide-area hypermedia information retrieval initiative aiming to give universal access to a large universe of documents. - Tim Berners-Lee The above was said about the web in 1991 Web began to grow exponentially since then The “Universe of Documents” was expanding The Web was growing too large, too fast, and it was heading toward collapse It was unclear if the Web would scale to meet the increasing demand Advanced Web-based Systems | Misbhauddin

4 Web Scalability - Solution
Roy Fielding got concerned by the Web Scalability Problem Web’s scalability was governed by a set of key constraints Uniformly satisfy all of the constraints - so that the Web could continue to expand Advanced Web-based Systems | Misbhauddin

5 Advanced Web-based Systems | Misbhauddin
Constraints The six constraints are: Client-Server Uniform Interface Layered System Cacheable Stateless Code on Demand (optional) Advanced Web-based Systems | Misbhauddin

6 Advanced Web-based Systems | Misbhauddin
Client-Server Web is a client-server based system Clients and Servers have distinct parts to play They may be implemented and deployed independently using any language or technology Assume a disconnected system Separation of Concern But they should conform to Uniform Interface Advanced Web-based Systems | Misbhauddin

7 Advanced Web-based Systems | Misbhauddin
Uniform Interface There is interaction between web components Clients, Servers, Intermediaries Depends on a uniform interface between them If any of them move away from standards Web Communication breaks down Four sub-constraints - Simplifies and decouples the architecture Identification of resources; Manipulation of resources through representations; Self-descriptive messages; HATEOAS Advanced Web-based Systems | Misbhauddin

8 Identification | Uniform Interface
Identification of Resources Each web-based concept is known as a resource It is addressed by a unique identifier – URI Advanced Web-based Systems | Misbhauddin

9 Manipulation | Uniform Interface
Manipulation of Resources through Representations Clients manipulate representation of resources Same resource is represented in different way to different clients A file can be sent as a HTML to a web browser and as a JSON to an application Resources can be manipulated through representations without changing the actual resource Advanced Web-based Systems | Misbhauddin

10 Self-Descriptive | Uniform Interface
Self-Descriptive Messages Desired representation (or state) can be mentioned in the request message Current state is mentioned in the response message The resource state is included as a self-descriptive message Advanced Web-based Systems | Misbhauddin

11 HATEOAS | Uniform Interface
Hypermedia As The Engine Of Application State A resource’s state includes link to other resources The presence or absence of a link is a part of the resource’s current state Advanced Web-based Systems | Misbhauddin

12 Advanced Web-based Systems | Misbhauddin
Layered System Client cannot assume direct connection to the server Software or hardware intermediaries between the server and the client – Gateways and Proxies Also called network based intermediaries Improves scalability Network-based intermediaries are commonly used for Enforcement of security Response caching Load balancing Advanced Web-based Systems | Misbhauddin

13 Advanced Web-based Systems | Misbhauddin
Cacheable| REST Caching is one of web architecture’s most important constraints Caching response data can help Reduce client-perceived latency Increase the overall availability and reliability of an application Control a web server’s load In other words, caching reduces the cost of the web Cache can exist in any place in the path between the client and the server Advanced Web-based Systems | Misbhauddin

14 Advanced Web-based Systems | Misbhauddin
Stateless| REST Web Server does not remember the state of its client applications Each request contains enough context to process the message Self-descriptive messages; Any session state is kept on the client Client manage the state – Server can service much larger clients Advanced Web-based Systems | Misbhauddin

15 Advanced Web-based Systems | Misbhauddin
Code on Demand| REST Server can temporarily transfer executable code (scripts and plug-ins) to the client Transfer logic to client - Client executes logic Client must be able to understand and execute the code that it demands from the server This is why it is Optional For example JavaScript Java Applets Flash Advanced Web-based Systems | Misbhauddin

16 Advanced Web-based Systems | Misbhauddin
REST Representation State Transfer Set of architectural principles – data transmitted over HTTP Focus on design rules for stateless service Each resource is represented using a unique URI Representation of the resource is returned With each representation, client can transfer state All-in-all, it is an architectural style composed of all the six constraints Advanced Web-based Systems | Misbhauddin

17 Advanced Web-based Systems | Misbhauddin
RESTful Web Services Request Client Web API Web Service Backend Response Web API is the face of the Web Service REST style is applied to the design of the API The API is called REST API and the service becomes RESTful The REST API consists of interlinked resources The set of resources is known as the resource model Advanced Web-based Systems | Misbhauddin

18 Advanced Web-based Systems | Misbhauddin
URIs REST APIs use Uniform Resource Identifiers (URIs) to address resources Identify the things that you want to operate on – meaning RESOURCES A web page is a type of resource /professors List of all professors at CCSIT /professors/Misbhauddin Identify professor named ‘Misbhauddin’ GET /professors/Misbhauddin HTTP/1.1 Host: kfu.edu.sa/ccsit Resources are best thought of as nouns Advanced Web-based Systems | Misbhauddin

19 Advanced Web-based Systems | Misbhauddin
Resource Archetypes Document: A document resource is a singular concept similar to a database record. A document may have child resources that represent its specific subordinate concepts. docroot Advanced Web-based Systems | Misbhauddin

20 Advanced Web-based Systems | Misbhauddin
Resource Archetypes Collection: A collection resource is a server-managed directory of resources. Clients may propose new resources to be added to a collection Advanced Web-based Systems | Misbhauddin

21 Advanced Web-based Systems | Misbhauddin
Resource Archetypes Store: A store is a client-managed resource repository. A store resource lets an API client put resources in, get them back out, and decide when to delete them. The example interaction above shows a user (with ID 1234) of a client program using a REST API to insert a document resource named brazil in his store of favorites PUT /users/1234/favorites/brazil Advanced Web-based Systems | Misbhauddin

22 Advanced Web-based Systems | Misbhauddin
Resource Archetypes Controller: Controller resources are like executable functions, with parameters and return values; inputs and outputs. Controller names typically appear as the last segment in a URI path, with no child resources POST /alerts/245743/resend POST /alerts/245743/resend/resource Advanced Web-based Systems | Misbhauddin

23 Advanced Web-based Systems | Misbhauddin
URI Design Advanced Web-based Systems | Misbhauddin

24 Advanced Web-based Systems | Misbhauddin
Interactions Used to manipulate a resource’s representation Lets say we want to add a new professor Two ways OR …… Use a specific URL Use HTTP Verbs /professors/add Not RESTful GET /professors/Misbhauddin HTTP/1.1 Host: kfu.edu.sa/ccsit Advanced Web-based Systems | Misbhauddin

25 HTTP Verbs | Request Actions
HTTP verbs tell the server what to do with the data identified by the URL. GET used to get the representation of the resourse PUT used insert or update a resource DELETE used to delete a resource from the parent POST used to create a new resource in the collection or execute controller HEAD used to get the Headers of the response only OPTIONS used to get info about resource’s available interactions Advanced Web-based Systems | Misbhauddin

26 Advanced Web-based Systems | Misbhauddin
Request Message > GET /greeting HTTP/1.1 > User-Agent: chrome /7.20.1 > Host: api.example.restapi.org > Accept: */* < HTTP/ OK < Date: Sat, 20 Aug :02:40 GMT < Server: Apache < Expires: Sat, 20 Aug :03:40 GMT < Cache-Control: max-age=60, must-revalidate < ETag: text/html:hello world < Content-Length: 130 < Last-Modified: Sat, 20 Aug :02:17 GMT < Vary: Accept-Encoding < Content-Type: text/html <!doctype html><head><meta charset="utf-8"><title>Greeting</title></head> <body><div id="greeting">Hello World!</div></body></html> Request Headers Response Message – Status Line Response Headers Example Response Body Advanced Web-based Systems | Misbhauddin

27 Advanced Web-based Systems | Misbhauddin
Representations The HTTP client and HTTP server exchange information about resources identified by URIs Typically resource is represented using JSON or XML Example Resource: person (Mohammed) Service: contact information (GET) Representation: Name, address, phone number JSON or XML format or VCard Advanced Web-based Systems | Misbhauddin

28 Advanced Web-based Systems | Misbhauddin
SOAP vs. REST SOAP REST Language, platform, and transport independent (REST requires use of HTTP) Works well in distributed enterprise environments (REST assumes direct point-to-point communication) Standardized Provides significant pre-build extensibility in the form of the WS* standards Built-in error handling Automation when used with certain language products No expensive tools require to interact with the Web service Smaller learning curve Efficient (SOAP uses XML for all messages, REST can use smaller message formats) Fast (no extensive processing required) Closer to other Web technologies in design philosophy Advanced Web-based Systems | Misbhauddin

29 Advanced Web-based Systems | Misbhauddin
Recommended Reading For the REST architecture REST API Design Rulebook by Mark Masse Publisher: O'Reilly Media, Inc. Release Date: October 2011 Chapters 1, 2, and 3 Advanced Web-based Systems | Misbhauddin


Download ppt "Advanced Web-based Systems | Misbhauddin"

Similar presentations


Ads by Google