Post on 03-Jul-2020
ODataThe best way to REST
Sam Xu
Software Engineer II
Microsoft
• SDE II at Microsoft Shanghai ZiZhu
• Almost 4 Years in Microsoft
• 3+ years in OData Team
• Focus on ODL, Web API OData
• http://github.com/xuzhg
About me
Agenda
• What is OData?
• Where is OData?
• Who provides OData?
• Why choose OData?
What is OData?
Web Services – SOAP vs REST
SOAP REST
Overhead Heavyweight Lightweight
Metadata Complex Simple
Operations SOAP envelope HTTP VERB (Get, Post…)
Resource identity SOAP envelope HTTP URI
• REST: Representational State Transfer• SOAP: Simple Object Access Protocol
Open Data Protocol (OData)
• An open protocol of OASIS standard to allow the creation and consumption of queryable and interoperable RESTful APIs in
a simple and standard way.[ ]• OASIS standard (2014/3/17)• HTTP Request/Response, Method, Status codes, etc• Entity Data Model (EDM)• JavaScript Object Notation (JSON)• Rich Query Options ($filter, $expand, etc)• ……
Where is OData?
Microsoft
Microsoft
Office 365 API
Azure APIsExcel and
PowerQuery
“The Office 365 APIs follow REST and OData 4.0 standards for data transport, and use the OAuth 2.0 standard for authentications and authorization.”
“Azure Search service API uses Open Data Protocol (OData) for index queries. Azure Search supports OData version 4.”
“Microsoft Power Query for Excel’s OData V4 support leverages the built-in functionality of the OData service to bring only the relevant data back into Excel. ”
More …
SAP NetWeaver Gateway SAP OpenUI5
SAP
“SAP NetWeaver Gateway provides an API that is designed to function in just such a manner; and it does so using the OData protocol.”
“It eases your development with a client-side HTML5 rendering library including a rich set of controls and supports data binding to different models (JSON, XML and OData).”
Salesforce’s OData product:
Lightning Connect & DataDirect Cloud
“With external objects you can connect to an external data source like SAP or any other database that uses OData protocol or a simple URL.”
Who provides OData?
OData libraries by Microsoft
Source: https://github.com/OData/Document: http://odata.github.io/
OData libs on Nuget.org
OData libraries by Breeze
http://www.getbreezenow.com/documentation/odata
Why choose OData?
Advantages
OData
OpenStandard
Interoperability
RESTfulness
Queryability
Industry practice
Community
OData is an open standard
Standardization history
V1.0 (2007)
V2.0 (2009)
V3.0 (2012)
V4.0 (2014) V4.0 (will submit to ISO this year)
OData OASIS TC participants
OData provides interoperability
Openness leads to interoperability
Agreed resource identification method
Agreed resource representation
Agreed resource operation
OData APIs are RESTful
OData follows REST principles
OData provides API queryability
Rich system query options
• To narrow the result set$filter
• To narrow the set of properties$select
• To do client side paging$top and $skip
• To sort the result set$orderby
• To take advanced results$count, $search,
$value, $format…
OData represents industry practices
Specification covering every aspect of REST
Model representation
Batch & asynchronous
requests
VersioningChange
requesting
URL conventions
Queries OperationsData
annotation…
Entity Data model
Http Verbs
Context URL
OData Version
Query Options
Industry practices in different businesses
Enterprises
• Microsoft
• SAP
• Salesforce
• IBM
• Schneider
Electrics
SaaS providers
• Blue garden
• K2
• Creditpoint
• Questionmark
• Splunk
Integration service
providers
• Jitterbit
• ODataHQ
• Mulesoft
• Juhe Data (聚合
数据)
• Progress software
Library and tooling
implementers
• JayData
• Apache
• Breeze
• Gizur
• Pragmatiqa
• Tableau
http://www.OData.org/ecosystem/
OData has a prosperous community
Three personas and their needs
RESTful API/client
Developers
• Tutorials
• Documentations
• Community
• Libraries
• Tooling
Business decision
makers
• Success stories
• Customers
• Business benefits
API advocates
• A good protocol
to advocate and
learn from
• Everything the
first two
personas need
Source Codes
DEMO
Basic OData URI examples
http://services.odata.org/V4/TripPinService
http://services.odata.org/V4/TripPinService/$metadata
http://services.odata.org/V4/TripPinService/People
http://services.odata.org/V4/TripPinService/People('russellwhyte')
Advance Query option examples
http://services.odata.org/V4/TripPinService/People?$filter=startswith(LastName,'A')
http://services.odata.org/V4/TripPinService/People?$select=UserName
http://services.odata.org/V4/TripPinService/People?$top=2&$skip=1
http://services.odata.org/V4/TripPinService/People?$orderby=FirstName%20desc
http://services.odata.org/V4/TripPinService/People?$filter=Friends/any(e0:startswith(e0/FirstName,'W') and Friends/any(e1:(LastName eq 'Alfred')))&$select=UserName,Friends
Summary
OData - The best way to REST
• Open protocol, open source libraries, open
communityOpen
• Protocol built on REST principlesRESTful
• Available on any device, any platform, anywhereUbiquitous
• Build on industry best practices, supported and
used by Enterprises that serves billions of usersPractical
Resources
• OData communityHome: • http://www.OData.org
• OASIS OData TC Home: • https://www.oasis-open.org/committees/tc_home.php?wg_abbrev=OData
• OData on GitHub: • https://github.com/OData/
• OData V4 sample servicesTripPin (read & write):• http://services.OData.org/V4/TripPinServiceRW
• OData team of MicrosoftMail to: • ODatafeedback@microsoft.com
Go to:
Thank You!