OData, Oh My!

March 30, 2011 at 1:05 pm | Posted in Microsoft, Technical Tips, Uncategorized | 1 Comment
Tags: , , , , , , , ,

Slogging through .NET 4 certification path, I am happy to find Microsoft adopt even more open standards. As open standards become more popular, the ideal of developing application logic and ignoring the plumbing details seems likes more of a possible reality. Well, a programmer can dream, right?

Anyway, one of these open standards is OData. WCF Data Services, formerly known as ADO.NET Data Services, uses the Open Data Protocol (OData) to expose data through addressable URIs, similar to REST (representational state transfer) services. OData supports both Atom and Json (JavaScript Object Notation) formats for the payload.

Okay, so again, what is OData? It’s a simple HTTP mechanism for accessing data. For example, let’s say that I have an application and want to retrieve all titles provided by Netflix that contain the notorious actor Charlie Sheen. Using OData, you can just type in the following URL:

http://odata.netflix.com/Catalog/People?$filter=Name eq ‘Charlie Sheen’&$expand=TitlesActedIn

If you are using IE, then you need to turn off feed reading view to see the results. Go to Internet Options and under the Content tab, click the Settings button in the Feeds and Web Slices section. Turn off reading view by unchecking the Turn on feed reading view checkbox.

Go ahead, try it. (Yeah, I forgot he was in Platoon, too.) What this query does is access the People set, filter it to a single actor and include the related Titles set. The $filter and $expand are keywords that limit entries and include related entries, respectively.

Let’s say that you like to listen to music while at work and want to retrieve all awesome live concerts available for instant streaming. Then, you would type a URL similar to this one:

http://odata.netflix.com/Catalog/Genres(‘Must-See Concerts’)/Titles?$filter=Instant/Available eq true&$select=Name,Synopsis

In this case, we choose the Titles set from the Genre “Must-See Concerts.” Notice the $select keyword is used to limit the entry properties to only the name and synopsis.

Okay, enough hand-holding. Try it out for yourself. Netflix has some more examples and eBay even has its own OData implementation.  So there’s the plumbing; I’ll let you move on to creating the applications!

1 Comment »

RSS feed for comments on this post. TrackBack URI

  1. […] RESTful Web services are those that use traditional HTTP, rather than SOAP protocols. Speaking of protocols, OData is becoming a big player in REST, especially in regards to catalogs such as Netflix and eBay. For more information on how it works, you can revisit my previous article (OData, Oh My). […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.
Entries and comments feeds.

%d bloggers like this: