Creating a RESTful API with Windows Communication Foundation

1,118 views
1,054 views

Published on

Learn how MySpace used Windows Communication Foundation and .NET 3.5 to rapidly scale up a massive RESTful API infrastructure that process millions of requests a day

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,118
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
23
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Creating a RESTful API with Windows Communication Foundation

  1. 1. Background REST (Representational State Transfer) What does it mean to be RESTful? Why REST? WCF How does WCF support REST? What are the pieces we need to add? Chess A RESTful Chess API
  2. 2. Open Your API – 2005 MySpace API roadmap Where are we today ? developer.myspace.com
  3. 3. Public interface for 3rd party clients and partners to view, add, update, delete data. Easily consumable by any client Follows established industry standards Needs to be highly scalable Supports different data interchange formats Moderately securable
  4. 4. Test’s we did…. WCF REST
  5. 5. What does it mean to be RESTful? Power combo: URI and HTTP Method Addressable, hierarchical URIs represent the entities or objects on your API HTTP Method represents the action to be taken on the resource Connectedness and Discoverability Like the Web, Http Responses contain links to other resources Roy Fielding dissertation http://www.ics.uci.edu/~fielding/pubs/dissert ation/top.htm
  6. 6. Benefits of REST for Web APIs Low barrier of entry ROA follows Web Semantics…convenient for Web Service APIs. Flexibility in Response formats REST is best choice when creating a general API when clients are unknown
  7. 7. The “Web Programming Model” URI Templates & WebGet/WebInvoke Attribute based definitions of URI template and HTTP method provide mapping of incoming request URIs to methods WebHttpBinding The binding that enables above WebOperationContext For more information: Building Applications and Services with .NET Framework 3.5 San Polo 3501A, M10:15 AM March 6th
  8. 8. The 20% Flexible URIs Bridging Low REST clients Request Authentication via Digital Signing Extending WebOperationContext Multiple Representation Formats RESTful Exception Handling
  9. 9. Problems… Service .svc extension Required when hosting a WCF service in IIS Can’t use custom extensions in templates What if I want to let the URI extension define the representation format?
  10. 10. Solutions… Use URL Rewriter implemented as an HttpModule Add .svc service file to incoming request URI Use extension format in path hierarchy and rewrite URI accordingly
  11. 11. High: support for full set of HTTP methods Low: only support GET and POST Allow clients to override HTTP method Using X-HTTPMethodOverride header Use of _method query parameter Extending WCF…Channels to the Rescue
  12. 12. OAuth Introducing OAuth Standards based API authentication Standard access delegation between Consumer and Provider Standard digital signing mechanism oauth.net
  13. 13. OAuth WCF Custom Channels to the rescue again Channel will authenticate request before method dispatch Extend Context with application data
  14. 14. MySpace Development Platform is RESTful WCF is a powerful web API development platform WCF has great extension points All demo source available at RestChess.com MySpace API’s are available Visit developer.myspace.com
  15. 15. © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.

×