{{ !articles[0].partner.isSponsoringArticle ? "Platinum" : "Portal" }} Partner

Detecting OData Service Version


Recently, on Apr 9 2012 Microsoft released WCF Data Service 5.0 RTM. As part of this new release there is whole new plethora of features that comes into OData. Here is the official release blog post from the WCF Data Services Team http://blogs.msdn.com/b/astoriateam/archive/2012/04/09/wcf-data-services-5-0-rtm-release.aspx.

What I wanted to do was – to try out the spatial capability that now comes into V3 of OData. I was playing around with a service and wanted to know what service version it is supporting. Thus this blog post so that if anybody else has the same inquisitiveness, read till the end.

OData Service Identification Rules:

Before we actually look at the ways, lets understand some of the Rules which have been defined as part of the protocol itself that makes a Service – OData Service. If you head over to the following URL, complete rules have been posted there: http://services.odata.org/validation/roadmap.htm#rules.

Rules which are in question to detect the OData Service Versions are as follows:


As you can see a OData Service must have the DataServiceVersion attribute in the metadata and in an element <edmx:DataServices>. Now that we know the rule, lets see how we can identify the Service Version in various ways.

Ways to check the Version:

I found 4 ways to find version of an OData Service. They are:

  • Looking at the metadata of the OData Service
  • Using Fiddler
  • Using Internet Explorer

We will look at one by one in coming sections.

OData Service Metadata Check:

Every OData Service must describe its Data Model using what is known as Service Metadata Document. The Metadata Document describes its data model in EDM format using XML language for describing models called Conceptual Schema Definition Language (CSDL). The metadata of a OData Service is accessible by appending $metadata to the service root URI. For e.g. Netflix OData Service is found at http://odata.netflix.com/v2/catalog/. So to know the metadata we need to append the $metadata string to the end of the URI i.e. http://odata.netflix.com/v2/catalog/$metadata

So open a browser of your choice and issue a request to http://odata.netflix.com/v2/catalog/$metadata. You will be presented with the metadata. Look out for edmx:DataServices element. It should contain a attribute DataServiceVersion. And that will be the version of the OData Service. Below is a screenshot of the same:


Inspecting Response Header Using Fiddler:

In previous section we saw how to find out the Data Service Version using metadata. In this section we will use Fiddler a HTTP debugging tool to inspect the response headers from a Data Service and figure out the version.

- First, open Fiddler and select Composer tab (will be on the right side).
- In the Parsed tab, provide the URL Netflix OData without the $metadata string i.e. type http://odata.netflix.com/v2/catalog/.
- Next click on execute to set the request.
- In the left hand side you will see web sessions and our request will be listed with a status of 200 which means success. Double click on the entry.
- In the right hand side you will see Request and Response Details.
- In the bottom section of the right hand side, select Headers. Those will be the Response Headers.
- If you go through the headers we will see a Response Header by name DataServiceVersion. The value of this header will identify the Data Service Version

Here is a screen shot of the same:



Inspecting Response Header Using Internet Explorer 9:

Internet Explorer 9 comes with a handy & nifty tools called Developer Tools. This has a new feature which will allow you to capture Network interaction on a web page. So we will make use of this feature and try to figure out the DataServiceVersion response header.

- Open Internet Explorer 9 & navigate to http://odata.netflix.com/v2/Catalog/
- Press F12 to get the developer tools
- Select Network tab & click on start capturing
- Refresh the page
- The network interaction from the page will be captured and shown in the grid below
- Double click the entry
- Select tab named “Response Headers”. This will show a Key-Value pairing of all the response headers. You will see DataServiceVersion as one of the key and its value being shown.


In this blog post I try to touch upon the rules that govern a OData Service. The protocol has a clear cut guidelines for OData Producers as to what they should be doing to identify the service as OData Service. There are many rules which needs to be satisfied if you want to call yourself an OData Service. We looked upon one such rule to identify the Data Service Version. Also it was interesting to note the fact that the same version information is also pushed in Response as an Header. For some clients this may be a easy way to track the version.

Hope this post was useful and you learned something new today.

Till next time, as usual, Happy Coding. Code with Passion, Decode with Patience.

{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks