Successfully reported this slideshow.

REST: So What's It All About? (Mastering SAP Technologies 2012)

7,388 views

Published on

An updated version (to March 2012) of a talk of the same name originally presented at SAP TechEd 2011 in Las Vegas. A video recording of the presentation is available on Vimeo: http://vimeo.com/39673297

Published in: Technology
  • Be the first to comment

REST: So What's It All About? (Mastering SAP Technologies 2012)

  1. 1. REST: So What’s It All About?Sascha Wenninger (@sufw)
  2. 2. What You Will SeeAs a paradigm for designing application integration and APIs,REST now enjoys significantly greater popularity than SOA(P),particularly for public, internet-facing APIs.This presentation will give you a quick overview of the core principlesbehind the architectural style known as REST.You will also get a taste of two different approaches for implementinginterfaces according to REST principles in your SAP systems.Mastering SAP Technologies
  3. 3. A Quick DefinitionArchitectural Style “An architectural style is a coordinated set of architectural constraints that restricts the roles/features of architectural elements and the allowed relationships among those elements within any architecture that conforms to that style.”Roy Fielding, p. 13Mastering SAP Technologies
  4. 4. Agenda NetWeaver Custom Concepts Demo Gateway Coding Implementation OptionsMastering SAP Technologies
  5. 5. Agenda NetWeaver Custom Concepts Demo Gateway Coding Implementation OptionsMastering SAP Technologies
  6. 6. RESTMastering SAP Technologies
  7. 7. REpresentational State TransferMastering SAP Technologies
  8. 8. What Does That Mean?Mastering SAP Technologies
  9. 9. One Definition… The Client communicates with the Server by modifying the state of Resources through RepresentationsMastering SAP Technologies
  10. 10. Another Definition… It’s The Web (for Machines)Mastering SAP Technologies
  11. 11. A Different ApproachREST interfaces manipulate the state of resources “Process as a state machine/data flow diagram” Resource-oriented decomposition of business processesSOA-style interfaces perform a specific task “Process as a flowchart/workflow” Functional decomposition of business processesMastering SAP Technologies
  12. 12. Representations?A Representation is a serialised version of the server’s internal stateProvides abstraction from implementation (DB, frameworks, language)Dynamically-created web pages are Representations!Many different formats possible – not just XML!Mastering SAP Technologies
  13. 13. Identifying Resources Every Resource has an IDMastering SAP Technologies
  14. 14. Identifying ResourcesURLs because everyone understands them:http://saperp/accountcustomer/12345URLs are cheap. Use lots of them!http://api.netflix.com/catalog/titles/movies/60021896http://api.netflix.com/catalog/titles/movies/60021896/casthttp://api.netflix.com/catalog/titles/movies/60021896/synopsisMastering SAP Technologies
  15. 15. HTTP? Why the http://… URLs?Mastering SAP Technologies
  16. 16. HTTP! Layer Example HTTP is an Application Protocol 7 Application DNS, FTP, HTTP... 6 Presentation SSL 5 Session L2TP, PPTP REST uses it as such 4 Transport TCP 3 Network IP SOAP uses it as a dumb transport 2 Data Link PPP, ARP 1 Physical IEEE 802.11Mastering SAP Technologies
  17. 17. This has a number of benefits…Mastering SAP Technologies
  18. 18. Benefits Reliable Communication (The client must handle errors and retries) Free* Caching! *provided by commodity infrastructure!Mastering SAP Technologies Thanks, Oliver Widder!
  19. 19. BenefitsEasy Metadata Exchange via HTTP Headers!AcceptContent-TypeIf-Modified-SinceLast-Modified…Mastering SAP Technologies
  20. 20. Benefits …and last but definitely not least… A Universally-Understood Protocol!Mastering SAP Technologies
  21. 21. But How is that Better than SOAP?Mastering SAP Technologies
  22. 22. No Special Tools Needed!Mastering SAP Technologies Thanks, Oliver Widder!
  23. 23. HTTP Has Standard Verbs… GET PUT POST DELETE HEAD OPTIONS PATCH TRACEMastering SAP Technologies
  24. 24. SOAP Doesn’t.getAccountCustomerByInternalIdsearchCustomerByBasicDataupdateSalesProspectStatusByPartnerSalesRepresentativeBasicData_syncAnd everything works via HTTP POST(i.e. it uses HTTP as a dumb transport protocol)Mastering SAP Technologies
  25. 25. Standard VerbsStandard Meaning Constraints = scope for optimization HTTP GET probably the most optimised piece of code everWidely Implemented Everybody knows how to behave No need to code low-level, API-specific communication logicMastering SAP Technologies
  26. 26. HTTP Has Standard Responses… 200 OK 302 Moved Permanently 404 Not Found 406 Method Not Allowed 409 Conflict 418 I’m a Teapot …Mastering SAP Technologies
  27. 27. SOAP Doesn’t.Mastering SAP Technologies
  28. 28. BenefitsOne more:HATEOASMastering SAP Technologies
  29. 29. BenefitsOne more:HypertextAsTheEngineOfApplicationStateMastering SAP Technologies
  30. 30. HATEOAS for HumansClient requests Shopping CartServer sends HTML page with items and linksClient’s moveClient clicks the “Check Out” linkServer sends HTML page with Total AmountClient’s moveClient clicks the “Pay” linkServer sends HTML page with “Thank You” messageMastering SAP Technologies
  31. 31. Things to NoteThe Server guides the Client forward in the process (with ‘Check Out’, ‘Pay’ links, etc.)The Client is responsible for moving forward If the client stops, the server doesn’t careMastering SAP Technologies
  32. 32. NetWeaver Custom Concepts Demo Gateway Coding Implementation OptionsMastering SAP Technologies
  33. 33. NetWeaver GatewayREST-inspired OData APIAdd-On to NetWeaver 7.02Current version: 2.0 SP03 Web Devices Enterprise Software SocialStrategic for SAP SAP NetWeaver Gateway SAP Business Suite CRM SRM SCM PLM ERPMastering SAP Technologies
  34. 34. The Good Things• Quickly build very simple RESTful APIs• Exposes BAPIs or custom ABAP classes via OData XML• Core part of SAP’s roadmap (integration to SUP, Duet, etc.)• SAP-delivered content with each SP release• Detailed logging and performance analysis toolsMy take: A productivity framework similar to the Web Services Runtime in ABAPMastering SAP Technologies
  35. 35. The Limitations• Only supports OData (Open, but Microsoft-centric XML) – JSON-formatted OData available with SP04 (May 2012) – no custom representations (other XML, PDF, etc.)• Limited support for complex input parameters (e.g. forms)• Anything beyond really basic APIs will require custom code – …maybe even lots of code…• Licensed separatelyMastering SAP Technologies
  36. 36. Mapping to BAPIs BAPI Field Defaults OData XML FieldMastering SAP Technologies
  37. 37. OData ChannelProgrammatic way of exposing OData from the backendMuch more flexible – full HATEOAS implementation possible!Full feature set available in SP04 (May 2012)Mastering SAP Technologies
  38. 38. Mastering SAP Technologies
  39. 39. Mastering SAP Technologies
  40. 40. NetWeaver Custom Concepts Demo Gateway Coding Implementation OptionsMastering SAP Technologies
  41. 41. DJ Adams Started It All…Mastering SAP Technologies DJ Adam’s SCN Blog
  42. 42. A Simple REST API for CRM• BusinessPartners everywhere• BPs have roles (e.g. Customer, Contact Person, Employee…)• BPs have relationships with other BPs• Relationships have attributes• Relationships lead to OpportunitiesTarget consumer: Mobile app built with HTML5 + jQuery MobileMastering SAP Technologies
  43. 43. 3 Resourceshttp://sapcrm:8000/auspost/businesspartnerhttp://sapcrm:8000/auspost/bprelationshiphttp://sapcrm:8000/auspost/opportunityplus any sub-resources we needMastering SAP Technologies
  44. 44. Design PrinciplesJSON as the default formatRoles & Relationships via hyperlinksClient must only know the ‘entry point’ URL to its own BPAll other client interaction driven by hyperlinksThere is a great ABAP  JSON library on CodeExchange!Mastering SAP Technologies
  45. 45. ICF Configuration Create a public classMastering SAP Technologies
  46. 46. ICF ConfigurationAssign Interface IF_HTTP_EXTENSIONMastering SAP Technologies
  47. 47. Insert Code Here.Mastering SAP Technologies Thanks, Oliver Widder!
  48. 48. NetWeaver Custom Concepts Demo Gateway Coding Implementation OptionsMastering SAP Technologies
  49. 49. QuestionsMastering SAP Technologies
  50. 50. Key Points to Take Home• REST is an architectural style – not a protocol or product. – Applies web principles to A2A integration, including use of hyperlinks• NetWeaver Gateway can quickly expose SAP data & functionality in a RESTful way.• More specific requirements can be met via custom code, including the ADL (Alternative Dispatch Layer)• Most mobile frameworks rely on RESTful integrationMastering SAP Technologies
  51. 51. If You’d Like to Learn MoreA free eBook on REST, by InfoQ: http://www.infoq.com/minibooks/emag-03-2010-restA Pragmatic Introduction to REST, by Stefan TilkovTeach a Dog to REST, by Apigee’s Brian MulloyREST: putting the web back in to web services, by Kerry BuckleyDJ Adams’ original blog on REST on SDN: Forget SOAP - build real web services with the ICFFurther blogs by DJ on implementing RESTful services via the ICF:• REpresentational State Transfer (REST) and SAP• A new REST handler / dispatcher for the ICF• REST-orientation: Controlling access to resourcesThe defining work on REST, by Roy FieldingArchitectural Styles and the Design of Network-based Software ArchitecturesA Simple Intro to JSON: http://json.orgKnown Limitations of SAP NetWeaver Gateway: SAP Note 1574568The Richardson Maturity Model, and explained by Martin Fowler.Mastering SAP Technologies
  52. 52. watchKeynote();Mastering SAP Technologies
  53. 53. watchKeynote();Mastering SAP Technologies
  54. 54. We’re RESTful now GET /masteringsap/tech/keynote HTTP/1.1Mastering SAP Technologies
  55. 55. Sascha Wenninger Australia Post sascha@wenninger.name @sufw +61 403 933 472Mastering SAP Technologies Slide 59

×