1 / 30

RESTful Services for the Programmable Web with Windows Communication Foundation

RESTful Services for the Programmable Web with Windows Communication Foundation. Ron Jacobs Sr. Technical Evangelist Microsoft Corporation. Why the Web Works. Simple and open Addressing scheme – URI Application protocol – HTTP Representation Format – (X)HTML Response codes – HTTP status

blake
Télécharger la présentation

RESTful Services for the Programmable Web with Windows Communication Foundation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. RESTful Services for the Programmable Web with Windows Communication Foundation Ron Jacobs Sr. Technical Evangelist Microsoft Corporation

  2. Why the Web Works • Simple and open • Addressing scheme – URI • Application protocol – HTTP • Representation Format – (X)HTML • Response codes – HTTP status • Scales best when • Stateless • Cached • It works because people find value in it

  3. question How do we move from a web of pages to a web of services?

  4. The Web of Services should work the way the Web of Pages works

  5. RESTfullness HI-REST LO-REST URI HTTP verbs Semantics Formats

  6. SOAP/WS-* Industrial Strength Complex Powerful Difficult Specifications

  7. REST Simple Light Weight Good Enough Less Functional Freedom

  8. REST WCF SOAP

  9. annoucing WCF REST Starter Kit http://tinyurl.com/wcfRESTsk

  10. WCF REST Starter Kit • Visual Studio 2008 templates • Caching • Security • Help page • Client library • Codeplex Project supported by WCF team • Features may be rolled into .NET 4.0

  11. demo Consuming Twitter

  12. Resources

  13. Define Your Resource • public class SessionData • { • public string ID { get; set; } • public string Title { get; set; } • public string Speaker { get; set; } • }

  14. Resource Format • Content negotiation • Allow the client to ask for the format they want • text/xml • Supported (default) • application/json • Supported • Methods • .xml, .json • Query parameter ?format=json • Accept Header

  15. URI Resources

  16. Resource URI

  17. Service URI Resources

  18. Session Service • public class Session • { • SessionDataGetSession(string id) • { • return _sessions[id]; • } • }

  19. WCF Service • [ServiceContract] • public class Session • { • [OperationContract] • SessionDataGetSession(string id) • { • return _sessions[id]; • } • } Note: This is a SOAP Service

  20. WCF REST Service • [ServiceContract] • public class Session • { • [OperationContract] • [WebGet] • SessionDataGetSession(string id) • { • return _sessions[id]; • } • } Address http://localhost/Session.svc/GetSession?id=123

  21. WCF Service • [ServiceContract] • public class Session • { • [OperationContract] • [WebGet(UriTemplate="session/{id}"] • SessionDataGetSession(string id) • { • return _sessions[id]; • } • } Address http://localhost/Session.svc/session/123

  22. Session.svc • <%@ ServiceHost • Language="C#" • Debug="true" • Service="Conference.Session" • CodeBehind="Session.svc.cs" • Factory="System.ServiceModel.Activation. • WebServiceHostFactory" • %> No <System.ServiceModel> in web.config!

  23. demo Session Service

  24. Future Help Page

  25. Microsoft Confidential No SVC Configuration • <configuration> • <system.serviceModel>     • <serviceHostingEnvironment> • <serviceActivations> • <add virtualPath="~/wines” • factory= • "System.ServiceModel.Activation. • WebServiceHostFactory” service=“CohoWinery.Wines"/>

  26. What Now? • Download the WCF REST Starter Kit • http://msdn.microsoft.com/wcf/rest • Download the REST Starter Kit Labs • http://code.msdn.microsoft.com/wcfrestlabs • Give it a try

  27. © 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.

More Related