Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
GAININGTHE KNOWLEDGEOF
THE OPEN DATA PROTOCOL
(ODATA)
ChrisWoodruff
WHO I AM?
ChrisWoodruff
MVP,Visual C#
Director at Perficient
Co-host of Deep Fried Bytes Podcast
@cwoodruff / cwoodruff@li...
YOUWILL LEARN:
 Understand the background of OData
 Have an understanding of the OData protocol
 How to produce an ODat...
BACKGROUND
Knowledge of OData
QUOTE
Today, the tools for capturing
data both at the mega-scale
and at the milli-scale are just
dreadful. After you have
...
Problem: Data APIs frequently
create more problems than
solutions
THISTALK IS ABOUT ONE SOLUTION.
SURVEY
…knows what the web is
…are comfortable w/ HTTP and
XML? JSON?
…have a basic understanding of
the term REST
…have c...
Is there really a problem?
What is it?
QUIZTIME
FACEBOOK: WHAT FIELDSWILL I
GETWHEN I READ A POST?
FACEBOOK: HOW DOYOU LIKE A
POST?
How do developers
know what to do?
SO GIVENTHAT NOBODY KNEWTHE ANSWERSTOTHESE
QUESTIONS,
I GUESSTHEY USE DOCS
So is there really a problem?
Yes
DEVELOPERS DON’T HAVETIMETO ACTUALLY READTHE DOCS
Can OData Magically cure the
problem? No, but it can help.
LET’S SEE HOW
THE PROTOCOL
Knowledge of OData
THE BASICS OF ODATA
Feeds, which are Collections of typed Entities
OData services can expose Actions and Functions (v4),
S...
FULL SQL LIKE QUERY
“LANGUAGE”
HTTP Command
(Verb)
SQL
Command
GET SELECT
PUT UPDATE
POST INSERT
DELETE DELETE
THE $METADATA ENDPOINT
CONVENTIONS
http://services.odata.org/OData/OData.svc
_______________________________________/
|
service root URI
http://s...
URL CONVENTIONS
$filter
/Suppliers?$filter=Address/City eq 'Redmond‘
$orderby
/Products?$orderby=ReleaseDate asc, Rating d...
COMBINING UEL CONVENTIONS
http://.../Players/
?$skip=10
&$top=2
&filter=substringof(‘Wood',nameLast)
&$orderby=nameLa...
PAYLOAD CONVENTIONS
 Success and error Codes
 200 OK, 201 Created, 415 Unsupported MediaType, etc
 Overall Format
 JSO...
JSON FORMAT
 Friendly to Javascript
 90% more compact than AtomPub
 Reads like a custom API
 Very little OData “gunk”
ATOM FORMAT
 Atom parsers exist in many frameworks
 Element fields can be mapped to their Atom
counterparts
 A good exa...
WHAT ELSE CANYOU DO WITH
ODATA?
 Actions and Functions allow hypermedia-based
method calls (non-CRUD operations)
 Define...
ODATA ISN’T ALWAYSTHE BEST
FIT
 OData may not be a good fit for highly opinionated APIs
laden with developer intent
 ODa...
ODATA DOES NOT SUPPORT ALL
QUERIES
 OData doesn’t currently support aggregation
 You can’t ask for customers that have a...
ODATA IS A STANDARD!!
 OASIS, ISO
 Ratified in March!
WHO USES ODATA?
WHAT DOES ODATA GIVE ME AND
MY ORGANIZATION?
Empower Internal
Power Users
Empower Existing and
Future Customers
Monetize D...
CREATING FEEDW/
ASP.NETWEB API
Knowledge of OData
ASP.NETWEB API
DEMO
ODATA BEST PRACTICES
(PRODUCER)
 Always design your OData feed will server-side paging if your
entity collections hold la...
CONSUMING ODATA
Knowledge of OData
WHAT IF DATA API’S WERE LIKE…
LINQ?
 What are the last 50 invoices we sent?
 context.Invoice.OrderByDescending(i=>i.Post...
ODATA BEST PRACTICES
(CONSUMER)
 Use Query Projection to only bring back the entity properties
you or your app needs.
 T...
WHY AREWE EXCITED!!
WRAP-UP
Knowledge of OData
The demo projects can be found at:
github.com/cwoodruff/
RESOURCES
REST
http://www.ics.uci.edu/~taylor/documents/2002-
REST-TOIT.pdf
OData
http://odata.org
http://odataprimer.com
CONTACT ME
Chris “Woody”Woodruff
cwoodruff@live.com
Twitter @cwoodruff
Skype cwoodruff
http://chriswoodruff.com
http://dee...
Upcoming SlideShare
Loading in …5
×

Gaining the Knowledge of the Open Data Protocol (OData)

The Open Data Protocol (OData) is an open protocol for sharing data. It provides a way to break down data silos and increase the shared value of data by creating an ecosystem in which data consumers can interoperate with data producers in a way that is far more powerful than currently possible, enabling more applications to make sense of a broader set of data. Every producer and consumer of data that participates in this ecosystem increases its overall value.

OData is consistent with the way the Web works – it makes a deep commitment to URIs for resource identification and commits to an HTTP-based, uniform interface for interacting with those resources (just like the Web). This commitment to core Web principles allows OData to enable a new level of data integration and interoperability across a broad range of clients, servers, services, and tools.

  • Be the first to comment

Gaining the Knowledge of the Open Data Protocol (OData)

  1. 1. GAININGTHE KNOWLEDGEOF THE OPEN DATA PROTOCOL (ODATA) ChrisWoodruff
  2. 2. WHO I AM? ChrisWoodruff MVP,Visual C# Director at Perficient Co-host of Deep Fried Bytes Podcast @cwoodruff / cwoodruff@live.com Skype: cwoodruff
  3. 3. YOUWILL 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
  4. 4. BACKGROUND Knowledge of OData
  5. 5. 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 curation and data analysis. Jim Gray
  6. 6. Problem: Data APIs frequently create more problems than solutions THISTALK IS ABOUT ONE SOLUTION.
  7. 7. 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
  8. 8. Is there really a problem? What is it? QUIZTIME
  9. 9. FACEBOOK: WHAT FIELDSWILL I GETWHEN I READ A POST?
  10. 10. FACEBOOK: HOW DOYOU LIKE A POST?
  11. 11. How do developers know what to do? SO GIVENTHAT NOBODY KNEWTHE ANSWERSTOTHESE QUESTIONS,
  12. 12. I GUESSTHEY USE DOCS
  13. 13. So is there really a problem? Yes DEVELOPERS DON’T HAVETIMETO ACTUALLY READTHE DOCS
  14. 14. Can OData Magically cure the problem? No, but it can help. LET’S SEE HOW
  15. 15. THE PROTOCOL Knowledge of OData
  16. 16. 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
  17. 17. FULL SQL LIKE QUERY “LANGUAGE” HTTP Command (Verb) SQL Command GET SELECT PUT UPDATE POST INSERT DELETE DELETE
  18. 18. THE $METADATA ENDPOINT
  19. 19. 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
  20. 20. 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
  21. 21. COMBINING UEL CONVENTIONS http://.../Players/ ?$skip=10 &$top=2 &filter=substringof(‘Wood',nameLast) &$orderby=nameLast%20desc &$select=nickname,yearBorn,nameFirst &$format=json
  22. 22. PAYLOAD CONVENTIONS  Success and error Codes  200 OK, 201 Created, 415 Unsupported MediaType, etc  Overall Format  JSON  AtomPub  JSONVerbose  Nuances  PATCH, Null payloads, etc
  23. 23. JSON FORMAT  Friendly to Javascript  90% more compact than AtomPub  Reads like a custom API  Very little OData “gunk”
  24. 24. ATOM FORMAT  Atom parsers exist in many frameworks  Element fields can be mapped to their Atom counterparts  A good example of OData interoperability
  25. 25. WHAT ELSE CANYOU DO WITH ODATA?  Actions and Functions allow hypermedia-based method calls (non-CRUD operations)  Defined conventions for PATCH and deep insert  Vocabularies
  26. 26. ODATA ISN’T ALWAYSTHE 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
  27. 27. 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
  28. 28. ODATA IS A STANDARD!!  OASIS, ISO  Ratified in March!
  29. 29. WHO USES ODATA?
  30. 30. WHAT DOES ODATA GIVE ME AND MY ORGANIZATION? Empower Internal Power Users Empower Existing and Future Customers Monetize Data for untapped Revenue
  31. 31. CREATING FEEDW/ ASP.NETWEB API Knowledge of OData
  32. 32. ASP.NETWEB API DEMO
  33. 33. 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
  34. 34. CONSUMING ODATA Knowledge of OData
  35. 35. 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);
  36. 36. 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).
  37. 37. WHY AREWE EXCITED!!
  38. 38. WRAP-UP Knowledge of OData
  39. 39. The demo projects can be found at: github.com/cwoodruff/
  40. 40. RESOURCES REST http://www.ics.uci.edu/~taylor/documents/2002- REST-TOIT.pdf OData http://odata.org http://odataprimer.com
  41. 41. CONTACT ME Chris “Woody”Woodruff cwoodruff@live.com Twitter @cwoodruff Skype cwoodruff http://chriswoodruff.com http://deepfriedbytes.com

×