REST - What's It All About? (SAP TechEd 2012, CD110)


Published on

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

REST - What's It All About? (SAP TechEd 2012, CD110)

  1. 1. REST – So What’s It All About? CD110 @ SAP TechEd 2012 Las Vegas
  2. 2. About MeSascha WenningerIntegration Guy: SOA, PI, etc.Drawer of Diagrams, Writer of Emails@sufw
  3. 3. Agenda Applica.ons  Concepts   Demo   in  SAP-­‐land  
  4. 4. Agenda Applica.ons  Concepts   Demo   in  SAP-­‐land  
  5. 5. REST
  6. 6. REpresentationalStateTransfer
  7. 7. What Does That Mean?
  8. 8. The Client communicates with the Server by modifying the state of Resources through Representations
  9. 9. It’s  the  Web     (for  machines)  
  10. 10. REST  interfaces  manipulate  the  state  of  resources   “Process  as  a  state  machine/data  flow  diagram”   Resource-­‐oriented  decomposi.on  of  business  processes      SOA-­‐style  interfaces  perform  a  specific  task   “Process  as  a  flowchart/workflow”   Func.onal  decomposi.on  of  business  processes  
  11. 11. Representations?The server can store its data in whatever way it likesThe client is unaware of this, and can store the same things differentlyEach party serialises its internal state into RepresentationsThis provides loose coupling!
  12. 12. Everything has a URL
  13. 13. URLs because everyone understands them: are cheap. Use lots of them!
  14. 14. Why the http:// URLs?
  15. 15. HTTP is an Application Protocol. REST recognises this.
  16. 16. But How is that Better than SOAP?
  17. 17. Remember the OSI Stack? Layer   Example  7   Applica/on   DNS,  FTP,  HTTP,  etc.  6   Presenta.on   SSL  5   Session   L2TP,  PPTP  4   Transport   TCP  3   Network   IP  2   Data  Link   PPP,  ARP  1   Physical   IEEE  802.11  
  18. 18. SOAP was designedto be transport-protocol agnostic
  19. 19. Many bindings for SOAP: HTTP SMTP JMS AMQP
  20. 20. Many bindings for SOAP: HTTP SMTP JMS AMQP
  21. 21. HTTP  is  an  Applica.on   Protocol.  REST recognises this.
  22. 22. SOAP knows nothing about it!
  23. 23. So What?Well, there are benefits to knowing…
  24. 24. Reliable Communication(as long as the client knows how to handle errors and retries)Free* Caching!*provided by commodity infrastructure!
  25. 25. Easy Metadata exchange via HTTP Headers!AcceptContent-TypeIf-Modified-SinceLast-Modified
  26. 26. …and last but not least…A Universally-Understood Protocol!
  28. 28. HTTP has Standard VerbsStandard Meaningà Constraints = scope for optimizationWidely Implementedà Everybody knows how to behave
  29. 29. SOAP Doesn’t.getAccountCustomerByInternalIdsearchCustomerByBasicDataupdateSalesProspectStatusByPartnerSalesRepresentativeBasicData_syncAnd everything works via HTTP POST(i.e. it uses HTTP as the dumb transport)
  30. 30. HTTP has Standard Responses 200 OK 302 Moved Permanently 404 Not Found 406 Method Not Allowed 409 Conflict 418 I’m a Teapot …
  31. 31. SOAP Doesn’t.
  32. 32. One last principle before we move on: HATEOAS  
  33. 33. One last principle before we move on: Hypertext   As   The   Engine   Of   Applica.on   State  
  34. 34. An ExampleClient requests Shopping CartServer sends HTML page with items and links Client’s moveClient clicks the “Check Out” linkServer sends HTML page with Total Amount Client’s moveClient clicks the “Pay” linkServer sends HTML page with “Thank You” message
  35. 35. Notice Something?The Client is responsible for moving forward in a processThe server guides the client forward (with ‘Check Out’, ‘Pay’ links)The client is responsible for completing the process If the client stops, the server doesn’t care!
  36. 36. Notice Something?The server doesn’t maintain session/application state. It does maintain resource state!Every request modifies the state of a resourceIn the example, the client causes the state of the “Shopping Cart” resource to be modified.
  37. 37. Applica.ons  Concepts   Demo   in  SAP-­‐land  
  38. 38. NetWeaver Gateway
  39. 39. RESTful OData API Add-On to NetWeaver 7.0* Web Devices Enterprise Social Software Current version: 2.0 SP05 Strategic for SAP SAP  NetWeaver  Gateway   SAP  Business  Suite   CRM SRM SCM PLM ERP*see  Prerequisites  and  Deployment  Op.ons  
  40. 40. The Good Things•  Exposes BAPIs, RFCs & custom ABAP classes via OData XML –  Specific connectors for BOL (GenIL), HANA, BW, BOR, Workflow, etc.•  Well integrated into SAP’s roadmap –  Tight integration with SUP 2.1+ –  Duet Enterprise uses Gateway internally•  Framework provides flexible security and auditing/logging•  Push notifications to consumers after subscription•  Expose data & functionality from older (pre-7.0) systems
  41. 41. New Since Last Year•  JSON (finally! :-)•  Batch operations•  “Deltas”, aka conditional requests•  “Model Composition”, aka Mash-ups•  New Service Builder (SEGW)•  Idempotency Support•  etc… (see What’s New)
  42. 42. 2 Approaches to Development Generation Tools OData Channel•  Quickly expose BAPIs, RFCs •  Complete Control and GUI screens •  Build custom code adhering to•  Up & running in minutes! a structured framework with a library of helper classes •  Since SP04: SEGW
  43. 43. 2 Approaches to Development Generation Tools OData Channel•  Quickly expose BAPIs, RFCs •  Complete Control and GUI screens •  Build custom code adhering to•  Up & running in minutes! a structured framework with a library of helper classes •  New tool SEGW since SP04
  44. 44. The Limitations•  Only supports OData (both XML & JSON) –  no custom representations (other XML/JSON, PDF, etc.)•  Limited support for complex input parameters•  Inherits the limitations of the backend services
  45. 45. More Info on Gateway at TechEd CD109 How the University of Mississippi Runs Better with NetWeaver Gateway CD160 NetWeaver Gateway Development for Beginners CD204 NetWeaver Gateway and OData in Detail CD267 Developing Applications with HTML5 Toolkit and NetWeaver GatewayMOB107 Best Practices for Establishing and Running a Mobile LandscapeMOB204 Building SAP Applications Using NetWeaver Gateway and HTML5MOB205 From Start to Finish - Developing an iPad App Using NW GatewayPMC206 NetWeaver PI and Gateway - When to Use What TEC107 NetWeaver Gateway Overview - Roadmap and Strategy
  46. 46. Custom Development
  47. 47. DJ Adams Started It All!
  48. 48. A Simple RESTful API for SAP 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 Mobile
  49. 49. 3 Resourceshttp://sapcrm:8000/api/businesspartnerhttp://sapcrm:8000/api/bprelationshiphttp://sapcrm:8000/api/opportunityplus any sub-resources we need
  50. 50. 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!
  51. 51. Sidebar: Hyperlinks in JSON
  52. 52. Sidebar: Hyperlinks in JSON No one standard to show hyperlinks à We chose the simplest option we found:magic  keyword   rela.onship*   “links”: { “self”: “http://…”, custom  rela.onship   link  URL   “up”: “http://…”, “”: “http://…”, … } *as  per  IANA  standard  
  53. 53. ICF Configuration in SAP CRM Create  a  public  class    
  54. 54. ICF Configuration in SAP CRMAssign interface IF_HTTP_EXTENSION
  55. 55. Insert Code Here…
  56. 56. Demo
  57. 57. Summary•  REST is an architectural style –  Apply web principles to A2A integration –  Promotes true loose coupling via hyperlinks –  Based on Resources rather than functionality or tasks•  NetWeaver Gateway can expose SAP data & functionality in a RESTful way.•  More specific requirements can be met with Z code•  Most mobile frameworks rely on RESTful integration –  But the REST style is equally valid for A2A and non-mobile scenarios!
  58. 58. About MeSascha
  59. 59. Get the Latest Version of this Talk!  presenta.on  by  Sascha  Wenninger  is  available  under  a  Commons  A`ribu.on-­‐ShareAlike  3.0  license  
  60. 60. FeedbackPlease complete a session evaluation for this sessionSession Code: CD110
  61. 61. Resources & Further ReadingA free eBook on REST, by InfoQ: interesting blogs and articles on InfoQ: Richardson Maturity Model, explained by Martin Fowler: ...and by Leonard Richardson himself: Adams’ original blog on REST on SCN: blogs by DJ on implementing RESTful services via the ICF: Simple Intro to JSON: http://json.orgCORS – Cross-Origin Resource Sharing, by the Mozilla Developer Network:
  62. 62. Resources & Further ReadingRESTful APIs from Scratch – Lessons Learnt (so far): NetWeaver Gateway space on SCN: An Application-Level Protocol: Let’s GET It On!: Response Codes: are not Objects: (a good read for OO programmers)Known Limitations of SAP NetWeaver Gateway: SAP Note 1574568
  63. 63. AttributionsImages by Geek & Poke (Oliver Widder):‘Standards’ by xkcd (Randall Munroe):‘Permanent State’ by Gaping Void (Hugh MacLeod): thanks to all for providing their work under a Creative Commons license! J