DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report

Detecting OData Service Version

Lohith Nagaraj user avatar by
Lohith Nagaraj
·
Apr. 19, 12 · Interview
Like (0)
Save
Tweet
Share
5.26K Views

Join the DZone community and get the full member experience.

Join For Free

overview:

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:

image

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:

image


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:

image

image


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
image
- 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.
image


conclusion:

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.

Web Service

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Steel Threads Are a Technique That Will Make You a Better Engineer
  • Monolithic First
  • DevOps for Developers: Continuous Integration, GitHub Actions, and Sonar Cloud
  • Introduction to Spring Cloud Kubernetes

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: