WCF & REST at MIX08: The Tale of MySpace APIs
[Update: we received notice that not all of you were able to download the video . We fixed the issue already friday night, it should work for everybody. Enjoy! Thanks to Terje for the first headsup]
Yesterday we finally had the session about the making of MySpace APIs. As you'll be able to see from the recording, it was a *great* session: extremely interesting and very informative. It had only one issue: Paul Walker, the architect behind the MySpace API efforts and the key person we worked with on the WCF components of the project, couldn't make it to the conference. Paul has a deep, deep understanding of the REST principles and was the one who envisioned how WCF could have been used and extended for meeting MySpace architectural needs. If you'll ever have a chance to attend a session from him or read anything he writes on this topic, I strongly recommend it.
The session was opened by Aaron Sloman, who gave the business background. Back to the very first edition of Mix, MySpace demonstrated some Vista gadgets: the reaction it elicited from the audience was the request of opening the corresponding APIs. Well, just a couple of years later here we are, developer.myspace.com is up and running! Aaron then moved to give the list of requirements for the API of a juggernaut like MySpace, and hinted to the fact that the REST architectural principles and WCF were the solution they found fit for the task after much testing.
The main technical delivery came from Haider Sabri, who was involved in the implementation of the project for the very beginning. I won't go too much on the details, since there is the recording of the session publicly available; anyway, just for wetting your appetite:
- Paul's team created a demo API set, hosted & publicly available at RESTchess.com, inspired to the work that was made for the real MySpace APIs
- All samples demonstrated on stage were extracted from those API. And brace yourself, because that source code is publicly available & donwloadable! You can download it, study it, play with it... and the functions provided are nothing short of amazing. Some of the features that were demonstrated during the session:
- flexible URIs: the guys wrote an URL Rewriter HttpModule, which
- gets rid of the .svc extension from the service URIs, and
- allows to specify the format for the representation by using extension: you can add a trailing ".xml" for getting xml, ".json" for json and so on
- low to high rest bridging: MySpace APIs are full high rest, with inclusive support for PUT, DELETE... and yet, the team wanted to ensure access also for the clients that are unable to use those verbs. To that end they created a custom WCF channel, which recognizes the _method querystring parameter and transforms requests from low rest clients to high rest request, in a way that is completely transparent to the service developer; everything happens at the infrastructure level. That's just GREAT!
- Exception handling: the sample includes a library of custom exceptions, which surfaces the error conditions in a RESTful way: it takes care of setting the correct return code and uses the entity-body for transmitting the exception message back to the requestor. Very handy
- OAuth channel: MySpace decided to adopt OAuth as the authentication mechanism for their APIs. They wanted to shield the developer from having to worry about digital signatures and similar low level considerations: again, they used a custom channel for implementing the functionality. As demonstrated by Haider on stage, now securing a service is as simple as adding a line in the service config file. The OAuth channel code is available in the RESTChess.com sample as well.
- And much more, that could not be shown given the 1:15 mins time constraint
- flexible URIs: the guys wrote an URL Rewriter HttpModule, which
In summary: it was a great session. Watch the video, enjoy the treasure trove of WCF extensions offered with the sample source code, and play with the MySpace APIs!
Comments
Anonymous
March 07, 2008
Well, don't get fooled. I'm not going to make any big philosophical considerations about technology andAnonymous
March 07, 2008
Well, don't get fooled. I'm not going to make any big philosophical considerations about technologyAnonymous
March 12, 2008
As part of the MySpace session at MIX they've put online the code for a sample called RESTchessAnonymous
April 02, 2008
Chuck, in a comment on a previous post , posed this question: Why choose WCF for a REST app? Here itAnonymous
June 01, 2008
I am now focusing exclusively on identity & services, true, but certain news about former interestsAnonymous
October 24, 2008
As part of the MySpace session at MIX they've put online the code for a sample called RESTchess . RESTchess