SlideShare a Scribd company logo
Web Service: REST  原則與實作分享 簡報者:許登傑、林宗茂 更新日期: 2008-09-01
大綱 REST 打哪來 ? REST for rest  ♨ Client  操作範例 Curl  指令運用 Server  開發思維 實作分享 (Resource Template) 現行限制 & 框架支援 (Framework) 參考文獻 & 相關資源
REST 打哪來 ?  # 1 SOA   ≈  LEGO Web Service   Implementation RPC 、 SOAP 、 REST Re presentational  S tate  T ransfer 2000, doctoral thesis of Roy Fielding Style  of software architecture for  distributed hypermedia systems R esource  O riented  A rchitecture W orld  W ide  W eb
REST 打哪來 ?  # 2 Client (Server) Request:   GET https ://.../customers/1/orders Response:  Content-type:   XML https://.../orders/00131 https://.../orders/00832 https://.../orders/00759 Server db3n2u.sinica.edu.tw/~textdb/ap … /orders/ { id } POST /   GET / PUT / DELETE /customers/ { id } POST /   GET / PUT / DELETE /customers/ { id } /orders POST /   GET  / PUT / DELETE
REST 打哪來 ?  # 3 ROA : Four Concepts Resource resource  Name Representation  of a resource * code on demand Link to  a related resource ROA : Four Properties Addressability Uniform interface  * (# 4) well-defined operations, CRUD Statelessness Connectedness
REST 打哪來 ?  # 4 Verbs of HTTP Safe : no changes to any data on the server Idempotent : repeat without changing resource DELETE GET ○ X Delete ○ X Update create PUT ○ ○ Read X X Create update, delete POST Idempotent Safe CRUD Method
REST for rest  ♨  - Client  操作範例 REST-like on the web End user:   www.flickr.com AP / Server:   殷周金文資料庫 : GIS 座標 how to be a Client curl  /  libcurl  ( PHP/CURL )  * ex. db3x Other development… HTTP/FTP client libraries  * open source C  * libcurl  c interface  /  bindings JAVA  * Yahoo! Developer Network .NET (C#)  * Yahoo! Developer Network
REST for rest  ♨  - curl  指令操作範例 GET curl -G -d <data> -d <data> (URL) POST curl --request POST -d <data> -d <data> (URL) PUT curl --request PUT -d <data> -d <data> (URL) DELETE curl --request DELETE -d <data> -d <data> (URL) *<data>  :  variable=value
REST for rest  ♨  - curl  指令其他常用參數 curl –help :  線上求助 -u  <login:passwd> : Set user and password --silent :  不顯示 curl 回應訊息 --data-urlencode  <name=data/name@filename> : HTTP GET data url encoded  -1/--tlsv1 : Use TLSv1 (SSL) -2/--sslv2 : Use SSLv2 (SSL) -3/--sslv3 : Use SSLv3 (SSL) -k : SSL without certification
REST for rest  ♨  -  在 C 語言中執行  curl 若開發環境無法安裝  libcurl , 則直接執行  curl  指令代替 system(cmd); 指令執行成功回傳  0 、失敗回傳  -1 system(cmd > out.txt); 需取得回傳資料,可輸出為文件檔
REST for rest  ♨  - Server  開發思維 Uniform Interface
實作分享  # 1: DORE combined (Resource Template) header('Content-Type: application/vnd.google-earth.kml+xml; charset=utf-8'); echo $loader->run(); REQUEST https:// login:passwd@db1n... _login, _passwd RESPONSE $loader = new Loader(‘gismap'); $_roleList = '*'; $_webService0 = 2; require_once('../../dore/lib0.php'); $_sess->close(); <<interface>> REST restPost() restGet() restPut() restDelete() <<resource>> gismap err() usage() chkArgs() restPost() restGet() restPut() restDelete() <<handler>> Loader err() run() auth()
實作分享  # 2 (Resource Template) Key issues Authentication, Authorization HTTP basic authentication DORE Variable / Data security  * chkArgs() Verbs reacting criteria Error handler  * Yahoo! Developer Network 1  /  2
現行限制 & 框架支援 No Framework, No PUT / DELETE PHP-based Framework Zend IBM Project Zero  * WebSphere sMash WSDL 2.0  support for all HTTP verbs Java, .Net SOAP frameworks Spring, Apache CXF, Apache Axis2
參考文獻 & 相關資源 http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm “ RESTful Web Services”; Leonard Richardson, Sam Ruby; (First Edition) May 2007 http:// www.wikipedia.org / http://curl.haxx.se/ http:// developer.yahoo.com/php /

More Related Content

What's hot (20)

PPTX
分析mysql acid 设计实现
rfyiamcool
 
ODT
Spatial script for MongoBoulder
Steven Pousty
 
PDF
DNS (BIND) on CentOS
Md Tanjil Islam Bappi
 
PPT
Dns
muh kemal
 
KEY
MongoDB: How it Works
Mike Dirolf
 
PDF
XtraDB 5.7: key performance algorithms
Laurynas Biveinis
 
PDF
"Развитие ветки PHP-7"
Badoo Development
 
PDF
Anton Moldovan "Building an efficient replication system for thousands of ter...
Fwdays
 
PPTX
MySQL Audit using Percona audit plugin and ELK
YoungHeon (Roy) Kim
 
PPT
Redis深入浅出
ruoyi ruan
 
PDF
Subversion To Mercurial
Ladislav Prskavec
 
KEY
第一回MongoDBソースコードリーディング
nobu_k
 
PDF
Ilugc curl
Akilan Ram
 
PDF
Introduction HTTP via cURL
Kyosuke MOROHASHI
 
PDF
Page compression. PGCON_2016
Anastasia Lubennikova
 
PDF
Open Source Backup Conference 2014: Workshop bareos introduction, by Philipp ...
NETWAYS
 
PDF
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Ontico
 
PDF
HTTP 완벽가이드- 13 다이제스트 인증
박 민규
 
PDF
It’s about time to embrace Streams
Luciano Mammino
 
PDF
Nginx-lua
Дэв Тим Афс
 
分析mysql acid 设计实现
rfyiamcool
 
Spatial script for MongoBoulder
Steven Pousty
 
DNS (BIND) on CentOS
Md Tanjil Islam Bappi
 
MongoDB: How it Works
Mike Dirolf
 
XtraDB 5.7: key performance algorithms
Laurynas Biveinis
 
"Развитие ветки PHP-7"
Badoo Development
 
Anton Moldovan "Building an efficient replication system for thousands of ter...
Fwdays
 
MySQL Audit using Percona audit plugin and ELK
YoungHeon (Roy) Kim
 
Redis深入浅出
ruoyi ruan
 
Subversion To Mercurial
Ladislav Prskavec
 
第一回MongoDBソースコードリーディング
nobu_k
 
Ilugc curl
Akilan Ram
 
Introduction HTTP via cURL
Kyosuke MOROHASHI
 
Page compression. PGCON_2016
Anastasia Lubennikova
 
Open Source Backup Conference 2014: Workshop bareos introduction, by Philipp ...
NETWAYS
 
Масштабируемая конфигурация Nginx, Игорь Сысоев (Nginx)
Ontico
 
HTTP 완벽가이드- 13 다이제스트 인증
박 민규
 
It’s about time to embrace Streams
Luciano Mammino
 

Similar to REST Web Sebvice (20)

PPTX
Curl Tutorial
Ankireddy Polu
 
PDF
Consuming RESTful services in PHP
Zoran Jeremic
 
PDF
Consuming RESTful Web services in PHP
Zoran Jeremic
 
PPTX
Kubered -Recipes for C2 Operations on Kubernetes
Jeffrey Holden
 
PPTX
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Puppet
 
PPTX
Building Portable Applications with Kubernetes
Kublr
 
PDF
Hands on with CoAP and Californium
Julien Vermillard
 
PDF
Conf2015 d waddle_defense_pointsecurity_deploying_splunksslbestpractices
BrentMatlock
 
PPTX
Hacking Oracle From Web Apps 1 9
sumsid1234
 
PDF
Bootstrapping multidc observability stack
Bram Vogelaar
 
PDF
us-17-Tsai-A-New-Era-Of-SSRF-Exploiting-URL-Parser-In-Trending-Programming-La...
sonjeku1
 
PDF
Docker tlv
Ariel Moskovich
 
PPTX
How to create a multi tenancy for an interactive data analysis
Tiago Simões
 
PDF
mastering libcurl part 1
Daniel Stenberg
 
PDF
Infrastructure as Code with Terraform
Pedro J. Molina
 
PDF
NSManchester - Restofire - 10 Feb
RahulKatariya14
 
PDF
Nginx - The webserver you might actually like
Edorian
 
PPTX
Construindo APIs Usando Rails
Fernando Kakimoto
 
PDF
Web services tutorial
Lorna Mitchell
 
PPTX
Apache Solr
Minh Tran
 
Curl Tutorial
Ankireddy Polu
 
Consuming RESTful services in PHP
Zoran Jeremic
 
Consuming RESTful Web services in PHP
Zoran Jeremic
 
Kubered -Recipes for C2 Operations on Kubernetes
Jeffrey Holden
 
Fully Automate Application Delivery with Puppet and F5 - PuppetConf 2014
Puppet
 
Building Portable Applications with Kubernetes
Kublr
 
Hands on with CoAP and Californium
Julien Vermillard
 
Conf2015 d waddle_defense_pointsecurity_deploying_splunksslbestpractices
BrentMatlock
 
Hacking Oracle From Web Apps 1 9
sumsid1234
 
Bootstrapping multidc observability stack
Bram Vogelaar
 
us-17-Tsai-A-New-Era-Of-SSRF-Exploiting-URL-Parser-In-Trending-Programming-La...
sonjeku1
 
Docker tlv
Ariel Moskovich
 
How to create a multi tenancy for an interactive data analysis
Tiago Simões
 
mastering libcurl part 1
Daniel Stenberg
 
Infrastructure as Code with Terraform
Pedro J. Molina
 
NSManchester - Restofire - 10 Feb
RahulKatariya14
 
Nginx - The webserver you might actually like
Edorian
 
Construindo APIs Usando Rails
Fernando Kakimoto
 
Web services tutorial
Lorna Mitchell
 
Apache Solr
Minh Tran
 
Ad

REST Web Sebvice

  • 1. Web Service: REST 原則與實作分享 簡報者:許登傑、林宗茂 更新日期: 2008-09-01
  • 2. 大綱 REST 打哪來 ? REST for rest ♨ Client 操作範例 Curl 指令運用 Server 開發思維 實作分享 (Resource Template) 現行限制 & 框架支援 (Framework) 參考文獻 & 相關資源
  • 3. REST 打哪來 ? # 1 SOA ≈ LEGO Web Service Implementation RPC 、 SOAP 、 REST Re presentational S tate T ransfer 2000, doctoral thesis of Roy Fielding Style of software architecture for distributed hypermedia systems R esource O riented A rchitecture W orld W ide W eb
  • 4. REST 打哪來 ? # 2 Client (Server) Request: GET https ://.../customers/1/orders Response: Content-type: XML https://.../orders/00131 https://.../orders/00832 https://.../orders/00759 Server db3n2u.sinica.edu.tw/~textdb/ap … /orders/ { id } POST / GET / PUT / DELETE /customers/ { id } POST / GET / PUT / DELETE /customers/ { id } /orders POST / GET / PUT / DELETE
  • 5. REST 打哪來 ? # 3 ROA : Four Concepts Resource resource Name Representation of a resource * code on demand Link to a related resource ROA : Four Properties Addressability Uniform interface * (# 4) well-defined operations, CRUD Statelessness Connectedness
  • 6. REST 打哪來 ? # 4 Verbs of HTTP Safe : no changes to any data on the server Idempotent : repeat without changing resource DELETE GET ○ X Delete ○ X Update create PUT ○ ○ Read X X Create update, delete POST Idempotent Safe CRUD Method
  • 7. REST for rest ♨ - Client 操作範例 REST-like on the web End user: www.flickr.com AP / Server: 殷周金文資料庫 : GIS 座標 how to be a Client curl / libcurl ( PHP/CURL ) * ex. db3x Other development… HTTP/FTP client libraries * open source C * libcurl c interface / bindings JAVA * Yahoo! Developer Network .NET (C#) * Yahoo! Developer Network
  • 8. REST for rest ♨ - curl 指令操作範例 GET curl -G -d <data> -d <data> (URL) POST curl --request POST -d <data> -d <data> (URL) PUT curl --request PUT -d <data> -d <data> (URL) DELETE curl --request DELETE -d <data> -d <data> (URL) *<data> : variable=value
  • 9. REST for rest ♨ - curl 指令其他常用參數 curl –help : 線上求助 -u <login:passwd> : Set user and password --silent : 不顯示 curl 回應訊息 --data-urlencode <name=data/name@filename> : HTTP GET data url encoded -1/--tlsv1 : Use TLSv1 (SSL) -2/--sslv2 : Use SSLv2 (SSL) -3/--sslv3 : Use SSLv3 (SSL) -k : SSL without certification
  • 10. REST for rest ♨ - 在 C 語言中執行 curl 若開發環境無法安裝 libcurl , 則直接執行 curl 指令代替 system(cmd); 指令執行成功回傳 0 、失敗回傳 -1 system(cmd > out.txt); 需取得回傳資料,可輸出為文件檔
  • 11. REST for rest ♨ - Server 開發思維 Uniform Interface
  • 12. 實作分享 # 1: DORE combined (Resource Template) header('Content-Type: application/vnd.google-earth.kml+xml; charset=utf-8'); echo $loader->run(); REQUEST https:// login:passwd@db1n... _login, _passwd RESPONSE $loader = new Loader(‘gismap'); $_roleList = '*'; $_webService0 = 2; require_once('../../dore/lib0.php'); $_sess->close(); <<interface>> REST restPost() restGet() restPut() restDelete() <<resource>> gismap err() usage() chkArgs() restPost() restGet() restPut() restDelete() <<handler>> Loader err() run() auth()
  • 13. 實作分享 # 2 (Resource Template) Key issues Authentication, Authorization HTTP basic authentication DORE Variable / Data security * chkArgs() Verbs reacting criteria Error handler * Yahoo! Developer Network 1 / 2
  • 14. 現行限制 & 框架支援 No Framework, No PUT / DELETE PHP-based Framework Zend IBM Project Zero * WebSphere sMash WSDL 2.0 support for all HTTP verbs Java, .Net SOAP frameworks Spring, Apache CXF, Apache Axis2
  • 15. 參考文獻 & 相關資源 http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm “ RESTful Web Services”; Leonard Richardson, Sam Ruby; (First Edition) May 2007 http:// www.wikipedia.org / http://curl.haxx.se/ http:// developer.yahoo.com/php /

Editor's Notes

  • #4: Service-oriented architecture , a computer systems architectural style for creating and using business processes, packaged as services . http://en.wikipedia.org/wiki/Service-oriented_architecture IT 資源 &gt;&gt; 服務 ( 設計層次高於 function, component, procedure) Web Service : Web APIs that can be accessed over a network, 可實現 xOA 的技術集合 http://en.wikipedia.org/wiki/Web_service RPC : distributed function (method) call interface. Mapping directly language-specific functions. SOAP : message, rather than an operation. REST : interacting with stateful resources. Roy Fielding , one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification. Style : (guideline) network architecture principles, outline how resources are defined and addressed. (Simple interface, Domain-specific data, Non-additional info) distributed hypermedia systems : such as the World Wide Web. ROA : 2007 book, RESTful Web Services. Every resource is a service. (Four concepts, four properties)
  • #5: https: TCP/IP model &gt; Application Layer &gt; HTTP
  • #6: Four concepts Resource : could be a physical resource, or even a person. Can be described by a representation. Name : URI for use in hypermedia links. Representation : HTTP header Content-type, describe the resource (XML / HTML / JSON / link). Link to : response to other resources. Four properties Addressability : set as URIs and allows clients to manipulate their state. Uniform interface : verbs reacting criteria (GET / PUT / POST / DELETE). Statelessness : server only keeps resource state; client keeps application state. Connectedness : have a set of links (URIs). REST principle &gt; protocol : client-server, stateless, cacheable, layered (intermediaries)
  • #15: WSDL: an XML -based language that provides a model for describing Web services .