1 / 40

Implementing RESTful Services Using the Microsoft .NET Framework

Required Slide. SESSION CODE: DEV202. Implementing RESTful Services Using the Microsoft .NET Framework . Ron Jacobs Technical Evangelist Microsoft Corporation http://blogs.msdn.com/rjacobs. Experience. Share, explore, question my world With others When and how I want Even right now

miyo
Download Presentation

Implementing RESTful Services Using the Microsoft .NET Framework

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. Required Slide SESSION CODE: DEV202 Implementing RESTful Services Using the Microsoft .NET Framework Ron Jacobs Technical Evangelist Microsoft Corporation http://blogs.msdn.com/rjacobs

  2. Experience Share, explore, question my world With others When and how I want Even right now On whatever device I have at hand

  3. How do we move from a PC oriented experience to a multi-device experience? question

  4. Services Drive Experiences data

  5. Services Drive Experiences Services

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

  7. WCF Programming Model SOAPServices Web HTTP Services Data Services RIA Services Workflow Services Service Model Data Contract Service Contract Service Behavior Channel Model Formats (Atom, JSON, XML,…) Transports (HTTP, TCP, …) Protocols (SOAP, HTTP, Open Data Protocol,…)

  8. WCF Programming Model SOAPServices Web HTTP Services Data Services RIA Services Workflow Services Service Model Data Contract Service Contract Service Behavior Channel Model Formats (Atom, JSON, XML,…) Transports (HTTP, TCP, …) Protocols (SOAP, HTTP, Open Data Protocol,…)

  9. Model

  10. Service publicclassConference: DataService<ConferenceDataEntities> { // This method is called only once to initialize service-wide policies. publicstaticvoidInitializeService(DataServiceConfigurationconfig) { config.SetEntitySetAccessRule("*", EntitySetRights.AllRead); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2; } }

  11. Data Services demo

  12. Implications • Fast and Easy • REST over Model (backed by Database) • Also supports Services • Power to the caller

  13. Constrain publicclassConference: DataService<ConferenceDataEntities> { // This method is called only once to initialize service-wide policies. publicstaticvoidInitializeService(DataServiceConfigurationconfig) { config.SetEntitySetAccessRule("*", EntitySetRights.AllRead); config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2; config.SetEntitySetPageSize("Sessions", 10); config.SetEntitySetPageSize("Speakers", 5); } }

  14. Route privatevoidRegisterRoutes() { DataServiceHostFactory factory = newDataServiceHostFactory(); RouteTable.Routes.Add( newServiceRoute("Conference", factory, typeof(Conference))); }

  15. Routed Data Services demo

  16. WCF Programming Model SOAPServices Web HTTP Services Data Services RIA Services Workflow Services Service Model Data Contract Service Contract Service Behavior Channel Model Formats (Atom, JSON, XML,…) Transports (HTTP, TCP, …) Protocols (SOAP, HTTP, Open Data Protocol,…)

  17. Three Steps to build a WebHttp Service

  18. Resource publicclassSessionData { publicint ID { get; set; } publicstring Title { get; set; } publicDateTime? Date { get; set; } publicstring Speaker { get; set; } }

  19. Three Steps to build a WebHttp Service

  20. Resource URI

  21. Three Steps to build a WebHttp Service

  22. Web HTTP Services demo

  23. Step 1 – Create Service

  24. Step 2 – Implement Service

  25. Step 3 – Attribute for WCF

  26. Step 3 – Attribute for WCF HTTP GET = “~/Sessions/GetSession?id=123”

  27. Step 3 – Attribute for WCF HTTP GET = “~/Sessions/123”

  28. Step 3 – Attribute for WCF HTTP GET = “~/Sessions?start=5&count=7”

  29. Step 4 – Add Routes publicclassGlobal : System.Web.HttpApplication { voidApplication_Start(object sender, EventArgs e) { RegisterRoutes(); } privatevoidRegisterRoutes() { WebServiceHostFactory factory = newWebServiceHostFactory(); RouteTable.Routes.Add( newServiceRoute("Sessions", factory, typeof(SessionService))); } } No .SVC file!

  30. Step 5 – Configure <system.serviceModel> <standardEndpoints> <webHttpEndpoint> <standardEndpoint automaticFormatSelectionEnabled="true" helpEnabled="true" /> </webHttpEndpoint> </standardEndpoints> <serviceHostingEnvironmentaspNetCompatibilityEnabled="true" /> </system.serviceModel>

  31. .NET 4 Web HTTP Services demo

  32. Incarnate

  33. WF4 Coordination

  34. Required Slide Speakers, please list the Breakout Sessions, Interactive Sessions, Labs and Demo Stations that are related to your session. Related Content • ASI312 | What's New in Windows Communication Foundation in .NET Framework 4 • DEV303 | Building RESTful Applications with the Open Data Protocol

  35. Required Slide Track PMs will supply the content for this slide, which will be inserted during the final scrub. Track Resources • Visual Studio – http://www.microsoft.com/visualstudio/en-us/ • Soma’s Blog – http://blogs.msdn.com/b/somasegar/ • MSDN Data Developer Center – http://msdn.com/data • ADO.NET Team Blog – http://blogs.msdn.com/adonet • WCF Data Services Team Blog – http://blogs.msdn.com/astoriateam • EF Design Blog – http://blogs.msdn.com/efdesign

  36. Required Slide Resources Learning • Sessions On-Demand & Community • Microsoft Certification & Training Resources www.microsoft.com/teched www.microsoft.com/learning • Resources for IT Professionals • Resources for Developers • http://microsoft.com/technet • http://microsoft.com/msdn

  37. Required Slide Complete an evaluation on CommNet and enter to win!

  38. Sign up for Tech·Ed 2011 and save $500 starting June 8 – June 31st http://northamerica.msteched.com/registration You can also register at the North America 2011 kiosk located at registrationJoin us in Atlanta next year

  39. © 2010 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.

  40. Required Slide

More Related