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
2. What You Will See
As 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 principles
behind the architectural style known as REST.
You will also get a taste of two different approaches for implementing
interfaces according to REST principles in your SAP systems.
Mastering SAP Technologies
3. A Quick Definition
Architectural 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. 13
Mastering SAP Technologies
11. A Different Approach
REST interfaces manipulate the state of resources
“Process as a state machine/data flow diagram”
Resource-oriented decomposition of business processes
SOA-style interfaces perform a specific task
“Process as a flowchart/workflow”
Functional decomposition of business processes
Mastering SAP Technologies
12. Representations?
A Representation is a serialised version of the server’s internal state
Provides abstraction from implementation (DB, frameworks, language)
Dynamically-created web pages are Representations!
Many different formats possible – not just XML!
Mastering SAP Technologies
14. Identifying Resources
URLs because everyone understands them:
http://saperp/accountcustomer/12345
URLs are cheap. Use lots of them!
http://api.netflix.com/catalog/titles/movies/60021896
http://api.netflix.com/catalog/titles/movies/60021896/cast
http://api.netflix.com/catalog/titles/movies/60021896/synopsis
Mastering SAP Technologies
15. HTTP?
Why the http://… URLs?
Mastering SAP Technologies
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.11
Mastering SAP Technologies
17. This has a number of benefits…
Mastering SAP Technologies
18. Benefits
Reliable Communication
(The client must handle errors and retries)
Free* Caching!
*provided by commodity infrastructure!
Mastering SAP Technologies Thanks, Oliver Widder!
19. Benefits
Easy Metadata Exchange via HTTP Headers!
Accept
Content-Type
If-Modified-Since
Last-Modified
…
Mastering SAP Technologies
20. Benefits
…and last but definitely not least…
A Universally-Understood Protocol!
Mastering SAP Technologies
21. But How is that Better than SOAP?
Mastering SAP Technologies
22. No Special Tools Needed!
Mastering SAP Technologies Thanks, Oliver Widder!
23. HTTP Has Standard Verbs…
GET
PUT
POST
DELETE
HEAD
OPTIONS
PATCH
TRACE
Mastering SAP Technologies
25. Standard Verbs
Standard Meaning
Constraints = scope for optimization
HTTP GET probably the most optimised piece of code ever
Widely Implemented
Everybody knows how to behave
No need to code low-level, API-specific communication logic
Mastering SAP Technologies
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
30. HATEOAS for Humans
Client requests Shopping Cart
Server sends HTML page with items and links
Client’s move
Client clicks the “Check Out” link
Server sends HTML page with Total Amount
Client’s move
Client clicks the “Pay” link
Server sends HTML page with “Thank You” message
Mastering SAP Technologies
31. Things to Note
The 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 care
Mastering SAP Technologies
33. NetWeaver Gateway
REST-inspired OData API
Add-On to NetWeaver 7.02
Current version: 2.0 SP03 Web Devices Enterprise
Software
Social
Strategic for SAP
SAP NetWeaver Gateway
SAP Business Suite
CRM SRM SCM PLM ERP
Mastering SAP Technologies
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 tools
My take: A productivity framework similar to the Web Services Runtime
in ABAP
Mastering SAP Technologies
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 separately
Mastering SAP Technologies
36. Mapping to BAPIs
BAPI Field Defaults OData XML Field
Mastering SAP Technologies
37. OData Channel
Programmatic way of exposing OData from the backend
Much more flexible – full HATEOAS implementation possible!
Full feature set available in SP04 (May 2012)
Mastering SAP Technologies
41. DJ Adams Started It All…
Mastering SAP Technologies DJ Adam’s SCN Blog
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 Opportunities
Target consumer: Mobile app built with HTML5 + jQuery Mobile
Mastering SAP Technologies
44. Design Principles
JSON as the default format
Roles & Relationships via hyperlinks
Client must only know the ‘entry point’ URL to its own BP
All other client interaction driven by hyperlinks
There is a great ABAP JSON library on CodeExchange!
Mastering SAP Technologies
54. 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 integration
Mastering SAP Technologies
55. If You’d Like to Learn More
A free eBook on REST, by InfoQ: http://www.infoq.com/minibooks/emag-03-2010-rest
A Pragmatic Introduction to REST, by Stefan Tilkov
Teach a Dog to REST, by Apigee’s Brian Mulloy
REST: putting the web back in to web services, by Kerry Buckley
DJ Adams’ original blog on REST on SDN: Forget SOAP - build real web services with the ICF
Further 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 resources
The defining work on REST, by Roy FieldingArchitectural Styles and the Design of Network-based Software Architectures
A Simple Intro to JSON: http://json.org
Known Limitations of SAP NetWeaver Gateway: SAP Note 1574568
The Richardson Maturity Model, and explained by Martin Fowler.
Mastering SAP Technologies