SlideShare a Scribd company logo
1 of 43
Download to read offline
RESTful Web
from RESTful style to RESTful code work
!
!
!
@PengEdy
2
Table of Contents
• Web & Web Service
!
• Details of REST Style
!
• Some Examples
3
Web & Web Service
4
Web Service
• Normally: a method of communications over the WWW
!
• W3C Definition: a software system
• Designed to support interoperable machine-to-machine interaction
• Over network
• An interface with a certain format: WSDL
• Other systems interact with the Web Service
5
The ways we are using web service:
• RPC: Remote Procedure Call
• Strong Coupling
• SOA: Service-oriented Architecture
• This is a good choice.
• REST: Representational State Transfer
• Another choice
6
Demo of RPC
• Server
getUser()
addUser()
removeUser()
updateUser()
getLocation()
addLocation()
removeLocation()
updateLocation()
• Client
exampleAppObject = new
ExampleApp(“example.com:
1234”)
exampleAppObject.getUser()
7
Demo of REST
• Server
http://example.com/users/
http://example.com/users/
{user}
http://example.com/
findUserForm
http://example.com/locations
http://example.con/locations/
{location}
http://example.com/
findLocationForm
• Client
userResource = new
Resource(http://
example.com/users/001)
userResource.get()
8
Our Web…
• Human Web
• For normal users
• Website, Web Application, etc.
• Programmable Web
• For program/programmer
• A set of API
9
Web History
• Stage 1: Static Content
• At the beginning of web
• Full of static HTML content, which is the papers made by the scholar 
• Like a file sharing server supports Hypertext
!
• Is that enough ? We want MORE !
10
Web History
• Stage 2: CGI Program
• People wanted to have more function on the web.
• API appeared.
• CGI is made by C/C++, Perl, and some other language, which is 



powerful but a little tricky.
!
• But, we want it better…
11
Web History
• Stage 3: Script Languages
• CGI is not safe, so we have script languages.
• ASP, JSP, PHP, Java Applet, JavaScript, etc…
• HTML was mixed with scripts, which is much more safe and powerful.
!
• Well, it was still tricky for developers with pure scripts.
• The mixture of HTML and script was horrible when code increased.
!
• And, we want more !
12
Web History
• Stage 4: Thin Client
• All the content was produced on the server.
• And we had MVC !
• Back-end technology runs fast in this stage.
!
• Still, we want more !
13
Web History
• Stage 5: Rich Interactive Application (RIA)
• Developers started to build single page application, which can be very 



useful on the desktop.
• Front-end technology started to run.
• Ajax, jQuery/jQuery UI, ExtJS, Prototype, etc…
• Flex, Sliverlight, JavaFX
• ……
!
• Always, we want more !
14
Web History
• Stage 6: Mobile Application
• RIA is great, we now have something greater — mobile web.
• iOS, Android, Windows Phone, Blackberry, etc..
• HTML5 + CSS3 + JavaScript
!
• We are happy with it now, while we both know that’s not enough.
15
Web NOW !
• Pure HTML is not enough.
• CGI and scripts suck.
• Developers, users, administrators want to be happy !
!
• So, we have made our mind and technology improved:
• Resource Oriented
• HTTP 1.1: request method, status code, cache
• REST
16
RESTful and Resource Oriented Architecture
• REST: Representational State Transfer
• a style, not a standerd
• ROA
• What is resource: anything useful
• Resources must have URIs.
• Use HTTP verbs to implement CRUD
• Provide 2 kind of web service
• Human Web
• Programmable Web
17
HTTP Request Methods
• Verbs: 
• OPTIONS
• HEAD
• GET
• POST
• PUT
• DELETE
• TRACE
• CONNECT
• PATCH
18
HTTP Request Methods
• Safe method: just get information, doesn’t change anything.
• GET, HEAD
• Idempotent methods: multiple identical requests should have the same
effect as a single request.
• GET, HEAD, PUT, DELETE, OPTIONS, TRACE
!
• We focus on: GET, POST, DELETE, PUT
19
Details of REST Style
20
Build REST from Everything
• There are two thoughts when we want build something:
• Nothing we have, we start from bringing in.
• Everything we have, we start from cutting down.
!
• For REST, the author made some cut off on the former web style.
21
RESTful Binding
• Client-Server
• Separate the system into client and server
• Client call request, send it to server
22
RESTful Binding
• Stateless
• Request shall contain all the information it needs.
• Server identify requests by the info it stored in, not some info on the 



server.
23
RESTful Binding
• Cacheable
• Data in the request should marked as either cacheable or not, in a 



sensitive or insensitive way, so that client can cache the data.
24
RESTful Binding
• Uniform Interface
• Optimize the structure
• Light coupling
25
RESTful Binding
• Layered System
• Simplify the system
• Make high performance possible
26
RESTful Binding
• Code on Demand
• Expand system
27
REST Quick Tips
• Use HTTP Verbs to mean something: GET, PUT, DELETE, POST
• Provide sensible resource names
• Use HTTP response code to indicate status
• Offer JSON and XML
28
HTTP Methods
• We will only discuss the most useful four methods here:
• GET
• PUT
• POST
• DELETE
29
HTTP Methods: GET
# Add bookmark
GET /bookmarks/add_bookmark?href=http%3A%2F%2F
www.example.org%2F2009%2F10%2F10%2Fontes.html HTTP/1.1
Host: www.example.org
# Add cart
GET /add_cart?pid=1234 HTTP/1.1
Host: www.example.org
# Delete note
GET /notes/delete?id=1234 HTTP/1.1
Host: www.example.org
30
HTTP Methods: PUT
• PUT will only be used when client can decide the URI or resource. 
!
# Request
PUT /user/smith/address/home_address HTTP/1.1
Host: www.example.com
Content-type: application/xml;charset=UTF-8
<address>
<street>1, Main Street</street>
<city>New York</city>
</address>
31
HTTP Methods: PUT
# Response
HTTP/1.1 201 Created
Location: http://www.example.org/user/smith/address/home_address
Content-Location: http://www.example.org/user/smith/address/home_address
Content-Type: application/xml;charset=UTF-8
<address>
<id>urn:example:user:smith:address:1</id>
<atom>link rel=“self” href=“http://www.example.org/user/smith/address/
home_address”/>
<street>1, Main Street</street>
<city>New York</city>
</address>
32
HTTP Methods: POST
• Create new resource if we don’t
know the URI
• Update resource(s) using controller
• Run research which has too many
parameters
• Other actions which are not safe
# Request
POST /user/smith HTTP/1.1
Host: www.example.com
Content-type: application/xml;charset=UTF-8
Slug: Home Address
<address>
<street>1, Main Street</street>
<city>New York</city>
</address>
33
HTTP Methods: POST
# Response
HTTP/1.1 201 Created
Location: http://www.example.org/user/smith/address/home_address
Content-Location: http://www.example.org/user/smith/address/home_address
Content-Type: application/xml;charset=UTF-8
<address>
<id>urn:example:user:smith:address:1</id>
<atom>link rel=“self” href=“http://www.example.org/user/smith/address/
home_address”/>
<street>1, Main Street</street>
<city>New York</city>
</address>
34
HTTP Methods: DELETE
• DELETE a resource on the web.
!
# Request
DELETE /users/john HTTP/1.1
Host: www.example.com
35
Resource Naming
• To name a resource to make it readable and programmable
• URI: the name of resource as well as an address on the web
• A RESTful URI should refer to a resource that is a thing, not an action.
• Resource:
• Users of the system
• Courses in which a student is enrolled
• A user’s timeline of posts
• The users that follow another user (some kind of relationship)
• An article or a news on the web
• etc…
36
Resource Naming
• Some examples:
• To insert/create a new customer in the system:
• POST http://example.com/customers
• To read a customer with Customer ID #12345
• GET http://example.com/customers/12345
• the same URI would be used for PUT & DELETE, to update and delete
• For reading , updating, deleting, product #12345:
• GET/PUT/DELETE http://example.com/pruducts/12345
37
Resource Naming
• More examples:
• To create an order for a customer:
• POST http://example.com/customers/12345/orders
• GET http://example.com/customers/12345/orders
• What will it return ?
• POST http://example.com/customers/12345/orders/2334/lineitems
• What will this return ?
38
Resource Naming
• More and more real examples:
• Twitter: https://dev.twitter.com/docs/api
• Facebook: http://develpoers.facebook.com/docs/api/
• LinkedIn: https://developer.linkedin.com/apis
• more…
39
RESTful API Demo
40
Build a website
41
Build a set of API
42
Programming Languages and Frameworks
• Java
• PHP
• Python
• Ruby
• JavaScript (Node.js)
• C#
• etc…
43
Thanks for your listening !

More Related Content

What's hot

HTTP protocol and Streams Security
HTTP protocol and Streams SecurityHTTP protocol and Streams Security
HTTP protocol and Streams SecurityBlueinfy Solutions
 
Web services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGigWeb services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGigMandakini Kumari
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
Web Services - A brief overview
Web Services -  A brief overviewWeb Services -  A brief overview
Web Services - A brief overviewRaveendra Bhat
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jerseyb_kathir
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni InturiSreeni I
 
REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)Jef Claes
 
Webservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and RESTWebservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and RESTPradeep Kumar
 
Using Java to implement RESTful Web Services: JAX-RS
Using Java to implement RESTful Web Services: JAX-RSUsing Java to implement RESTful Web Services: JAX-RS
Using Java to implement RESTful Web Services: JAX-RSKatrien Verbert
 
Restful web services with java
Restful web services with javaRestful web services with java
Restful web services with javaVinay Gopinath
 
An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST Ram Awadh Prasad, PMP
 

What's hot (20)

Web Services
Web ServicesWeb Services
Web Services
 
SOAP-based Web Services
SOAP-based Web ServicesSOAP-based Web Services
SOAP-based Web Services
 
Overview of java web services
Overview of java web servicesOverview of java web services
Overview of java web services
 
HTTP protocol and Streams Security
HTTP protocol and Streams SecurityHTTP protocol and Streams Security
HTTP protocol and Streams Security
 
Web Services Tutorial
Web Services TutorialWeb Services Tutorial
Web Services Tutorial
 
L18 REST API Design
L18 REST API DesignL18 REST API Design
L18 REST API Design
 
Web services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGigWeb services soap and rest by mandakini for TechGig
Web services soap and rest by mandakini for TechGig
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Web Services - A brief overview
Web Services -  A brief overviewWeb Services -  A brief overview
Web Services - A brief overview
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni Inturi
 
REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)REST and ASP.NET Web API (Milan)
REST and ASP.NET Web API (Milan)
 
Webservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and RESTWebservices Overview : XML RPC, SOAP and REST
Webservices Overview : XML RPC, SOAP and REST
 
Using Java to implement RESTful Web Services: JAX-RS
Using Java to implement RESTful Web Services: JAX-RSUsing Java to implement RESTful Web Services: JAX-RS
Using Java to implement RESTful Web Services: JAX-RS
 
Restful web services with java
Restful web services with javaRestful web services with java
Restful web services with java
 
Restful web services ppt
Restful web services pptRestful web services ppt
Restful web services ppt
 
SOAP vs REST
SOAP vs RESTSOAP vs REST
SOAP vs REST
 
An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST An Overview of Web Services: SOAP and REST
An Overview of Web Services: SOAP and REST
 
Web service introduction
Web service introductionWeb service introduction
Web service introduction
 
XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)XML-RPC and SOAP (April 2003)
XML-RPC and SOAP (April 2003)
 

Similar to RESTful web

Restful风格ž„web服务架构
Restful风格ž„web服务架构Restful风格ž„web服务架构
Restful风格ž„web服务架构Benjamin Tan
 
CNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application TechnologiesCNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application TechnologiesSam Bowne
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API RecommendationsJeelani Shaik
 
CNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesCNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesSam Bowne
 
REST Methodologies
REST MethodologiesREST Methodologies
REST Methodologiesjrodbx
 
API Testing. Streamline your testing process.
API Testing. Streamline your testing process.API Testing. Streamline your testing process.
API Testing. Streamline your testing process.Andrey Oleynik
 
Ch 3: Web Application Technologies
Ch 3: Web Application TechnologiesCh 3: Web Application Technologies
Ch 3: Web Application TechnologiesSam Bowne
 
Coding 100-session-slides
Coding 100-session-slidesCoding 100-session-slides
Coding 100-session-slidesCisco DevNet
 
Real-time web applications using SharePoint, SignalR and Azure Service Bus
Real-time web applications using SharePoint, SignalR and Azure Service BusReal-time web applications using SharePoint, SignalR and Azure Service Bus
Real-time web applications using SharePoint, SignalR and Azure Service BusDinusha Kumarasiri
 
Austin Day of Rest - Introduction
Austin Day of Rest - IntroductionAustin Day of Rest - Introduction
Austin Day of Rest - IntroductionHandsOnWP.com
 
Middleware in Golang: InVision's Rye
Middleware in Golang: InVision's RyeMiddleware in Golang: InVision's Rye
Middleware in Golang: InVision's RyeCale Hoopes
 
ekb.py: KISS REST API
ekb.py: KISS REST APIekb.py: KISS REST API
ekb.py: KISS REST APIYury Yurevich
 
ekbpy'2012- Юрий Юревич - Как сделать REST API на Python
ekbpy'2012- Юрий Юревич - Как сделать REST API на Pythonekbpy'2012- Юрий Юревич - Как сделать REST API на Python
ekbpy'2012- Юрий Юревич - Как сделать REST API на Pythonit-people
 
Building Awesome APIs with Lumen
Building Awesome APIs with LumenBuilding Awesome APIs with Lumen
Building Awesome APIs with LumenKit Brennan
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP TutorialLorna Mitchell
 
REST and REST-fulness
REST and REST-fulnessREST and REST-fulness
REST and REST-fulnessDavid Waite
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Henry S
 

Similar to RESTful web (20)

Restful风格ž„web服务架构
Restful风格ž„web服务架构Restful风格ž„web服务架构
Restful风格ž„web服务架构
 
CNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application TechnologiesCNIT 129S - Ch 3: Web Application Technologies
CNIT 129S - Ch 3: Web Application Technologies
 
REST API Recommendations
REST API RecommendationsREST API Recommendations
REST API Recommendations
 
CNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application TechnologiesCNIT 129S: Ch 3: Web Application Technologies
CNIT 129S: Ch 3: Web Application Technologies
 
REST Methodologies
REST MethodologiesREST Methodologies
REST Methodologies
 
API Testing. Streamline your testing process.
API Testing. Streamline your testing process.API Testing. Streamline your testing process.
API Testing. Streamline your testing process.
 
Ch 3: Web Application Technologies
Ch 3: Web Application TechnologiesCh 3: Web Application Technologies
Ch 3: Web Application Technologies
 
Coding 100-session-slides
Coding 100-session-slidesCoding 100-session-slides
Coding 100-session-slides
 
Remix
RemixRemix
Remix
 
Real-time web applications using SharePoint, SignalR and Azure Service Bus
Real-time web applications using SharePoint, SignalR and Azure Service BusReal-time web applications using SharePoint, SignalR and Azure Service Bus
Real-time web applications using SharePoint, SignalR and Azure Service Bus
 
Austin Day of Rest - Introduction
Austin Day of Rest - IntroductionAustin Day of Rest - Introduction
Austin Day of Rest - Introduction
 
Middleware in Golang: InVision's Rye
Middleware in Golang: InVision's RyeMiddleware in Golang: InVision's Rye
Middleware in Golang: InVision's Rye
 
ekb.py: KISS REST API
ekb.py: KISS REST APIekb.py: KISS REST API
ekb.py: KISS REST API
 
ekbpy'2012- Юрий Юревич - Как сделать REST API на Python
ekbpy'2012- Юрий Юревич - Как сделать REST API на Pythonekbpy'2012- Юрий Юревич - Как сделать REST API на Python
ekbpy'2012- Юрий Юревич - Как сделать REST API на Python
 
Building Awesome APIs with Lumen
Building Awesome APIs with LumenBuilding Awesome APIs with Lumen
Building Awesome APIs with Lumen
 
SCWCD : The web client model
SCWCD : The web client modelSCWCD : The web client model
SCWCD : The web client model
 
Web Services PHP Tutorial
Web Services PHP TutorialWeb Services PHP Tutorial
Web Services PHP Tutorial
 
REST and REST-fulness
REST and REST-fulnessREST and REST-fulness
REST and REST-fulness
 
Node.js
Node.jsNode.js
Node.js
 
Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1Code for Startup MVP (Ruby on Rails) Session 1
Code for Startup MVP (Ruby on Rails) Session 1
 

Recently uploaded

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 

Recently uploaded (20)

ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 

RESTful web

  • 1. RESTful Web from RESTful style to RESTful code work ! ! ! @PengEdy
  • 2. 2 Table of Contents • Web & Web Service ! • Details of REST Style ! • Some Examples
  • 3. 3 Web & Web Service
  • 4. 4 Web Service • Normally: a method of communications over the WWW ! • W3C Definition: a software system • Designed to support interoperable machine-to-machine interaction • Over network • An interface with a certain format: WSDL • Other systems interact with the Web Service
  • 5. 5 The ways we are using web service: • RPC: Remote Procedure Call • Strong Coupling • SOA: Service-oriented Architecture • This is a good choice. • REST: Representational State Transfer • Another choice
  • 6. 6 Demo of RPC • Server getUser() addUser() removeUser() updateUser() getLocation() addLocation() removeLocation() updateLocation() • Client exampleAppObject = new ExampleApp(“example.com: 1234”) exampleAppObject.getUser()
  • 7. 7 Demo of REST • Server http://example.com/users/ http://example.com/users/ {user} http://example.com/ findUserForm http://example.com/locations http://example.con/locations/ {location} http://example.com/ findLocationForm • Client userResource = new Resource(http:// example.com/users/001) userResource.get()
  • 8. 8 Our Web… • Human Web • For normal users • Website, Web Application, etc. • Programmable Web • For program/programmer • A set of API
  • 9. 9 Web History • Stage 1: Static Content • At the beginning of web • Full of static HTML content, which is the papers made by the scholar • Like a file sharing server supports Hypertext ! • Is that enough ? We want MORE !
  • 10. 10 Web History • Stage 2: CGI Program • People wanted to have more function on the web. • API appeared. • CGI is made by C/C++, Perl, and some other language, which is 
 
 powerful but a little tricky. ! • But, we want it better…
  • 11. 11 Web History • Stage 3: Script Languages • CGI is not safe, so we have script languages. • ASP, JSP, PHP, Java Applet, JavaScript, etc… • HTML was mixed with scripts, which is much more safe and powerful. ! • Well, it was still tricky for developers with pure scripts. • The mixture of HTML and script was horrible when code increased. ! • And, we want more !
  • 12. 12 Web History • Stage 4: Thin Client • All the content was produced on the server. • And we had MVC ! • Back-end technology runs fast in this stage. ! • Still, we want more !
  • 13. 13 Web History • Stage 5: Rich Interactive Application (RIA) • Developers started to build single page application, which can be very 
 
 useful on the desktop. • Front-end technology started to run. • Ajax, jQuery/jQuery UI, ExtJS, Prototype, etc… • Flex, Sliverlight, JavaFX • …… ! • Always, we want more !
  • 14. 14 Web History • Stage 6: Mobile Application • RIA is great, we now have something greater — mobile web. • iOS, Android, Windows Phone, Blackberry, etc.. • HTML5 + CSS3 + JavaScript ! • We are happy with it now, while we both know that’s not enough.
  • 15. 15 Web NOW ! • Pure HTML is not enough. • CGI and scripts suck. • Developers, users, administrators want to be happy ! ! • So, we have made our mind and technology improved: • Resource Oriented • HTTP 1.1: request method, status code, cache • REST
  • 16. 16 RESTful and Resource Oriented Architecture • REST: Representational State Transfer • a style, not a standerd • ROA • What is resource: anything useful • Resources must have URIs. • Use HTTP verbs to implement CRUD • Provide 2 kind of web service • Human Web • Programmable Web
  • 17. 17 HTTP Request Methods • Verbs: • OPTIONS • HEAD • GET • POST • PUT • DELETE • TRACE • CONNECT • PATCH
  • 18. 18 HTTP Request Methods • Safe method: just get information, doesn’t change anything. • GET, HEAD • Idempotent methods: multiple identical requests should have the same effect as a single request. • GET, HEAD, PUT, DELETE, OPTIONS, TRACE ! • We focus on: GET, POST, DELETE, PUT
  • 20. 20 Build REST from Everything • There are two thoughts when we want build something: • Nothing we have, we start from bringing in. • Everything we have, we start from cutting down. ! • For REST, the author made some cut off on the former web style.
  • 21. 21 RESTful Binding • Client-Server • Separate the system into client and server • Client call request, send it to server
  • 22. 22 RESTful Binding • Stateless • Request shall contain all the information it needs. • Server identify requests by the info it stored in, not some info on the 
 
 server.
  • 23. 23 RESTful Binding • Cacheable • Data in the request should marked as either cacheable or not, in a 
 
 sensitive or insensitive way, so that client can cache the data.
  • 24. 24 RESTful Binding • Uniform Interface • Optimize the structure • Light coupling
  • 25. 25 RESTful Binding • Layered System • Simplify the system • Make high performance possible
  • 26. 26 RESTful Binding • Code on Demand • Expand system
  • 27. 27 REST Quick Tips • Use HTTP Verbs to mean something: GET, PUT, DELETE, POST • Provide sensible resource names • Use HTTP response code to indicate status • Offer JSON and XML
  • 28. 28 HTTP Methods • We will only discuss the most useful four methods here: • GET • PUT • POST • DELETE
  • 29. 29 HTTP Methods: GET # Add bookmark GET /bookmarks/add_bookmark?href=http%3A%2F%2F www.example.org%2F2009%2F10%2F10%2Fontes.html HTTP/1.1 Host: www.example.org # Add cart GET /add_cart?pid=1234 HTTP/1.1 Host: www.example.org # Delete note GET /notes/delete?id=1234 HTTP/1.1 Host: www.example.org
  • 30. 30 HTTP Methods: PUT • PUT will only be used when client can decide the URI or resource. ! # Request PUT /user/smith/address/home_address HTTP/1.1 Host: www.example.com Content-type: application/xml;charset=UTF-8 <address> <street>1, Main Street</street> <city>New York</city> </address>
  • 31. 31 HTTP Methods: PUT # Response HTTP/1.1 201 Created Location: http://www.example.org/user/smith/address/home_address Content-Location: http://www.example.org/user/smith/address/home_address Content-Type: application/xml;charset=UTF-8 <address> <id>urn:example:user:smith:address:1</id> <atom>link rel=“self” href=“http://www.example.org/user/smith/address/ home_address”/> <street>1, Main Street</street> <city>New York</city> </address>
  • 32. 32 HTTP Methods: POST • Create new resource if we don’t know the URI • Update resource(s) using controller • Run research which has too many parameters • Other actions which are not safe # Request POST /user/smith HTTP/1.1 Host: www.example.com Content-type: application/xml;charset=UTF-8 Slug: Home Address <address> <street>1, Main Street</street> <city>New York</city> </address>
  • 33. 33 HTTP Methods: POST # Response HTTP/1.1 201 Created Location: http://www.example.org/user/smith/address/home_address Content-Location: http://www.example.org/user/smith/address/home_address Content-Type: application/xml;charset=UTF-8 <address> <id>urn:example:user:smith:address:1</id> <atom>link rel=“self” href=“http://www.example.org/user/smith/address/ home_address”/> <street>1, Main Street</street> <city>New York</city> </address>
  • 34. 34 HTTP Methods: DELETE • DELETE a resource on the web. ! # Request DELETE /users/john HTTP/1.1 Host: www.example.com
  • 35. 35 Resource Naming • To name a resource to make it readable and programmable • URI: the name of resource as well as an address on the web • A RESTful URI should refer to a resource that is a thing, not an action. • Resource: • Users of the system • Courses in which a student is enrolled • A user’s timeline of posts • The users that follow another user (some kind of relationship) • An article or a news on the web • etc…
  • 36. 36 Resource Naming • Some examples: • To insert/create a new customer in the system: • POST http://example.com/customers • To read a customer with Customer ID #12345 • GET http://example.com/customers/12345 • the same URI would be used for PUT & DELETE, to update and delete • For reading , updating, deleting, product #12345: • GET/PUT/DELETE http://example.com/pruducts/12345
  • 37. 37 Resource Naming • More examples: • To create an order for a customer: • POST http://example.com/customers/12345/orders • GET http://example.com/customers/12345/orders • What will it return ? • POST http://example.com/customers/12345/orders/2334/lineitems • What will this return ?
  • 38. 38 Resource Naming • More and more real examples: • Twitter: https://dev.twitter.com/docs/api • Facebook: http://develpoers.facebook.com/docs/api/ • LinkedIn: https://developer.linkedin.com/apis • more…
  • 41. 41 Build a set of API
  • 42. 42 Programming Languages and Frameworks • Java • PHP • Python • Ruby • JavaScript (Node.js) • C# • etc…
  • 43. 43 Thanks for your listening !