350 likes | 714 Views
WCF The Unified Services Programming Model for SOAP, REST, Data and RIA Communication. Ron Jacobs Sr. Program Manager, AppFabric Development Platform (WCF/WF) Microsoft Corporation http://blogs.msdn.com/rjacobs @ ronljacobs. What you wanted. What you got. What you need. WCF.
E N D
WCF The Unified Services Programming Model for SOAP, REST, Data and RIA Communication Ron Jacobs Sr. Program Manager, AppFabric Development Platform (WCF/WF) Microsoft Corporation http://blogs.msdn.com/rjacobs @ronljacobs
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,…)
WCF SOAP Services (made easy in .NET 4) 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,…)
WCF Workflow Services http://channel9.msdn.com/Shows/Endpoint/endpointtv-WF4--AppFabric-Contoso-HR-Sample 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,…)
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; } }
WCF Data Services http://bit.ly/bTKZNz 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; } }
Step 1 – Create Service • public class Session • { • public SessionData[] GetSessions(int start, int count) • { • } • public SessionData GetSession(string id) • { • } • }
Step 2 – Implement Service • public class Session • { • public SessionData[] GetSessions(int start, int count) • { • return ConferenceRepository.GetSessions(start, count); • } • public SessionDataGetSession(string id) • { • return ConferenceRepository.GetSession(id); • } • }
Step 3 – Attribute for WCF • [ServiceContract] • [AspNetCompatibilityRequirements( • RequirementsMode = AspNetCompatibilityRequirementsMode.Required)] • public class Session • { • }
Step 3 – Attribute for WCF • [WebGet] • public SessionDataGetSession(string id) • { • return ConferenceRepository.GetSession(id); • } HTTP GET = “~/Sessions/GetSession?id=123”
Step 3 – Attribute for WCF • [WebGet(UriTemplate = "/{id}")] • public SessionDataGetSession(string id) • { • return ConferenceRepository.GetSession(id); • } HTTP GET = “~/Sessions/123”
Step 3 – Attribute for WCF • [WebGet(UriTemplate = "/?skip={skip}&take={take}")] • public SessionData[] GetSessions(int skip, int take) • { • return ConferenceRepository.GetSessions( • AdjustSkip(skip), • AdjustTake(take)); • } HTTP GET = “~/Sessions?skip=5&take=7”
Step 4 – Add Routes • void Application_Start(object sender, EventArgs e) • { • RouteTable.Routes.Add( • new ServiceRoute("Sessions", • new WebServiceHostFactory(), • typeof(SessionService))); • } No .SVC file!
Step 5 – Configure <system.serviceModel> <standardEndpoints> <webHttpEndpoint> <standardEndpoint automaticFormatSelectionEnabled="true" helpEnabled="true" /> </webHttpEndpoint> </standardEndpoints> <serviceHostingEnvironmentaspNetCompatibilityEnabled="true" /> </system.serviceModel>
WCF WebHTTP Services http://code.msdn.microsoft.com/WebHTTPAPIKey demo
Canonical REST Entity Service http://code.msdn.microsoft.com/cannonicalRESTEntity demo
Talk to us • http://facebook.com/AppFabric • Twitter: @appfabric, @ronljacobs • Email: appfabric@microsoft.com
Podcasts • http://endpoint.tv • Coming soon • AppFabric Radio • Dialog with us live • Twitter • Facebook • Email
Q&A • New WCF HTTP bits available on CodePlex • ASI201-LNC - Windows Workflow Foundation Futures • Thursday Lunch 1:20p • Stay Informed • http://endpoint.tv – our video podcast • http://blogs.msdn.com/endpoint - team blog • http://blogs.msdn.com/rjacobs - my blog • http://msdn.microsoft.com/wcf - WCF Developer Center • http://wcf.codeplex.com – WCF on CodePlex • @appfabric, @ronljacobs – Twitter / Facebook
Session Evaluations Tell us what you think, and you could win! All evaluations submitted are automatically entered into a daily prize draw* Sign-in to the Schedule Builder at http://europe.msteched.com/topic/list/ * Details of prize draw rules can be obtained from the Information Desk.
© 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.