gaining the knowledge of the open data protocol (odata)
TRANSCRIPT
![Page 1: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/1.jpg)
GAINING THE KNOWLEDGE OF THE OPEN DATA PROTOCOL
(ODATA)Chris Woodruff
![Page 2: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/2.jpg)
WHO I AM?
Chris Woodruff
MVP, Visual C#
Director at Perficient
Co-host of Deep Fried Bytes Podcast
@cwoodruff / [email protected]
Skype: cwoodruff
![Page 3: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/3.jpg)
YOU WILL LEARN:
Understand the background of OData
Have an understanding of the OData protocol
How to produce an OData feed using WCF Data Services
How to produce an OData feed using ASP.NET Web API
How to consume an OData feed using LINQ
![Page 4: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/4.jpg)
BACKGROUND
Knowledge of OData
![Page 5: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/5.jpg)
QUOTE
Today, the tools for capturing data both at the mega-scale and at the milli-scale are just dreadful. After you have captured the data, you need to curate it before you can start doing any kind of data analysis, and we lack good tools for both data curationand data analysis.
Jim Gray
![Page 6: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/6.jpg)
Problem: Data APIs frequently create more problems than
solutionsTHIS TALK IS ABOUT ONE SOLUTION.
![Page 7: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/7.jpg)
SURVEY
…knows what the web is
…are comfortable w/ HTTP and XML? JSON?
…have a basic understanding of the term REST
…have created a Data API
![Page 8: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/8.jpg)
Is there really a problem?What is it?
QUIZ TIME
![Page 9: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/9.jpg)
FACEBOOK: WHAT FIELDS WILL I GET WHEN I READ A POST?
![Page 10: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/10.jpg)
FACEBOOK: HOW DO YOU LIKE A POST?
![Page 11: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/11.jpg)
How do developers know what to do?
SO GIVEN THAT NOBODY KNEW THE ANSWERS TO THESE QUESTIONS,
![Page 12: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/12.jpg)
I GUESS THEY USE DOCS
![Page 13: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/13.jpg)
So is there really a problem?Yes
DEVELOPERS DON’T HAVE TIME TO ACTUALLY READ THE DOCS
![Page 14: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/14.jpg)
Can OData Magically cure the problem? No, but it can help.
LET’S SEE HOW
![Page 15: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/15.jpg)
THE PROTOCOL
Knowledge of OData
![Page 16: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/16.jpg)
THE BASICS OF ODATA
Feeds, which are Collections of typed Entities
OData services can expose Actions and Functions (v4), Services (v3)
OData services expose all these constructs via URIs
OData service may also expose a Service Metadata Document
![Page 17: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/17.jpg)
FULL SQL LIKE QUERY “LANGUAGE”
HTTP Command (Verb)
SQLCommand
GET SELECT
PUT UPDATE
POST INSERT
DELETE DELETE
![Page 18: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/18.jpg)
THE $METADATA ENDPOINT
![Page 19: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/19.jpg)
CONVENTIONS
http://services.odata.org/OData/OData.svc
\_______________________________________/
|
service root URI
http://services.odata.org/OData/OData.svc/Category(1)/Products?$top=2&$orderby=name
\_______________________________________/ \__________________/ \_________________/
| | |
service root URI resource path query options
![Page 20: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/20.jpg)
URL CONVENTIONS
$filter
/Suppliers?$filter=Address/City eq 'Redmond‘
$orderby
/Products?$orderby=ReleaseDate asc, Rating desc
$top and $skip
/Products?$top=5&$skip=2
$select and $expand
/Products?$select=*,Category/Name&$expand=Category
![Page 21: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/21.jpg)
COMBINING UEL CONVENTIONS
http://.../Players/ ?$skip=10
&$top=2
&filter=substringof(‘Wood',nameLast)
&$orderby=nameLast%20desc
&$select=nickname,yearBorn,nameFirst
&$format=json
![Page 22: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/22.jpg)
PAYLOAD CONVENTIONS
Success and error Codes 200 OK, 201 Created, 415 Unsupported Media Type, etc
Overall Format JSON
AtomPub
JSON Verbose
Nuances PATCH, Null payloads, etc
![Page 23: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/23.jpg)
JSON FORMAT
Friendly to Javascript
90% more compact than AtomPub
Reads like a custom API
Very little OData “gunk”
![Page 24: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/24.jpg)
ATOM FORMAT
Atom parsers exist in many frameworks
Element fields can be mapped to their Atom counterparts
A good example of OData interoperability
![Page 25: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/25.jpg)
WHAT ELSE CAN YOU DO WITH ODATA?
Actions and Functions allow hypermedia-based method calls (non-CRUD operations)
Defined conventions for PATCH and deep insert
Vocabularies
![Page 26: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/26.jpg)
ODATA ISN’T ALWAYS THE BEST FIT
OData may not be a good fit for highly opinionated APIs laden with developer intent
OData may not be a good fit for bulk data transfer
OData may not be a good fit for the APIs that dramatically different in shape than the backend
![Page 27: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/27.jpg)
ODATA DOES NOT SUPPORT ALL QUERIES
OData doesn’t currently support aggregation You can’t ask for customers that have at least 2 orders
OData doesn’t currently support filters expansions You can’t ask for a customer and only their orders placed in 2013
OData doesn't support “graph” queries You can ask friend-of-a-friend type queries, but there are limitations
![Page 28: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/28.jpg)
ODATA IS A STANDARD!!
OASIS, ISO
Ratified in March!
![Page 29: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/29.jpg)
WHO USES ODATA?
![Page 30: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/30.jpg)
WHAT DOES ODATA GIVE ME AND MY ORGANIZATION?
Empower Internal Power Users
Empower Existing and Future Customers
Monetize Data for untapped Revenue
![Page 31: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/31.jpg)
CREATING FEED W/ ASP.NET WEB API
Knowledge of OData
![Page 32: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/32.jpg)
ASP.NET WEB API
DEMO
![Page 33: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/33.jpg)
ODATA BEST PRACTICES (PRODUCER)
Always design your OData feed will server-side paging if your entity collections hold large amounts of data.
Looks at server-side validation of queries and data updates based on the user credentials sent through HTTP
![Page 34: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/34.jpg)
CONSUMING ODATA
Knowledge of OData
![Page 35: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/35.jpg)
WHAT IF DATA API’S WERE LIKE…
LINQ? What are the last 50 invoices we sent?
context.Invoice.OrderByDescending(i=>i.PostedAt).Take(50);
What are the invoices from the last 24 hours? context.Invoice.Where(i=>i.PostedAt > DateTime.Now.AddDays(-1));
How many $1M invoices have we sent? context.Invoice.Where(i=>i.TotalAmount >= 1000000);
![Page 36: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/36.jpg)
ODATA BEST PRACTICES (CONSUMER)
Use Query Projection to only bring back the entity properties you or your app needs.
Think about client-side paging even if their exists server-side paging.
Design and implement a client-side data caching function in your app (unless sensitive data).
![Page 37: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/37.jpg)
WHY ARE WE EXCITED!!
![Page 38: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/38.jpg)
WRAP-UP
Knowledge of OData
![Page 39: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/39.jpg)
The demo projects can be found at:
github.com/cwoodruff/
![Page 40: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/40.jpg)
RESOURCES
REST
http://www.ics.uci.edu/~taylor/documents/2002-REST-TOIT.pdf
OData
http://odata.org
http://odataprimer.com
![Page 41: Gaining the Knowledge of the Open Data Protocol (OData)](https://reader033.vdocuments.mx/reader033/viewer/2022042817/55a6a4da1a28abda2e8b4569/html5/thumbnails/41.jpg)
CONTACT ME
Chris “Woody” Woodruff
Twitter @cwoodruff
Skype cwoodruff
http://chriswoodruff.com
http://deepfriedbytes.com