SlideShare a Scribd company logo
1 of 29
RESTful Web Services




Grzegorz Borkowski




                       Confidential
RESTful Web Services
Agenda


 Introduction


 REST principles


 Designing RESTful API


 Miscellaneous


 Implementions and Frameworks


 Implementing RESTful API




         © Rule Financial 2011   2
RESTful Web Services
Agenda



 Introduction


REST principles


 Designing RESTful API


 Miscellaneous


 Implementions and Frameworks


 Implementing RESTful API




         © Rule Financial 2011   3
Introduction


Materials
 The most recommended reading:
   Materials - Richardson, Leonard; Ruby, Sam (2007-05), RESTful Web Services, O'Reilly
    (warning: code examples are written in Ruby!)




            © Rule Financial 2011                                                          4
Introduction


REST origins
 REST = Representational state transfer - a style of software architecture
 The term representational state transfer was introduced and defined in 2000 by Roy Fielding in his doctoral dissertation
 REST = applying HTTP principles to the software architecture
 RESTful = conforming to the REST priniciples. → RESTful Web Services


 Why has HTTP got so popular?
      Because of simplicity. Probably every programming language supports HTTP - because it’s easy!
      Compare to SOAP – SOAP is much more complicated.
      Internet. Internet is efficient, scalable, easy to use… we want our software to be like the Internet!


 SOAP – alternate approach to web services.
      To better understand REST, it's helpful to compare it to SOAP.
      REST is a simpler alternative to SOAP, a simpler way to build web services.
      Compare especially WSDL!




             © Rule Financial 2011                                                                                           5
Introduction


An HTTP GET request for http://www.oreilly.com/index.html
GET /index.html HTTP/1.1
Host: www.oreilly.com
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12)...
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,...
Accept-Language: us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-15,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive


The response to an HTTP GET request for http://www.oreilly.com/index.html
HTTP/1.1 200 OK
Date: Fri, 17 Nov 2006 15:36:32 GMT
Server: Apache
Last-Modified: Fri, 17 Nov 2006 09:05:32 GMT
Etag: "7359b7-a7fa-455d8264
Content-Length: 43302
Content-Type: text/html
Keep-Alive: timeout=15, max=1000
Connection: Keep-Alive

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>oreilly.com -- Welcome to O'Reilly Media, Inc.</title>
...




            © Rule Financial 2011                                            6
RESTful Web Services
Agenda


 Introduction


 REST principles


 Designing RESTful API


 Miscellaneous


 Implementions and Frameworks


 Implementing RESTful API




         © Rule Financial 2011   7
REST principles


REST keywords:
 Resources
 Addressability
 Statelessness
 Uniform API
 Representations
 Cacheability
 Connectedness and discoverability




              © Rule Financial 2011   8
REST principles


Resource
 Every data or abstraction which can be created/updated/retrieved/removed and somehow represented, and is addressable.
   Web page is a resource;
   but also a blog post,
   a comment,
   a cart,
   a cart item etc.




              © Rule Financial 2011                                                                                       9
REST principles


Addressability
 Why addressability is important?
      Bookmarking
      sending links
      resource-level authorization
 Compare FTP, JSF 1.x, most of poorly written Ajax applications, Flash-based applications – they are not addressable.
 URIs vs URLs vs URNs
      URI doesn't have to be URL. For example, XML namespace is an URI, but it's not an URL
      URLs that point to the same resource:
                            http://mylib.example.com/releases/1.1
                            http://mylib.example.com/releases/1.2
                            http://mylib.example.com/releases/latest  at this time, it can be the same as 1.2
      URIs of the single resources vs URIs of the resource lists/queries
                            http://mylib.example.com/releases/          list of all releases
                            http://mylib.example.com/releases/?majorVersion=1
                            http://mylib.example.com/releases/1.2



             © Rule Financial 2011                                                                                       10
REST principles


Addressability – cont.
Permanent URIs vs Readable URIs (vs Hybrid URIs)
“Clean URLs” - http://en.wikipedia.org/wiki/Clean_URLs - advantages:
   SEO
   user experience
   hide underlying technology (index.jsp, index.php, index.aspx)
   mod rewrite, UrlRewriteFilter


Note: percent-encoding
   URL-encoding – URI specification, closely related to HTTP (” ” -> ”%20”)
   Form encoding – part of HTML specification for submitting forms (” ” -> ”+”)
        as a query string (part of URL!) in GET requests, as a body in POST requests




             © Rule Financial 2011                                                     11
REST principles


Statelessness
 Every request is independent of previous one
 No server-side sessions, conversation state is kept on the client side only
 Advantages:
        Simplicity
        Scalability
        Addressability
 Application (conversation) state vs resource state
      Resource state is the same for all clients/applications
      Application (conversation) state is client-specific




              © Rule Financial 2011                                             12
REST principles


Uniform API
  Uniform operations: CRUD
      POST  Create
      GET  Read (retrieve single resource, or query to get list of matches)
      PUT  Update (or Create)
      DELETE  Delete
  SOAP is more like Java/.NET/etc – no uniform API. REST is more like SQL – uniform API (insert, select, update, delete).
  Special meaning of POST („Overloaded POST”)  trigger some algorithm/procedure/operation
  note: PUT/DELETE over POST (for example for HTML 4.x forms)


  Safe and indempotent operations
      Take care to keep PUT indempotent (eg. Don't increment value in PUT)
      Safe – e.g. safe for webcrawlers.
      Safe and indempotent calls are great for unreliable networks – if request times out, just resend it.
      Why it's important – example of Google Accelerator (2005)




            © Rule Financial 2011                                                                                            13
REST principles


Uniform API
  Uniform response codes
      1xx - info
      2xx - ok
      3xx - redirect
      4xx – client error
      5xx – server error
  Uniform headers, e.g.:
      Accept-Encoding: gzip,deflate
      Last-Modified: Fri, 17 Nov 2006 09:05:32 GMT
      Content-Type: text/plain
      (but you are not limited to the standard headers, you can use your own ones)


  Compare to RPC




           © Rule Financial 2011                                                     14
REST principles


Representations
  The same resource, but different representations - content types:
      HTML, XHTML
      XML
      JSON
      Form-encoded (application/x-www-form-urlencoded)
      binary (PDF, JPG,...)
      Base64
      Plaintext
  Content negotiation
      using headers
      or the representation specified in the URI (…/projects/12.xml - …/projects/12.json)
  Short/medium/long representation, e.g.:
   – Users list for dropdowns, only id and label – short representation
   – Users list with details – medium representation
   – Users list with related projects, tasks, absences etc. - long representation



             © Rule Financial 2011                                                          15
REST principles


Cacheability
 All HTTP clients are allowed to cache resources
 Caching controlled by standard headers (Uniform API!)
  – HTTP 1.0: Expires, Last-Modified, If-Modified-Since
  – HTTP 1.1: Cache-Control, Etag, If-None-Matches
 Cache forever and never ask again – great value for versioned resources
 Cache and ask whether it has changed (Conditional GET)
 IE problems for Ajax requests – broken caching, use the random element in URL



Connectedness
 Navigation from one resource to related resources by links
 Discoverability




             © Rule Financial 2011                                                16
RESTful Web Services
Agenda


 Introduction


 REST principles


Designing RESTful API


 Miscellaneous


 Implementions and Frameworks


 Implementing RESTful API




         © Rule Financial 2011   17
Designing RESTful API
RESTful web service example


Simple RESTful web service Amazon S3 (Simple Storage Service)
 A service for reliable storage of objects (files)
 Two types of resources
         –   Buckets
         –   Objects
 API:

                                   GET                         HEAD                        PUT                      DELETE

 The bucket list                   List your buckets           -                           -                        -
 /
 A bucket                          List the bucket’s objects   -                           Create the bucket        Delete the bucket
 /{bucket}
 An object                         Get the object’s value      Get the object’s metadata   Set the object’s value   Delete the object
 /{bucket}/{object}                and metadata                                            and metadata




               © Rule Financial 2011                                                                                                    18
Designing RESTful API


Designing the read-only API
 Design resources
 Design representations served by the service
 Specify supported methods
 Specify caching




             © Rule Financial 2011               19
Designing RESTful API
Exercise


Design the read-only market data information service for traders
 Service should deliver information about:
   Exchanges (name, location, public holidays, …)
   Indices (name, current value, past values)
   Stocks (name, fundamental data, current price, past prices)
   Derivatives
   Fx pairs




 Design
   Resources
   Their addresses
   Supported methods
   Representations




               © Rule Financial 2011                               20
Designing RESTful API


Designing the read-write API
 Design resources
 Design representations served by the service
 Design accepted incoming representations
 Specify supported methods
 Specify caching
 Security
            Authentication (preferred stateless: keep authentication state on the client side, reauthenticate on each request)
            Authorization
 Error handling

Note: Basic authentication
 Server returns code and header:
  401 Authorization Required
  WWW-Authenticate: Basic realm=„Realm name"
 Client sends (with each request) header:
  Authorization: Basic Base64Encoded(username:password)




               © Rule Financial 2011                                                                                              21
RESTful Web Services
Agenda


 Introduction


 REST principles


 Designing RESTful API


Miscellaneous


 Implementions and Frameworks


 Implementing RESTful API




         © Rule Financial 2011   22
Miscellaneous


Versioning
Versioning
   Versioning of resources – e.g. http://myservice.example.com/rest/customers/11235.4
   Versioning of API – e.g. http://myservice.example.com/rest/v1/customers/




              © Rule Financial 2011                                                      23
Miscellaneous


HTTP – additional capabilities
Compression
   Accept-Encoding: gzip,deflate


Async requests
   Response code: 202 Accepted
   „jobs”


Conditional PUT
   Expect reponse code: 100 Continue




             © Rule Financial 2011      24
RESTful Web Services
Agenda


 Introduction


 REST principles


 Designing RESTful API


 Miscellaneous


Implementions and Frameworks


 Implementing RESTful API




         © Rule Financial 2011   25
Implementions and Frameworks


Client side requirements
Support for SSL/TLS
Support PUT, DELETE, HEAD, not only GET and POST
Support manipulation of request headers
Access to response headers and status code
Support proxies
Support compression
Support caching
Support authentication mechanisms (basic, digest, wsse, o-auth)
Support redirects (3xx)


Java examples
java.net. HttpURLConnection
Apache HttpClient
Restlet Client




              © Rule Financial 2011                                26
Implementions and Frameworks


Server side requirements - all as client side, plus boiler-plate code reducing features
URI Templates with data conversion and binding: /project/{projectName}/tasks/{taskId}
content-negotiation
PUT/DELETE over POST
Body parsing, conversion and binding (plain, form-encoded, json, xml)
data validation


Java examples
JAX-RS
Restlet
Spring MVC




              © Rule Financial 2011                                                       27
RESTful Web Services
Agenda


 Introduction


 REST principles


 Designing RESTful API


 Miscellaneous


 Implementions and Frameworks


 Implementing RESTful API




         © Rule Financial 2011   28
It’s time to code something!




                               Confidential

More Related Content

What's hot

Seda与Java并行编程点滴
Seda与Java并行编程点滴Seda与Java并行编程点滴
Seda与Java并行编程点滴Benjamin Tan
 
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...Edward Burns
 
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...J V
 
Essential Camel Components
Essential Camel ComponentsEssential Camel Components
Essential Camel ComponentsChristian Posta
 
Keynote Oracle Fusion Middleware Summit_2020
Keynote Oracle Fusion Middleware Summit_2020Keynote Oracle Fusion Middleware Summit_2020
Keynote Oracle Fusion Middleware Summit_2020Michel Schildmeijer
 
Simple web service vm
Simple web service vmSimple web service vm
Simple web service vmMohammed246
 
Introduction to Apache CloudStack by David Nalley
Introduction to Apache CloudStack by David NalleyIntroduction to Apache CloudStack by David Nalley
Introduction to Apache CloudStack by David Nalleybuildacloud
 
Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Lucas Jellema
 
Oracle SOA suite and Coherence dehydration
Oracle SOA suite and  Coherence dehydrationOracle SOA suite and  Coherence dehydration
Oracle SOA suite and Coherence dehydrationMichel Schildmeijer
 
Zarafa SummerCamp 2012 - Exchange Web Services, technical information
Zarafa SummerCamp 2012 - Exchange Web Services, technical informationZarafa SummerCamp 2012 - Exchange Web Services, technical information
Zarafa SummerCamp 2012 - Exchange Web Services, technical informationZarafa
 
Zarafa SummerCamp 2012 - Steve Hardy Friday Keynote
Zarafa SummerCamp 2012 - Steve Hardy Friday KeynoteZarafa SummerCamp 2012 - Steve Hardy Friday Keynote
Zarafa SummerCamp 2012 - Steve Hardy Friday KeynoteZarafa
 
A Tale of 2 Systems
A Tale of 2 SystemsA Tale of 2 Systems
A Tale of 2 SystemsDavid Newman
 
Scalability Availabilty and Management of WSO2 Carbon
Scalability Availabilty and Management of WSO2 CarbonScalability Availabilty and Management of WSO2 Carbon
Scalability Availabilty and Management of WSO2 CarbonWSO2
 
Integrating Microservices with Apache Camel
Integrating Microservices with Apache CamelIntegrating Microservices with Apache Camel
Integrating Microservices with Apache CamelChristian Posta
 
Developing and Hosting SOAP Based Services
Developing and Hosting SOAP Based ServicesDeveloping and Hosting SOAP Based Services
Developing and Hosting SOAP Based ServicesStephenKardian
 
Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)Lucas Jellema
 
Scale your Alfresco Solutions
Scale your Alfresco Solutions Scale your Alfresco Solutions
Scale your Alfresco Solutions Alfresco Software
 
Kafka Summit SF 2017 - Kafka Connect Best Practices – Advice from the Field
Kafka Summit SF 2017 - Kafka Connect Best Practices – Advice from the FieldKafka Summit SF 2017 - Kafka Connect Best Practices – Advice from the Field
Kafka Summit SF 2017 - Kafka Connect Best Practices – Advice from the Fieldconfluent
 

What's hot (20)

Seda与Java并行编程点滴
Seda与Java并行编程点滴Seda与Java并行编程点滴
Seda与Java并行编程点滴
 
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
HTTP/2 Comes to Java: Servlet 4.0 and what it means for the Java/Jakarta EE e...
 
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
Deep Dive: Alfresco Core Repository (... embedded in a micro-services style a...
 
Essential Camel Components
Essential Camel ComponentsEssential Camel Components
Essential Camel Components
 
Keynote Oracle Fusion Middleware Summit_2020
Keynote Oracle Fusion Middleware Summit_2020Keynote Oracle Fusion Middleware Summit_2020
Keynote Oracle Fusion Middleware Summit_2020
 
Fabric8 mq
Fabric8 mqFabric8 mq
Fabric8 mq
 
Simple web service vm
Simple web service vmSimple web service vm
Simple web service vm
 
Introduction to Apache CloudStack by David Nalley
Introduction to Apache CloudStack by David NalleyIntroduction to Apache CloudStack by David Nalley
Introduction to Apache CloudStack by David Nalley
 
Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)Introduction to Node (15th May 2017)
Introduction to Node (15th May 2017)
 
Oracle SOA suite and Coherence dehydration
Oracle SOA suite and  Coherence dehydrationOracle SOA suite and  Coherence dehydration
Oracle SOA suite and Coherence dehydration
 
Zarafa SummerCamp 2012 - Exchange Web Services, technical information
Zarafa SummerCamp 2012 - Exchange Web Services, technical informationZarafa SummerCamp 2012 - Exchange Web Services, technical information
Zarafa SummerCamp 2012 - Exchange Web Services, technical information
 
Zarafa SummerCamp 2012 - Steve Hardy Friday Keynote
Zarafa SummerCamp 2012 - Steve Hardy Friday KeynoteZarafa SummerCamp 2012 - Steve Hardy Friday Keynote
Zarafa SummerCamp 2012 - Steve Hardy Friday Keynote
 
A Tale of 2 Systems
A Tale of 2 SystemsA Tale of 2 Systems
A Tale of 2 Systems
 
Scalability Availabilty and Management of WSO2 Carbon
Scalability Availabilty and Management of WSO2 CarbonScalability Availabilty and Management of WSO2 Carbon
Scalability Availabilty and Management of WSO2 Carbon
 
Jakarta EE 8 on JDK17
Jakarta EE 8 on JDK17Jakarta EE 8 on JDK17
Jakarta EE 8 on JDK17
 
Integrating Microservices with Apache Camel
Integrating Microservices with Apache CamelIntegrating Microservices with Apache Camel
Integrating Microservices with Apache Camel
 
Developing and Hosting SOAP Based Services
Developing and Hosting SOAP Based ServicesDeveloping and Hosting SOAP Based Services
Developing and Hosting SOAP Based Services
 
Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)Introducing Node.js in an Oracle technology environment (including hands-on)
Introducing Node.js in an Oracle technology environment (including hands-on)
 
Scale your Alfresco Solutions
Scale your Alfresco Solutions Scale your Alfresco Solutions
Scale your Alfresco Solutions
 
Kafka Summit SF 2017 - Kafka Connect Best Practices – Advice from the Field
Kafka Summit SF 2017 - Kafka Connect Best Practices – Advice from the FieldKafka Summit SF 2017 - Kafka Connect Best Practices – Advice from the Field
Kafka Summit SF 2017 - Kafka Connect Best Practices – Advice from the Field
 

Similar to Restful web services rule financial

Restful web-services
Restful web-servicesRestful web-services
Restful web-servicesrporwal
 
Paul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA RegistryPaul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA Registrydeimos
 
Understanding and Using Rest APIs (SocialDevCamp Chicago 2009)
Understanding and Using Rest APIs (SocialDevCamp Chicago 2009)Understanding and Using Rest APIs (SocialDevCamp Chicago 2009)
Understanding and Using Rest APIs (SocialDevCamp Chicago 2009)Pete Morano
 
WSO2 ESB Integration with REST
WSO2 ESB Integration with RESTWSO2 ESB Integration with REST
WSO2 ESB Integration with RESTWSO2
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developersPatrick Savalle
 
Designing RESTful APIs
Designing RESTful APIsDesigning RESTful APIs
Designing RESTful APIsanandology
 
KaTe RESTful adapter for SAP Process Integration: Introduction
KaTe RESTful adapter for SAP Process Integration: IntroductionKaTe RESTful adapter for SAP Process Integration: Introduction
KaTe RESTful adapter for SAP Process Integration: IntroductionKate_RESTful
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
 
LAJUG Napster REST API
LAJUG Napster REST APILAJUG Napster REST API
LAJUG Napster REST APIstephenbhadran
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni InturiSreeni I
 
RestFul Web Services In Drupal 8
RestFul Web Services In Drupal 8RestFul Web Services In Drupal 8
RestFul Web Services In Drupal 8Gajendra Sharma
 
Creating Restful Web Services with restish
Creating Restful Web Services with restishCreating Restful Web Services with restish
Creating Restful Web Services with restishGrig Gheorghiu
 

Similar to Restful web services rule financial (20)

Restful web-services
Restful web-servicesRestful web-services
Restful web-services
 
Paul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA RegistryPaul Fremantle Restful SOA Registry
Paul Fremantle Restful SOA Registry
 
Understanding and Using Rest APIs (SocialDevCamp Chicago 2009)
Understanding and Using Rest APIs (SocialDevCamp Chicago 2009)Understanding and Using Rest APIs (SocialDevCamp Chicago 2009)
Understanding and Using Rest APIs (SocialDevCamp Chicago 2009)
 
Unerstanding and Using RESTful APIs
Unerstanding and Using RESTful APIsUnerstanding and Using RESTful APIs
Unerstanding and Using RESTful APIs
 
Rest with Spring
Rest with SpringRest with Spring
Rest with Spring
 
WSO2 ESB Integration with REST
WSO2 ESB Integration with RESTWSO2 ESB Integration with REST
WSO2 ESB Integration with REST
 
REST-API introduction for developers
REST-API introduction for developersREST-API introduction for developers
REST-API introduction for developers
 
Soap and Rest
Soap and RestSoap and Rest
Soap and Rest
 
Designing RESTful APIs
Designing RESTful APIsDesigning RESTful APIs
Designing RESTful APIs
 
KaTe RESTful adapter for SAP Process Integration: Introduction
KaTe RESTful adapter for SAP Process Integration: IntroductionKaTe RESTful adapter for SAP Process Integration: Introduction
KaTe RESTful adapter for SAP Process Integration: Introduction
 
ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
eZ Publish REST API v2
eZ Publish REST API v2eZ Publish REST API v2
eZ Publish REST API v2
 
E zsc2012 rest-api-v2
E zsc2012 rest-api-v2E zsc2012 rest-api-v2
E zsc2012 rest-api-v2
 
LAJUG Napster REST API
LAJUG Napster REST APILAJUG Napster REST API
LAJUG Napster REST API
 
Restful web services by Sreeni Inturi
Restful web services by Sreeni InturiRestful web services by Sreeni Inturi
Restful web services by Sreeni Inturi
 
Rest web service
Rest web serviceRest web service
Rest web service
 
RestFul Web Services In Drupal 8
RestFul Web Services In Drupal 8RestFul Web Services In Drupal 8
RestFul Web Services In Drupal 8
 
RESTful Web Services
RESTful Web ServicesRESTful Web Services
RESTful Web Services
 
Creating Restful Web Services with restish
Creating Restful Web Services with restishCreating Restful Web Services with restish
Creating Restful Web Services with restish
 
Salesforce REST API
Salesforce  REST API Salesforce  REST API
Salesforce REST API
 

Recently uploaded

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 

Recently uploaded (20)

"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 

Restful web services rule financial

  • 1. RESTful Web Services Grzegorz Borkowski Confidential
  • 2. RESTful Web Services Agenda Introduction REST principles Designing RESTful API Miscellaneous Implementions and Frameworks Implementing RESTful API © Rule Financial 2011 2
  • 3. RESTful Web Services Agenda Introduction REST principles Designing RESTful API Miscellaneous Implementions and Frameworks Implementing RESTful API © Rule Financial 2011 3
  • 4. Introduction Materials  The most recommended reading:  Materials - Richardson, Leonard; Ruby, Sam (2007-05), RESTful Web Services, O'Reilly (warning: code examples are written in Ruby!) © Rule Financial 2011 4
  • 5. Introduction REST origins  REST = Representational state transfer - a style of software architecture  The term representational state transfer was introduced and defined in 2000 by Roy Fielding in his doctoral dissertation  REST = applying HTTP principles to the software architecture  RESTful = conforming to the REST priniciples. → RESTful Web Services  Why has HTTP got so popular?  Because of simplicity. Probably every programming language supports HTTP - because it’s easy!  Compare to SOAP – SOAP is much more complicated.  Internet. Internet is efficient, scalable, easy to use… we want our software to be like the Internet!  SOAP – alternate approach to web services.  To better understand REST, it's helpful to compare it to SOAP.  REST is a simpler alternative to SOAP, a simpler way to build web services.  Compare especially WSDL! © Rule Financial 2011 5
  • 6. Introduction An HTTP GET request for http://www.oreilly.com/index.html GET /index.html HTTP/1.1 Host: www.oreilly.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12)... Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,... Accept-Language: us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-15,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive The response to an HTTP GET request for http://www.oreilly.com/index.html HTTP/1.1 200 OK Date: Fri, 17 Nov 2006 15:36:32 GMT Server: Apache Last-Modified: Fri, 17 Nov 2006 09:05:32 GMT Etag: "7359b7-a7fa-455d8264 Content-Length: 43302 Content-Type: text/html Keep-Alive: timeout=15, max=1000 Connection: Keep-Alive <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title>oreilly.com -- Welcome to O'Reilly Media, Inc.</title> ... © Rule Financial 2011 6
  • 7. RESTful Web Services Agenda Introduction REST principles Designing RESTful API Miscellaneous Implementions and Frameworks Implementing RESTful API © Rule Financial 2011 7
  • 8. REST principles REST keywords:  Resources  Addressability  Statelessness  Uniform API  Representations  Cacheability  Connectedness and discoverability © Rule Financial 2011 8
  • 9. REST principles Resource  Every data or abstraction which can be created/updated/retrieved/removed and somehow represented, and is addressable.  Web page is a resource;  but also a blog post,  a comment,  a cart,  a cart item etc. © Rule Financial 2011 9
  • 10. REST principles Addressability  Why addressability is important?  Bookmarking  sending links  resource-level authorization  Compare FTP, JSF 1.x, most of poorly written Ajax applications, Flash-based applications – they are not addressable.  URIs vs URLs vs URNs  URI doesn't have to be URL. For example, XML namespace is an URI, but it's not an URL  URLs that point to the same resource: http://mylib.example.com/releases/1.1 http://mylib.example.com/releases/1.2 http://mylib.example.com/releases/latest  at this time, it can be the same as 1.2  URIs of the single resources vs URIs of the resource lists/queries http://mylib.example.com/releases/  list of all releases http://mylib.example.com/releases/?majorVersion=1 http://mylib.example.com/releases/1.2 © Rule Financial 2011 10
  • 11. REST principles Addressability – cont. Permanent URIs vs Readable URIs (vs Hybrid URIs) “Clean URLs” - http://en.wikipedia.org/wiki/Clean_URLs - advantages:  SEO  user experience  hide underlying technology (index.jsp, index.php, index.aspx)  mod rewrite, UrlRewriteFilter Note: percent-encoding  URL-encoding – URI specification, closely related to HTTP (” ” -> ”%20”)  Form encoding – part of HTML specification for submitting forms (” ” -> ”+”) as a query string (part of URL!) in GET requests, as a body in POST requests © Rule Financial 2011 11
  • 12. REST principles Statelessness  Every request is independent of previous one  No server-side sessions, conversation state is kept on the client side only  Advantages: Simplicity Scalability Addressability  Application (conversation) state vs resource state  Resource state is the same for all clients/applications  Application (conversation) state is client-specific © Rule Financial 2011 12
  • 13. REST principles Uniform API  Uniform operations: CRUD POST  Create GET  Read (retrieve single resource, or query to get list of matches) PUT  Update (or Create) DELETE  Delete  SOAP is more like Java/.NET/etc – no uniform API. REST is more like SQL – uniform API (insert, select, update, delete).  Special meaning of POST („Overloaded POST”)  trigger some algorithm/procedure/operation  note: PUT/DELETE over POST (for example for HTML 4.x forms)  Safe and indempotent operations Take care to keep PUT indempotent (eg. Don't increment value in PUT) Safe – e.g. safe for webcrawlers. Safe and indempotent calls are great for unreliable networks – if request times out, just resend it. Why it's important – example of Google Accelerator (2005) © Rule Financial 2011 13
  • 14. REST principles Uniform API  Uniform response codes 1xx - info 2xx - ok 3xx - redirect 4xx – client error 5xx – server error  Uniform headers, e.g.: Accept-Encoding: gzip,deflate Last-Modified: Fri, 17 Nov 2006 09:05:32 GMT Content-Type: text/plain (but you are not limited to the standard headers, you can use your own ones)  Compare to RPC © Rule Financial 2011 14
  • 15. REST principles Representations  The same resource, but different representations - content types: HTML, XHTML XML JSON Form-encoded (application/x-www-form-urlencoded) binary (PDF, JPG,...) Base64 Plaintext  Content negotiation using headers or the representation specified in the URI (…/projects/12.xml - …/projects/12.json)  Short/medium/long representation, e.g.: – Users list for dropdowns, only id and label – short representation – Users list with details – medium representation – Users list with related projects, tasks, absences etc. - long representation © Rule Financial 2011 15
  • 16. REST principles Cacheability  All HTTP clients are allowed to cache resources  Caching controlled by standard headers (Uniform API!) – HTTP 1.0: Expires, Last-Modified, If-Modified-Since – HTTP 1.1: Cache-Control, Etag, If-None-Matches  Cache forever and never ask again – great value for versioned resources  Cache and ask whether it has changed (Conditional GET)  IE problems for Ajax requests – broken caching, use the random element in URL Connectedness  Navigation from one resource to related resources by links  Discoverability © Rule Financial 2011 16
  • 17. RESTful Web Services Agenda Introduction REST principles Designing RESTful API Miscellaneous Implementions and Frameworks Implementing RESTful API © Rule Financial 2011 17
  • 18. Designing RESTful API RESTful web service example Simple RESTful web service Amazon S3 (Simple Storage Service)  A service for reliable storage of objects (files)  Two types of resources – Buckets – Objects  API: GET HEAD PUT DELETE The bucket list List your buckets - - - / A bucket List the bucket’s objects - Create the bucket Delete the bucket /{bucket} An object Get the object’s value Get the object’s metadata Set the object’s value Delete the object /{bucket}/{object} and metadata and metadata © Rule Financial 2011 18
  • 19. Designing RESTful API Designing the read-only API  Design resources  Design representations served by the service  Specify supported methods  Specify caching © Rule Financial 2011 19
  • 20. Designing RESTful API Exercise Design the read-only market data information service for traders  Service should deliver information about:  Exchanges (name, location, public holidays, …)  Indices (name, current value, past values)  Stocks (name, fundamental data, current price, past prices)  Derivatives  Fx pairs  Design  Resources  Their addresses  Supported methods  Representations © Rule Financial 2011 20
  • 21. Designing RESTful API Designing the read-write API  Design resources  Design representations served by the service  Design accepted incoming representations  Specify supported methods  Specify caching  Security  Authentication (preferred stateless: keep authentication state on the client side, reauthenticate on each request)  Authorization  Error handling Note: Basic authentication  Server returns code and header: 401 Authorization Required WWW-Authenticate: Basic realm=„Realm name"  Client sends (with each request) header: Authorization: Basic Base64Encoded(username:password) © Rule Financial 2011 21
  • 22. RESTful Web Services Agenda Introduction REST principles Designing RESTful API Miscellaneous Implementions and Frameworks Implementing RESTful API © Rule Financial 2011 22
  • 23. Miscellaneous Versioning Versioning  Versioning of resources – e.g. http://myservice.example.com/rest/customers/11235.4  Versioning of API – e.g. http://myservice.example.com/rest/v1/customers/ © Rule Financial 2011 23
  • 24. Miscellaneous HTTP – additional capabilities Compression  Accept-Encoding: gzip,deflate Async requests  Response code: 202 Accepted  „jobs” Conditional PUT  Expect reponse code: 100 Continue © Rule Financial 2011 24
  • 25. RESTful Web Services Agenda Introduction REST principles Designing RESTful API Miscellaneous Implementions and Frameworks Implementing RESTful API © Rule Financial 2011 25
  • 26. Implementions and Frameworks Client side requirements Support for SSL/TLS Support PUT, DELETE, HEAD, not only GET and POST Support manipulation of request headers Access to response headers and status code Support proxies Support compression Support caching Support authentication mechanisms (basic, digest, wsse, o-auth) Support redirects (3xx) Java examples java.net. HttpURLConnection Apache HttpClient Restlet Client © Rule Financial 2011 26
  • 27. Implementions and Frameworks Server side requirements - all as client side, plus boiler-plate code reducing features URI Templates with data conversion and binding: /project/{projectName}/tasks/{taskId} content-negotiation PUT/DELETE over POST Body parsing, conversion and binding (plain, form-encoded, json, xml) data validation Java examples JAX-RS Restlet Spring MVC © Rule Financial 2011 27
  • 28. RESTful Web Services Agenda Introduction REST principles Designing RESTful API Miscellaneous Implementions and Frameworks Implementing RESTful API © Rule Financial 2011 28
  • 29. It’s time to code something! Confidential