RESTful Web Services.

Slides:



Advertisements
Similar presentations
REST - Representational State Transfer
Advertisements

REST Vs. SOAP.
REST Introduction 吴海生 博克软件(杭州)有限公司.
Introduction to Web Services
Testing Web Applications & Services Testing Web Applications & Web Services.
Building RESTful Interfaces
CS 415 N-Tier Application Development By Umair Ashraf July 6,2013 National University of Computer and Emerging Sciences Lecture # 9 Introduction to Web.
RESTful Web Development With Nodejs and Express. REST Stands for REpresentational State Transfer Has the following constraints: ◦Client-Server ◦Stateless.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Copyright © cs-tutorial.com. Introduction to Web Development In 1990 and 1991,Tim Berners-Lee created the World Wide Web at the European Laboratory for.
ASP.NET + Ajax Jesper Tørresø ITNET2 F08. Ajax Ajax (Asynchronous JavaScript and XML) A group of interrelated web development techniques used for creating.
REST.  REST is an acronym standing for Representational State Transfer  A software architecture style for building scalable web services  Typically,
RESTful applications Norman White. REST Representational state transfer Key concepts – Client Server architecture built on transferring resources between.
Python and REST Kevin Hibma. What is REST? Why REST? REST stands for Representational State Transfer. (It is sometimes spelled "ReST".) It relies on a.
Murach’s ASP.NET 4.0/VB, C1© 2006, Mike Murach & Associates, Inc.Slide 1.
School of Computing and Information Systems CS 371 Web Application Programming PHP – Forms, Cookies, Sessions and Database.
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
1 Seminar on Service Oriented Architecture Principles of REST.
DM_PPT_NP_v01 SESIP_0715_JR HDF Server HDF for the Web John Readey The HDF Group Champaign Illinois USA.
Asynchronous Javascript And XML AJAX : an introduction UFCEUS-20-2 : Web Programming.
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.
ASP.NET (Active Server Page) SNU OOPSLA Lab. October 2005.
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?
REST By: Vishwanath Vineet.
Web Technologies Lecture 10 Web services. From W3C – A software system designed to support interoperable machine-to-machine interaction over a network.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Feeling RESTful? Well, first we’ll define a Web Service –A web page meant to be consumed by a computer via an autonomous program as opposed to a web browser.
Martin Kruliš by Martin Kruliš (v1.0)1.
Representational State Transfer COMP6017 Topics on Web Services Dr Nicholas Gibbins –
A Presentation Presentation On JSP On JSP & Online Shopping Cart Online Shopping Cart.
National College of Science & Information Technology.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Web Development. Agenda Web History Network Architecture Types of Server The languages of the web Protocols API 2.
INLS 623– Stored Procedures
Javascript and Dynamic Web Pages: Client Side Processing
API (Application Program Interface)
Understanding XMLHttpRequest
Web Concepts Lesson 2 ITBS2203 E-Commerce for IT.
RESTful Sevices Distributed Objects Presented by: Shivank Malik
AJAX.
AJAX and jQuery AJAX AJAX Concepts, XMLHttpRequest, jQuery AJAX: $.ajax(), $.get(), $.post() jQuery AJAX XMLHttpRequest SoftUni Team Technical Trainers.
WEB SERVICES.
REST- Representational State Transfer Enn Õunapuu
Node.js Express Web Services
AJAX and REST.
Unit – 5 JAVA Web Services
Advanced Web-based Systems | Misbhauddin
Callback Function function passed as a parameter to another function
CMPE 280 Web UI Design and Development October 26 Class Meeting
What is REST API ? A REST (Representational State Transfer) Server simply provides access to resources and the REST client accesses and presents the.
CMPE 280 Web UI Design and Development October 24 Class Meeting
Representational State Transfer
Introduction to J2EE Architecture
WEB API.
Ashish Pandit, Louis Zelus, Jonathan Whitman
Web Development Using ASP .NET
SDWIS Prime REST APIs Elinor Keith
Lecture 1: Multi-tier Architecture Overview
$, $$, $$$ API testing Edition
JavaScript & jQuery AJAX.
Web Programming Language
Service-Oriented Computing: Semantics, Processes, Agents
A gentle introduction to RESTful APIs
REST APIs Maxwell Furman Department of MIS Fox School of Business
REST på Microsoft-stacken
Week 05 Node.js Week 05
A gentle introduction to RESTful APIs
Chengyu Sun California State University, Los Angeles
Presentation transcript:

RESTful Web Services

RESTful Web Services REST stands for REpresentational State Transfer. REST revolves around resource where every component is a resource and a resource is accessed by a common interface using HTTP standard methods. REST Server simply provides access to resources and REST client accesses and modifies the resources. Each resource is identified by URIs/ global IDs. REST uses various representation to represent a resource like text, JSON, XML. JSON is the most popular one.

RESTful Web Services Web services based on REST Architecture are known as RESTful web services. RESTful web services use HTTP methods A RESTful web service usually defines a URI for a service and provides resource representation such as JSON.

Client–Server Architecture Client application and server application MUST be able to evolve separately without any dependency on each other. A client should know only resource URIs. Servers and clients may be replaced and developed independently. Separating the user interface from the data storage. Improves the portability of the user interface across multiple platforms. It also improves scalability by simplifying the server components.

Uniform interface A resource in the system should have only one logical URI It’s always better to synonymies a resource with a web page. Any single resource should not be too large and contain each and everything in its representation. All resources should be accessible through a common approach such as HTTP GET. Once a developer becomes familiar with one of your API, he should be able to follow the similar approach for other APIs.

Stateless Server will not store anything about latest HTTP request client made. Server will treat each and every request as new. No session, no history. If client application needs to be a stateful, where user logs in once and do other authorized operations, then each request from the client should contain all the information necessary to service the request – including authentication and authorization details. The client is responsible for managing the state of the application.

Cacheable Caching of data and responses is important wherever they are applicable/possible. Caching brings performance improvement for client side, and better scope for scalability for a server because the load has reduced. In REST, caching shall be applied to resources when applicable and then these resources MUST declare themselves cacheable. Caching can be implemented on the server or client side. Well-managed caching partially or completely eliminates some client-server interactions.

Layered system REST allows you to use a layered system architecture where you deploy the APIs on server A, and store data on server B and authenticate requests in Server C, for example. A client cannot ordinarily tell whether it is connected directly to the end server, or to an intermediary along the way. Intermediary servers can improve system scalability by enabling load balancing and by providing shared caches.

Code on demand (optional) Most of the time you send the static representations of resources in form of XML or JSON. But you may return executable code to support a part of your application. JavaScript, Java Applet Clients may call your API to get a UI widget rendering code. It is permitted.

RESTful uses HTTP Four HTTP methods are commonly used in REST. GET − Provides a read only access to a resource. POST − Used to create a new resource. DELETE − Used to remove a resource. PUT − Used to update a existing resource or create a new resource.

REST API Frameworks ASP.Net (C#) Spring (Java) Express (Node.js) Loopback (Node.js) Restify (Node.js) Django (Python) Flask (Python) Laravel (PHP) And many others…

Building REST APIs using Node.js (Express) Express is integrated with minimal and flexible Node.js web application and has a robust set of features. npm install express --save

Building REST APIs using Node.js (Express) var express = require('express'), app = express(); app.listen(3000); console.log('RESTful API server started on: ' + 3000); var todoList = require('./todolistcontroler.js'); app.route('/') .get(todoList.home); app.route('/tasks') .get(todoList.list_all_tasks) .post(todoList.list_all_tasks);

Building REST APIs using Node.js (Express) app.route('/tasks/r/:taskId') .get(todoList.list_all_tasks) .post(todoList.list_all_tasks); app.route('/tasks/a/:taskId/:taskName') .get(todoList.create_task) .put(todoList.update_task) app.route('/tasks/d/:taskId') .get(todoList.delete_task) .delete(todoList.delete_task);

todolistcontroler.js var taskdb=[]; exports.home = function(req, res) { res.sendFile(__dirname +'/todohome.html'); }; exports.list_all_tasks = function(req, res) { res.json(taskdb); exports.create_task = function(req, res) { taskdb.push({'id':req.params.taskId, 'name':req.params.taskName}); res.json("ok");

todolistcontroler.js exports.read_task = function(req, res) { for (var i = 0; i < taskdb.length; i++) { if(taskdb[i].id==req.params.taskId){ res.json(taskdb[i]); return; } res.json("not found"); }; exports.update_task = function(req, res) { taskdb[i]=req.params.taskName; res.json("ok");

todolistcontroler.js exports.delete_task = function(req, res) { for (var i = 0; i < taskdb.length; i++) { if(taskdb[i].id==req.params.taskId){ taskdb.splice(i, 1); res.json("ok"); return; } res.json("not found"); };

An HTML page to test REST APIs <body> <h2>To Do Tasks</h2> <button type="button" onclick="list()">List</button> <button type="button" onclick="add()">Add/Upate</button> <button type="button" onclick="del()">Delete</button> <button type="button" onclick="del()">Read</button> <br/> <input type="text" id="id" value=""> <input type="text" id="name" value=""> <div id="result"></div>

An HTML page to test REST APIs <script> function list() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { tasks=JSON.parse(this.responseText); document.getElementById("result").innerHTML=""; for (var i = 0; i < tasks.length; i++) { document.getElementById("result").innerHTML+=tasks[i].id+" "+tasks[i].name; } }; xhttp.open("GET", "/tasks", true); xhttp.send();

An HTML page to test REST APIs function add() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("result").innerHTML=this.responseText; } }; id=document.getElementById("id").value; name=document.getElementById("name").value; xhttp.open("GET", "/tasks/a/"+id+"/"+name, true); xhttp.send();

An HTML page to test REST APIs function del() { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { document.getElementById("result").innerHTML=this.responseText; } }; id=document.getElementById("id").value; xhttp.open("GET", "/tasks/d/"+id, true); xhttp.send(); </script>