OData Access to TFS

Brian Harry

  I’m criminally late in blogging about this and for that I apologize.  Several months ago, the Microsoft platform evangelism team came to me and said they wanted to create a really good OData sample that would show people all the stuff you can do with OData and how easy it is.  They told me that they thought creating an OData service running on Windows Azure and providing a public data feed for TFS on CodePlex would make for a great sample.  They asked it I had any objections.  Of course, I said no; that sounds like a great idea.  A few months ago they published the service and now I’d like to tell you a little about it. OData is a convenient protocol for managing structured data.  It’s a relatively simple XML format that’s easy to parse and there are a lot of tools that already understand it.  It’s something we’ve been looking at for a while to add to TFS and I was glad to see this experiment.  It will give us valuable learning for when we bite off adding it as an official part of the product. Having OData feeds is particularly useful in constrained environments (like phones) where you don’t have as complete a software stack as you might on a server for desktop machine.  The simplicity of the protocol/data format is a real advantage.  In creating the OData sample, the evangelism team created a Window Phone 7 app to demonstrate how easy it is to use OData in that context. If you just want to kick the tires, then you can get access to or create a CodePlex project and use the Azure hosted TFS OData service against it.  It’s really simple.  You can just type urls in the browser and see the feed results.  Here’s the url to the Codeplex OData service.  The initial page tells you everything you need to know about getting started: https://codeplexodata.cloudapp.net/ Here’s an example from a CodePlex project I have access to.  Here’s the url I typed in the browser: https://codeplexodata.cloudapp.net/TFS01/Projects(‘tfsadmin’)/Changesets And here’s the results that come back:

vstfs:///VersionControl/Changeset/83047

‎Sunday, ‎January ‎09, ‎2011, ‏‎6:15:32 AM

Fixed Team Foundation Server object model error message during setup

vstfs:///VersionControl/Changeset/82090

‎Sunday, ‎December ‎19, ‎2010, ‏‎8:51:18 AM

TFS Administration Tool 2.1 release branch

vstfs:///VersionControl/Changeset/81133

‎Saturday, ‎December ‎04, ‎2010, ‏‎10:59:55 AM

Updated version number and fixed a minor bug. Getting ready for release.

vstfs:///VersionControl/Changeset/76570

‎Saturday, ‎August ‎28, ‎2010, ‏‎10:46:46 AM

Added tracing information to SharePoint and Reporting Services detection

truncated for brevity…

And here’s what the XML looks like:

<?xml version=”1.0″ encoding=”utf-8″ standalone=”yes”?>
<feed xml:base=”https://codeplexodata.cloudapp.net/TFS01/” xmlns:d=”http://schemas.microsoft.com/ado/2007/08/dataservices” xmlns:m=”http://schemas.microsoft.com/ado/2007/08/dataservices/metadata” xmlns=”http://www.w3.org/2005/Atom”>
  <title type=”text”>Changesets</title>
  <id>https://codeplexodata.cloudapp.net/TFS01/Projects(‘tfsadmin’)/Changesets/</id>
  <updated>2011-07-05T01:21:28Z</updated>
  <link rel=”self” title=”Changesets” href=”Changesets” />
  <entry m:etag=”W/&quot;datetime’2011-01-09T11%3A15%3A32.7%2B00%3A00’&quot;”>
    <id>https://codeplexodata.cloudapp.net/TFS01/Changesets(83047)</id>
    <title type=”text”>vstfs:///VersionControl/Changeset/83047</title>
    <summary type=”text”>Fixed Team Foundation Server object model error message during setup</summary>
    <updated>2011-01-09T11:15:32Z</updated>
    <author>
      <name />
    </author>
    <link rel=”edit” title=”Changeset” href=”Changesets(83047)” />
    <link rel=”http://schemas.microsoft.com/ado/2007/08/dataservices/related/Changes” type=”application/atom+xml;type=feed” title=”Changes” href=”Changesets(83047)/Changes” />
    <link rel=”http://schemas.microsoft.com/ado/2007/08/dataservices/related/WorkItems” type=”application/atom+xml;type=feed” title=”WorkItems” href=”Changesets(83047)/WorkItems” />
    <category term=”Microsoft.Samples.DPE.ODataTFS.Model.Entities.Changeset” scheme=”http://schemas.microsoft.com/ado/2007/08/dataservices/scheme” />
    <content type=”application/xml”>
      <m:properties>
        <d:Id m:type=”Edm.Int32″>83047</d:Id>
        <d:ArtifactUri>vstfs:///VersionControl/Changeset/83047</d:ArtifactUri>
        <d:Comment>Fixed Team Foundation Server object model error message during setup</d:Comment>
        <d:Committer>SND\lszomoru_cp</d:Committer>
        <d:CreationDate m:type=”Edm.DateTime”>2011-01-09T11:15:32.7+00:00</d:CreationDate>
        <d:Owner>SND\lszomoru_cp</d:Owner>
        <d:Branch m:null=”true” />
        <d:WebEditorUrl>https://tfs.codeplex.com/tfs/web/cs.aspx?pcguid=81e6e737-5a20-4d0f-a97c-cb01297b46e0&amp;cs=83047</d:WebEditorUrl>
      </m:properties>
    </content>
  </entry>
  <entry m:etag=”W/&quot;datetime’2010-12-19T13%3A51%3A18.317%2B00%3A00’&quot;”>
    <id>https://codeplexodata.cloudapp.net/TFS01/Changesets(82090)</id>
    <title type=”text”>vstfs:///VersionControl/Changeset/82090</title>
    <summary type=”text”>TFS Administration Tool 2.1 release branch</summary>
    <updated>2010-12-19T13:51:18Z</updated>
    <author>
      <name />
    </author>
    <link rel=”edit” title=”Changeset” href=”Changesets(82090)” />
    <link rel=”http://schemas.microsoft.com/ado/2007/08/dataservices/related/Changes” type=”application/atom+xml;type=feed” title=”Changes” href=”Changesets(82090)/Changes” />
    <link rel=”http://schemas.microsoft.com/ado/2007/08/dataservices/related/WorkItems” type=”application/atom+xml;type=feed” title=”WorkItems” href=”Changesets(82090)/WorkItems” />
    <category term=”Microsoft.Samples.DPE.ODataTFS.Model.Entities.Changeset” scheme=”http://schemas.microsoft.com/ado/2007/08/dataservices/scheme” />
    <content type=”application/xml”>
      <m:properties>
        <d:Id m:type=”Edm.Int32″>82090</d:Id>
        <d:ArtifactUri>vstfs:///VersionControl/Changeset/82090</d:ArtifactUri>
        <d:Comment>TFS Administration Tool 2.1 release branch</d:Comment>
        <d:Committer>SND\lszomoru_cp</d:Committer>
        <d:CreationDate m:type=”Edm.DateTime”>2010-12-19T13:51:18.317+00:00</d:CreationDate>
        <d:Owner>SND\lszomoru_cp</d:Owner>
        <d:Branch m:null=”true” />
        <d:WebEditorUrl>https://tfs.codeplex.com/tfs/web/cs.aspx?pcguid=81e6e737-5a20-4d0f-a97c-cb01297b46e0&amp;cs=82090</d:WebEditorUrl>
      </m:properties>
    </content>
  </entry>
  <entry m:etag=”W/&quot;datetime’2010-12-04T15%3A59%3A55.183%2B00%3A00’&quot;”>
    <id>https://codeplexodata.cloudapp.net/TFS01/Changesets(81133)</id>
    <title type=”text”>vstfs:///VersionControl/Changeset/81133</title>
    <summary type=”text”>Updated version number and fixed a minor bug. Getting ready for release.</summary>
    <updated>2010-12-04T15:59:55Z</updated>
    <author>
      <name />
    </author>
    <link rel=”edit” title=”Changeset” href=”Changesets(81133)” />
    <link rel=”http://schemas.microsoft.co m/ado/2007/08/dataservices/related/Changes” type=”application/atom+xml;type=feed” title=”Changes” href=”Changesets(81133)/Changes” />
    <link rel=”http://schemas.microsoft.com/ado/2007/08/dataservices/related/WorkItems” type=”application/atom+xml;type=feed” title=”WorkItems” href=”Changesets(81133)/WorkItems” />
    <category term=”Microsoft.Samples.DPE.ODataTFS.Model.Entities.Changeset” scheme=”http://schemas.microsoft.com/ado/2007/08/dataservices/scheme” />
    <content type=”application/xml”>
      <m:properties>
        <d:Id m:type=”Edm.Int32″>81133</d:Id>
        <d:ArtifactUri>vstfs:///VersionControl/Changeset/81133</d:ArtifactUri>
        <d:Comment>Updated version number and fixed a minor bug. Getting ready for release.</d:Comment>
        <d:Committer>SND\lszomoru_cp</d:Committer>
        <d:CreationDate m:type=”Edm.DateTime”>2010-12-04T15:59:55.183+00:00</d:CreationDate>
        <d:Owner>SND\lszomoru_cp</d:Owner>
        <d:Branch m:null=”true” />
        <d:WebEditorUrl>https://tfs.codeplex.com/tfs/web/cs.aspx?pcguid=81e6e737-5a20-4d0f-a97c-cb01297b46e0&amp;cs=81133</d:WebEditorUrl>
      </m:properties>
    </content>
  </entry>
</feed>

Again, snipped for brevity…

If you want to see a sample client or if you want to set up the service to point at your own TFS server (rather than CodePlex), you can use this download: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=13576 Brian Keller put together a great video showing how use use this stuff: https://channel9.msdn.com/Blogs/briankel/OData-Service-for-Team-Foundation-Server-2010 I need adjust/clarify a few of the things in his intro.  OData is a very cool way to access TFS – because it is lightweight and there are a lot of tools that already support it.  This particular implementation is terrific for simple TFS browsing applications – show me a list of my work items, show me recent build status, etc.  It is not the same thing as the TFS object model – which not only provides access to the TFS server but also provides quite a lot of TFS client logic for managing workspaces, etc.  Further, we now provide both .NET and Java versions of the TFS object model, making it available from virtually any platform you choose.  Lastly, I want to comment on “support” of the TFS web services.  They are supported.  We’ve had 3rd parties use them and we’ve supported them.  We don’t change them willy nilly because we provide backwards compatibility between new TFS servers and old object model implementations.  It is true that we discourage people from using the web services directly.  They are much harder to use than the client object model (and much harder to use than OData).  There is very little documentation on them – not because we don’t believe in it but rather because we just haven’t gotten to it.  At some point in the future, I expect we’ll move our web services from SOAP to REST, at which point we’ll probably put in the effort to document them. I’m aware of one project where someone has picked up the OData support here built a more serious phone app.  It’s called TFS On The Road and is available for free.  Go to the WP7 Marketplace and check it out.  Here are a few screenshots of it: And you can read about Pedro’s experience building it here: http://pcbl.de/ Anyway enjoy playing with the OData service for TFS and let me know what you think of it.

Brian

0 comments

Discussion is closed.

Feedback usabilla icon