There are number of public products or services which have already adopted OData in their data publishing and also provided the OData compatible interfaces for the clients to consume the application data. Microsoft products SharePoint 2010, Windows Azure Storage Service,SQL Server 2008 Reporting Services have started supporting OData. Many online services such as Netflix.com,eBay.com, StackOverflow.com, Facebook etc also opened their business data to consumers through OData-based service endpoints.
This post demonstrates how convenient it is to build OData client applications for connecting the above mentioned services. When you talk about Public OData Producers, Netflix online catalog service will often be mentioned and used as test service to test OData. Netflix is a well-known internet streaming provider that provides distribution services over the world.
The below are the steps to consume the OData-based Netflix Catalog service in a .NET application.
1. Create a new .NET console application as the OData client.
2. Open the Visual Studio Add reference wizard and navigate to the following service address http://odata.netflix.com/v2/Catalog/
3. Expand the service node in the wizard to quickly have a glance on the available entity sets as shown below
4. Define the helper function for creating the data context instance of the OData client proxy
5. Write a function which retrieves first 10 Genre entities from the Netflix catalog service
6. You can achieve the same results as written above by using a raw query Uri string.
Netflix online catalog service is a publicly opened OData end-point which does not demand the client authentication. After generating the client proxy you can then use LINQ expression or raw query URI string to perform OData queries.
Query StackOverflow forums data with OData endpoint
StackOverflow is one of the popular online community site which presents questions and answers on wide range of topics in computer programming. As technical website, they have opened their knowledge database to the public.
Below are the steps to create an ASP.NET web page which shows two chart controls to display the tag and post distribution information by using OData end-point.
1. Create an empty ASP.NET Web application
2. Generate the client proxy for the target OData endpoint http://data.stackexchange.com/stackoverflow/atom
3. Add the below html to your aspx page
4. Below is the piece of code for querying StackOverflow Tags and Posts data in code-behind
5. Bind the above result to chart controls and output as below
Reference: http://www.packtpub.com/open-data-protocol-programming-for-dot-net-developers-cookbook/book In this book you can find more practical examples on OData and I highly recommend you to go through if you are an OData fan.
|Share this post :|