Building RESTful Applications  with the Open Data Protocol Todd Anglin Chief Evangelist, Telerik Level:  Intermediate
Introductions Todd Anglin Chief Evangelist, Telerik Microsoft MVP ASP Insider President NHDNUG & O’Reilly Author @toddanglin TelerikWatch.com
The Plan
What you should learn today: What is  REST/OData Who created  REST/OData Why use  REST/OData When should you use  REST/OData Where can you find  REST/OData
How did we get here?
“ There is a  vast amount of data  available today and data is now being collected and stored at a rate never seen before. Much, if not most, of this data however is  locked  into specific applications or formats and  difficult to access  or to  integrate  into new uses.”  - OData.org
State of Data & Services Internal  SQL My App App Data CMS Share Point Cloud Custom API SQL JSON Services FB
What is REST? Re presentational  S tate  T ransfer What is the biggest REST implementation? World Wide Web! REST is NOT a standard! (But it uses standards) HTTP + URLs + XML*
REST Principles
REST Illustrated Magic Kingdom (Resource) http://disneyworld.com/parks/magic-kingdom Resource URL Representation URL Click (State Transfer) Representation
RESTful Services Core idea: let's have  computers  use the web the way  humans  do
Alternatives to REST Most common: SOAP and RPC Why use SOAP (vs REST)? Enterprise security features (WS-Security) ACID Transactions (WS-AtomicTransaction) Message error recovery (WS-ReliableMessaging) SOAP  services focus on exposing  application logic REST  services focus on exposing  “data”  (or CRUD operations on data)
OData does for  data  what REST does for  services
(Finally!) What is OData? HTTP REST-based services AtomPub Data structure JSON  Data delivery format Data silo buster
What do web services require? A way to discover a service provider A way to discover available services at a provider A way to describe how to interface with service A way to execute functions provided by a service A standard messaging format A way to represent the data in exchange
Why? Interoperability Predictable access to data from any system Gaining popularity SharePoint 2010 SQL Server 2008 R2 IBM WebSphere eXtreme Scale Azure Table Storage Telerik TeamPulse …
REST AND ODATA IN ACTION DEMO
Consuming OData Windows Phone 7 / iPhone / Mobile AJAX / Javascript  PHP / Java / .NET  Silverlight  PowerPivot  Simple HTTP Requests (GET, POST, PUT, DELETE) More…
Visual Studio Tools Open Data Protocol Visualizer
CONSUMING EXISTING ODATA DEMO
Creating OData Service As simple as returning proper XML/JSON No specific platform requirements Ways to build: Using Visual Studio tools (WCF Data Services) SharePoint Lists Azure Table Storage Manually produce XML
WCF Data Services (Astoria) Build RESTful services on Microsoft platform Roots of OData protocol Built on WCF Supports ATOM (XML) and JSON data representations Automates REST for data Anything that implements IQueryable<T> or IUpdatable<T> EX:  EF, LinqToSQL, 3 rd  party ORM, etc.
WCF DATA SERVICES BASICS DEMO
Service Operations Functions exposed by OData Similar to RPC Accept zero or more primitive type input params Can return scalar value [WebGet]  is used for an addressable query [WebInvoke]  is used for insert, update, and delete http://.../OData.svc/ GetProductsByRating ?rating=5
Interceptors Query Interceptors Logic runs when resource is requested Uses:  limit the data viewed, log, perform security check Change Interceptors Logic runs when a change (Add/Edit/Delete) request is made (HTTP PUT/POST/DELETE)
SERVICE OPS & INTERCEPTORS DEMO
Securing Data Services Remember! REST is NOT a protocol, it’s a pattern Same security that applies to HTTP, AtomPub, JSON Other options: EntitySetRights Hiding sensitive data with [IgnoreProperties] Infrastructure security – SSL, IP Filtering QueryInterceptors
OData & SharePoint 2010 ListData.svc Out-of-the-box OData access to SharePoint data Data is NOT anonymously available! http://siteurl /_vti_bin/listdata.svc /Announcements
When to REST? Stateless web services Scalable web services (via HTTP caching) Mutually understood context (OData) Restricted bandwidth (Mobile) Always, except when there is a reason NOT to REST
[Q & A] Thanks! Gracias! Mersi! Blagodarya! @toddanglin telerikwatch.com [email_address]

Building RESTful Applications with OData

  • 1.
    Building RESTful Applications with the Open Data Protocol Todd Anglin Chief Evangelist, Telerik Level: Intermediate
  • 2.
    Introductions Todd AnglinChief Evangelist, Telerik Microsoft MVP ASP Insider President NHDNUG & O’Reilly Author @toddanglin TelerikWatch.com
  • 3.
  • 4.
    What you shouldlearn today: What is REST/OData Who created REST/OData Why use REST/OData When should you use REST/OData Where can you find REST/OData
  • 5.
    How did weget here?
  • 6.
    “ There isa vast amount of data available today and data is now being collected and stored at a rate never seen before. Much, if not most, of this data however is locked into specific applications or formats and difficult to access or to integrate into new uses.”  - OData.org
  • 7.
    State of Data& Services Internal SQL My App App Data CMS Share Point Cloud Custom API SQL JSON Services FB
  • 8.
    What is REST?Re presentational S tate T ransfer What is the biggest REST implementation? World Wide Web! REST is NOT a standard! (But it uses standards) HTTP + URLs + XML*
  • 9.
  • 10.
    REST Illustrated MagicKingdom (Resource) http://disneyworld.com/parks/magic-kingdom Resource URL Representation URL Click (State Transfer) Representation
  • 11.
    RESTful Services Coreidea: let's have computers use the web the way humans do
  • 12.
    Alternatives to RESTMost common: SOAP and RPC Why use SOAP (vs REST)? Enterprise security features (WS-Security) ACID Transactions (WS-AtomicTransaction) Message error recovery (WS-ReliableMessaging) SOAP services focus on exposing application logic REST services focus on exposing “data” (or CRUD operations on data)
  • 13.
    OData does for data what REST does for services
  • 14.
    (Finally!) What isOData? HTTP REST-based services AtomPub Data structure JSON Data delivery format Data silo buster
  • 15.
    What do webservices require? A way to discover a service provider A way to discover available services at a provider A way to describe how to interface with service A way to execute functions provided by a service A standard messaging format A way to represent the data in exchange
  • 16.
    Why? Interoperability Predictableaccess to data from any system Gaining popularity SharePoint 2010 SQL Server 2008 R2 IBM WebSphere eXtreme Scale Azure Table Storage Telerik TeamPulse …
  • 17.
    REST AND ODATAIN ACTION DEMO
  • 18.
    Consuming OData WindowsPhone 7 / iPhone / Mobile AJAX / Javascript PHP / Java / .NET Silverlight PowerPivot Simple HTTP Requests (GET, POST, PUT, DELETE) More…
  • 19.
    Visual Studio ToolsOpen Data Protocol Visualizer
  • 20.
  • 21.
    Creating OData ServiceAs simple as returning proper XML/JSON No specific platform requirements Ways to build: Using Visual Studio tools (WCF Data Services) SharePoint Lists Azure Table Storage Manually produce XML
  • 22.
    WCF Data Services(Astoria) Build RESTful services on Microsoft platform Roots of OData protocol Built on WCF Supports ATOM (XML) and JSON data representations Automates REST for data Anything that implements IQueryable<T> or IUpdatable<T> EX: EF, LinqToSQL, 3 rd party ORM, etc.
  • 23.
    WCF DATA SERVICESBASICS DEMO
  • 24.
    Service Operations Functionsexposed by OData Similar to RPC Accept zero or more primitive type input params Can return scalar value [WebGet] is used for an addressable query [WebInvoke] is used for insert, update, and delete http://.../OData.svc/ GetProductsByRating ?rating=5
  • 25.
    Interceptors Query InterceptorsLogic runs when resource is requested Uses: limit the data viewed, log, perform security check Change Interceptors Logic runs when a change (Add/Edit/Delete) request is made (HTTP PUT/POST/DELETE)
  • 26.
    SERVICE OPS &INTERCEPTORS DEMO
  • 27.
    Securing Data ServicesRemember! REST is NOT a protocol, it’s a pattern Same security that applies to HTTP, AtomPub, JSON Other options: EntitySetRights Hiding sensitive data with [IgnoreProperties] Infrastructure security – SSL, IP Filtering QueryInterceptors
  • 28.
    OData & SharePoint2010 ListData.svc Out-of-the-box OData access to SharePoint data Data is NOT anonymously available! http://siteurl /_vti_bin/listdata.svc /Announcements
  • 29.
    When to REST?Stateless web services Scalable web services (via HTTP caching) Mutually understood context (OData) Restricted bandwidth (Mobile) Always, except when there is a reason NOT to REST
  • 30.
    [Q & A]Thanks! Gracias! Mersi! Blagodarya! @toddanglin telerikwatch.com [email_address]