RESTful Services for the Programmable Web with Windows Communication Foundation

1,377 views
1,323 views

Published on

Services are needed to light up the Web, and Windows Communication Foundation (WCF) makes it possible to build RESTful services more quickly and easily than ever before by using the new WCF REST Starter Kit. In this session, we demonstrate using WCF to build a simple REST Service through to advanced REST concepts of Addressability, Scalability, and Security.

Published in: Business, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,377
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
63
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

RESTful Services for the Programmable Web with Windows Communication Foundation

  1. 1. The Web of Services should work the way the Web of Pages works
  2. 2. RESTfullness HI-REST LO-REST URI HTTP verbs Semantics Formats
  3. 3. SOAP/WS-* Industrial Strength Complex Powerful Difficult Specifications
  4. 4. REST Simple Light Weight Good Enough Less Functional Freedom
  5. 5. Resources
  6. 6. public class SessionData { public string ID { get; set; } public string Title { get; set; } public string Speaker { get; set; } }
  7. 7. URI Resources
  8. 8. URI Template HTTP Operation Method Session.svc/ GET Get all sessions Session.svc/{id} GET Get one session Session.svc/ POST Add a new session Session.svc/{id} PUT Update a session Session.svc/{id} DELETE Delete
  9. 9. Service URI Resources
  10. 10. public class Session { SessionData GetSession(string id) { return _sessions[id]; } }
  11. 11. [ServiceContract] public class Session { [OperationContract] SessionData GetSession(string id) { return _sessions[id]; } } Note: This is a SOAP Service
  12. 12. [ServiceContract] public class Session { [OperationContract] [WebGet] SessionData GetSession(string id) { return _sessions[id]; } Address } http://localhost/Session.svc/GetSession?id=123
  13. 13. [ServiceContract] public class Session { [OperationContract] [WebGet(UriTemplate=quot;session/{id}quot;] SessionData GetSession(string id) { return _sessions[id]; } } Address http://localhost/Session.svc/session/123
  14. 14. <%@ ServiceHost Language=quot;C#quot; Debug=quot;truequot; Service=quot;Conference.Sessionquot; CodeBehind=quot;Session.svc.csquot; Factory=quot;System.ServiceModel.Activation. WebServiceHostFactoryquot; %> No <System.ServiceModel> in web.config!
  15. 15. <configuration> <system.serviceModel> <serviceHostingEnvironment> <serviceActivations> <add virtualPath=quot;~/wines” factory= quot;System.ServiceModel.Activation. WebServiceHostFactory” service=“CohoWinery.Winesquot;/> Microsoft Confidential
  16. 16. http://msdn.microsoft.com/wcf/rest http://code.msdn.microsoft.com/wcfrestlabs
  17. 17. © 2009 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.

×