400 likes | 555 Views
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
E N D
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 On whatever device I have at hand
How do we move from a PC oriented experience to a multi-device experience? question
Services Drive Experiences Services
The Web of Services should work the way the Web of Pages works
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,…)
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,…)
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; } }
Data Services demo
Implications • Fast and Easy • REST over Model (backed by Database) • Also supports Services • Power to the caller
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); } }
Route privatevoidRegisterRoutes() { DataServiceHostFactory factory = newDataServiceHostFactory(); RouteTable.Routes.Add( newServiceRoute("Conference", factory, typeof(Conference))); }
Routed Data Services demo
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,…)
Resource publicclassSessionData { publicint ID { get; set; } publicstring Title { get; set; } publicDateTime? Date { get; set; } publicstring Speaker { get; set; } }
Web HTTP Services demo
Step 3 – Attribute for WCF HTTP GET = “~/Sessions/GetSession?id=123”
Step 3 – Attribute for WCF HTTP GET = “~/Sessions/123”
Step 3 – Attribute for WCF HTTP GET = “~/Sessions?start=5&count=7”
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!
Step 5 – Configure <system.serviceModel> <standardEndpoints> <webHttpEndpoint> <standardEndpoint automaticFormatSelectionEnabled="true" helpEnabled="true" /> </webHttpEndpoint> </standardEndpoints> <serviceHostingEnvironmentaspNetCompatibilityEnabled="true" /> </system.serviceModel>
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
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
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
Required Slide Complete an evaluation on CommNet and enter to win!
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
© 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.