Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Mini-Training: Let's have a rest


Published on

A quick overview on REST : what it is and what it is not. REST has strict contraints and many internet Apis are not so REST. It’s also very popular today because RESTfull services can be consumed easily by any client or device. Soap is also still valid in a few circomstaces. It has never been so easy to create Rest-like services in .net since Web Api.

Published in: Technology
  • Be the first to comment

Mini-Training: Let's have a rest

  1. 1. LET’S HAVE A REST ! MAXIME LEMAITRE - 11/04/2013 Private and Confidential
  2. 2. Agenda • • • • • • • Introduction What it is not, what it is REST constraints In the web Industry SOAP Vs REST REST-style Service in .NET Conclusion
  3. 3. REST a vastly misunderstood term • REpresentational State Transfer is not a – Philosophy essay – Language – Protocol – Standard, RFC – Framework of MS, Google, Facebook, … – Technology –…
  4. 4. REST what REST is • Introduced in 2000 by Roy Fielding – principal author of HTTP and creator of Apache Web Server • REST is an architecture style – a coordinated set of architectural constraints that restricts the roles and features of architectural elements, and the allowed relationships between those elements • Client–server • Stateless • Cacheable • Layered system • Uniform interface • Code on demand (optional) Conforming to these constraints is referred to as being RESTful
  5. 5. REST Constraints Client – Server Stateless “No restrictions on the nature of the client, on the number of the clients and on communication medium / protocol” “... each request from client to server must contain all of the information necessary to understand the request, and cannot take advantage of any stored context on the server, independent of any requests that may have preceded it » • • • • Separate data storage concerns Improve user interface portability across multiple platforms Improve scalability by simplifying server components Components evolve independently • • • • Session state is kept on client Improved visibility because every exchange is self descriptive Easier recoverability from partial failures Improved scalability on server
  6. 6. REST Constraints Cacheability “... the data within a response to a request must be implicitly or explicitly labeled as cacheable or non-cacheable. If a response is cacheable, then a client cache is given the right to reuse that response data for later, equivalent requests.” • • Reduces client to server interactions Improves efficiency, scalability and user perceived performance Layered System “The layered system style or also popularly referred to as n-layer system allows an architecture to be composed of hierarchical layers by constraining component behavior such that each component cannot "see" beyond the immediate layer with which they are interacting.”
  7. 7. REST Constraint : Uniform Interface Information is transferred in a standardized form • Considered fundamental to the design of any REST app Identification of resources Each resource has a URI and is access through a defined set of HTTP methods (GET, PUT, POST, DELETE) • Manipulation of resources through representations Each resource can have one or more representations. Such as application/xml, application/json, text/html, etc. Clients and servers negotiate to select representation. • Self-descriptive messages Requests and responses contain not only data but additional headers describing how the content should be handled. Such as if it should be cached, authentication requirements, etc. • Hypermedia as the engine of application state (aka HATEOAS) Clients make state transitions only through actions that are dynamically identified within hypermedia by the server (e.g., by hyperlinks within hypertext). Except for simple fixed entry points to the application, a client does not assume that any particular action is available for any particular resources beyond those described in representations previously received from the server.
  8. 8. REST big brother What is the biggest known RESTful System on planet Earth? World Wide Web
  9. 9. RESTful Web Service REST for the web • A RESTful web API (also called a RESTful web service) is a web API implemented using HTTP and the principles of REST – – – – – • • URI (Clean ?) Internet media types HTTP Headers HTTP Response Codes HTTP Methods • GET • POST • PUT • DELETE … RESTful Web Service uses the existing features of the HTTP protocol. Layered proxy and gateway components perform additional functions on the network, such as HTTP caching and security enforcement.
  10. 10. REST in the web industry • Definition of REST lost its way when popular services emerged calling themselves REST which were not – Having an HTTP server accept GET requests or POST and responding with XML, JSON or some other data format is not automatically RESTful • Not so many RESTful services, but many REST-like services and web Api ( loose adherence) – Client scripts – Exposed Operations
  11. 11. REST what makes REST-style web services so popular today ? • Because it’s based on the same constraints that make the Web successful – Web was not designed as an Xml Bus with RPC • Since it uses standard HTTP features, it is much more simpler, easier, faster and scalable than any other web technology • REST-styles permits many different data formats (json, xml, …) • REST-styles web services can be consumed easily by any client or device – Do you know a better way to touch desktop browsers, mobile, tablets for any OS or technology ?
  12. 12. REST vs SOAP SOAP web service REST-style web service Support multiple transport protocols (HTTP, TCP, UDP, and HTTP only and more suitable for access from various custom transports) browsers, mobile devices etc enabling wide reach. Enables building services that support multiple encodings (Text, MTOM, and Binary) of the same message type and allows switching between them. Enables building Web APIs that support wide variety of media types including XML, JSON etc. Supports building services with WS-* standards like Reliable Messaging, Transactions, Message Security. Uses basic protocol and formats such as HTTP, WebSockets, SSL, JQuery, JSON, and XML. There is no support for higher level protocols such as Reliable Messaging or Transactions. Supports Request-Reply, One Way, and Duplex message exchange patterns. HTTP is request/response but additional patterns can be supported through SignalRand WebSockets integration. WCF SOAP services can be described in WSDL allowing automated tools to generate client proxies even for services with complex schemas. There is a variety of ways to describe a Web API ranging from auto-generated HTML help page describing snippets to structured metadata for OData integrated APIs.
  13. 13. REST How to build a REST-style Service in .NET ? • Using WCF (deprecated) – Using WebHttpBinding & WebHttpBehavior • Using Web Api – – – – – – – – – – – Not part of .NET, open-source as MVC Strong Support URL Routing to produce clean URLs using familiar MVC style semantics Content Negotiation based on Accept headers for request and response serialization Support for a host of supported output formats including JSON, XML, ATOM Strong default support for REST semantics but they are optional Easily extensible Formatter support to add new input/output types Convention based design that drives you into doing the right thing for HTTP Services Very extensible, based on MVC like extensibility model of Formatters and Filters Self-hostable in non-Web applications Testable using testing concepts similar to MVC …
  14. 14. REST How to build a REST-style Service in .NET ? /api/products/2
  15. 15. Conclusion • REST is a vastly misunderstood term • REST-styles web services are very popular today because they are simple, easy to use, performant , scalable and can be consumed by any client • REST-style Vs SOAP ? Both the REST-style and SOAP have advantages and disadvantages when it comes to building services. It’s more related to an architectural Decision. to rest ...
  16. 16. Appendices • • • • • • • pell.pdf
  17. 17. Find out more • On
  18. 18. About Betclic • • • Betclic Everest Group, one of the world leaders in online gaming, has a unique portfolio comprising various complementary international brands: Betclic, Everest Gaming,, Expekt… Active in 100 countries with more than 12 million customers worldwide, the Group is committed to promoting secure and responsible gaming and is a member of several international professional associations including the EGBA (European Gaming and Betting Association) and the ESSA (European Sports Security Association). Through our brands, Betclic Everest Group places expertise, technological know-how and security at the heart of our strategy to deliver an on-line gaming offer attuned to the passion of our players.