Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.
REST Warsdaniel.fisher@devcoach.com
devcoach.com
BERTAUNG + SCHULUNG + PROJEKTE
• Themen
– Architektur & Technologie Evaluierung,
Performance Optimierung, Ent...
Daniel Fisher
• devcoach.com
– Mit-Gründer und Geschäftsführer
• Justcommunity.de
– Mit-Gründer und Vorstand
• nrwconf.de
...
Efficient Communication…
Agenda
• Introducing REST
• WCF WebHttp
• ASP.NET MVC
• WCF Web API
• Summary
Introducing REST
Introducing REST
Unified Programming Model
Interop
with other
platforms
ASMX
Attribute-
Based
Programming
Enterprise
Services
WS-*
Protocol...
WS-*
Security
Messaging
Reliable
Messaging
Transactions
Metadata
XML
The Microsoft Web PlatformMicrosoftWebPlatform
VisualStudio
ASP.NET Web
Forms
ADO.NET
SQL Server
Internet Information Serv...
Address, Binding & Contract
Caller Service
MessageABC A B C
A B C
Address Binding Contract
(Where) (How) (What)
Address
public class Global : HttpApplication
{
void Application_Start(
object sender,
EventArgs e)
{
RouteTable.Routes.Ad...
Binding
<bindings>
<basicHttpBinding>
<binding
configurationName="Binding1"
hostNameComparisonMode="StrongWildcard"
sendTi...
Contract + Address (parts)
[ServiceContract]
public interface ISessionPlaner
{
[WebGet(UriTemplate = "Sessions")]
List<Ses...
Automatic Format Selection
<system.serviceModel>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint
name=""
automatic...
Extensibility
public class MyBehavior
: WebHttpBehavior
{
}
public class MyClientFormatter
: IClientMessageFormatter
{
}
p...
Extensibility
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="SomeName">
<myExtension />
</behavior>...
Extensibility Client
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="SomeName">
<myExtension />
</be...
The Microsoft Web PlatformMicrosoftWebPlatform
VisualStudio
ASP.NET Web
Forms
ADO.NET
SQL Server
Internet Information Serv...
ASP.NET ArchitectureApplicationPool
ASP.NET(HttpRuntime)
HttpApplication
Application_Start
Application_End
Application_Err...
Controller
Model
View
1
2
3
4
Uri
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.M...
Functionality
using System.Web.Mvc;
…
public class HomeController : Controller
{
[HttpGet]
public ActionResult About()
{
r...
Extensibility
public class MyFilterAttribute
: ActionFilterAttribute
{
public override void OnActionExecuting(
ActionExecu...
Extensibility
public class ModelResult<T>
: ActionResult
{
public override void ExecuteResult(
ControllerContext context)
...
New Message Types
• HttpResponseMessage, JsonValue
Extensibility
public class MyFormatter
: MediaTypeFormatter
{
}
public class MyChannel
: DelegatingChannel
{
}
Extensibility
protected void Application_Start(object sender, EventArgs e)
{
var config =
HttpHostConfiguration.Create().
...
Summary
• WCF 4.0 WebHTTP
– Released with the .NET Framework.
– Easy to start with REST, if you already have WCF
in the ho...
Summary
• ASP.NET MVC
– Version 3.0 released as separate Product.
– Easy to start with REST, if you know any Web-
Platform...
Summary
• WCF 4.0 WebAPIHTTP
– Currently a Preview Release.
– Easy to adopt from the WCF perspective.
– Advanced goals can...
Resources
• WCF 4.0 WebHTTP
– Part of the Platform
• http://www.microsoft.com/downloads/en/details.aspx?FamilyID=0a3
91abd...
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
2011 - DNC: REST Wars
Prochain SlideShare
Chargement dans…5
×

2011 - DNC: REST Wars

REST Wars: ASP.NET MVC vs WCF

  • Soyez le premier à commenter

  • Soyez le premier à aimer ceci

2011 - DNC: REST Wars

  1. 1. REST Warsdaniel.fisher@devcoach.com
  2. 2. devcoach.com BERTAUNG + SCHULUNG + PROJEKTE • Themen – Architektur & Technologie Evaluierung, Performance Optimierung, Entwicklungs- Unterstützung, Security Reviews, QA, POC & Know-how-Transfer • Technologien – Services: WCF & WF – Data: ADO.NET & EF – Web: ASP.NET, MVC & Silverlight • Kunden – Versicherung, Finanzindustrie, Mittelstand, Handel, Kommunikation, Softwarehersteller… Und sie? • Kontakt – info@devcoach.com
  3. 3. Daniel Fisher • devcoach.com – Mit-Gründer und Geschäftsführer • Justcommunity.de – Mit-Gründer und Vorstand • nrwconf.de – Mit-Gründer und Organisator • netug-niederrhein.de – Mit-Gründer und Leiter • microsoft.com – Community Leader & Insider (CLIP) – Certified Professional Developer – Business Platform Technology Advisor • lennybacon.com – Blog • twitter.com – @lennybacon
  4. 4. Efficient Communication…
  5. 5. Agenda • Introducing REST • WCF WebHttp • ASP.NET MVC • WCF Web API • Summary
  6. 6. Introducing REST
  7. 7. Introducing REST
  8. 8. Unified Programming Model Interop with other platforms ASMX Attribute- Based Programming Enterprise Services WS-* Protocol Support WSE Message- Oriented Programming System.Messaging Extensibility Location transparency .NET Remoting
  9. 9. WS-* Security Messaging Reliable Messaging Transactions Metadata XML
  10. 10. The Microsoft Web PlatformMicrosoftWebPlatform VisualStudio ASP.NET Web Forms ADO.NET SQL Server Internet Information Services ASP.NET MVC Silverlight MsAjax jQuery WCF
  11. 11. Address, Binding & Contract Caller Service MessageABC A B C A B C Address Binding Contract (Where) (How) (What)
  12. 12. Address public class Global : HttpApplication { void Application_Start( object sender, EventArgs e) { RouteTable.Routes.Add( new ServiceRoute( string.Empty, new WebServiceHostFactory(), typeof(SessionPlanerService))); } }
  13. 13. Binding <bindings> <basicHttpBinding> <binding configurationName="Binding1" hostNameComparisonMode="StrongWildcard" sendTimeout="00:10:00" maxMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" </binding> </basicHttpBinding> </bindings>
  14. 14. Contract + Address (parts) [ServiceContract] public interface ISessionPlaner { [WebGet(UriTemplate = "Sessions")] List<SessionDetail> GetAllSessions(); }
  15. 15. Automatic Format Selection <system.serviceModel> <standardEndpoints> <webHttpEndpoint> <standardEndpoint name="" automaticFormatSelectionEnabled="true"> <security mode="None"/>
  16. 16. Extensibility public class MyBehavior : WebHttpBehavior { } public class MyClientFormatter : IClientMessageFormatter { } public class MyDispatchFormatter : IDispatchMessageFormatter { } public class MyEndpointBehavior : BehaviorExtensionElement , IEndpointBehavior { }
  17. 17. Extensibility <system.serviceModel> <behaviors> <endpointBehaviors> <behavior name="SomeName"> <myExtension /> </behavior> </endpointBehaviors> </behaviors> <services> <service name="Service"> <endpoint address="" binding="basicHttpBinding" contract="IService" behaviorConfiguration="SomeName"/> </service> </services> <extensions> <behaviorExtensions> <add name="myExtension" type="devcoach.ServiceModel.SomeEndpointBehavior, devcoach.ServiceModel, …"/> </behaviorExtensions> </extensions> </system.serviceModel>
  18. 18. Extensibility Client <system.serviceModel> <behaviors> <endpointBehaviors> <behavior name="SomeName"> <myExtension /> </behavior> </endpointBehaviors> </behaviors> <client> <endpoint name="SomeEntpointName" address="" binding="basicHttpBinding" contract="IService" behaviorConfiguration="SomeName"/> </client> <extensions> <behaviorExtensions> <add name="myExtension" type="devcoach.ServiceModel.SomeEndpointBehavior, devcoach.ServiceModel, …"/> </behaviorExtensions> </extensions> </system.serviceModel>
  19. 19. The Microsoft Web PlatformMicrosoftWebPlatform VisualStudio ASP.NET Web Forms ADO.NET SQL Server Internet Information Services ASP.NET MVC Silverlight MsAjax jQuery WCF
  20. 20. ASP.NET ArchitectureApplicationPool ASP.NET(HttpRuntime) HttpApplication Application_Start Application_End Application_Error … HttpContext RequestModules HttpHandler Begin_Request ResponseModules Authenticate_Request … UpdateRequestCache PostRequest HandlerExecuted … KernelCache
  21. 21. Controller Model View 1 2 3 4
  22. 22. Uri public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", // if parameter not in URL action = "Index", // if parameter not in URL id = UrlParameter.Optional } // Parameter defaults ); }
  23. 23. Functionality using System.Web.Mvc; … public class HomeController : Controller { [HttpGet] public ActionResult About() { return WhateverResult(); } }
  24. 24. Extensibility public class MyFilterAttribute : ActionFilterAttribute { public override void OnActionExecuting( ActionExecutingContext filterContext) { // Before... } public override void OnActionExecuted( ActionExecutedContext filterContext) { // After... } }
  25. 25. Extensibility public class ModelResult<T> : ActionResult { public override void ExecuteResult( ControllerContext context) { var r = context.HttpContext.Response; r.Write(…); } }
  26. 26. New Message Types • HttpResponseMessage, JsonValue
  27. 27. Extensibility public class MyFormatter : MediaTypeFormatter { } public class MyChannel : DelegatingChannel { }
  28. 28. Extensibility protected void Application_Start(object sender, EventArgs e) { var config = HttpHostConfiguration.Create(). AddFormatters(new MyFormatter()). AddMessageHandlers(typeof(MyChannel)); SetMappings(); RouteTable.Routes.MapServiceRoute<MyService>("Contact", config); } public void SetMappings() { var mappings = new List<UriExtensionMapping>(); mappings.AddMapping("xml", "application/xml"); SetUriExtensionMappings(mappings); }
  29. 29. Summary • WCF 4.0 WebHTTP – Released with the .NET Framework. – Easy to start with REST, if you already have WCF in the house. – Advanced goals can be reached,but with high effort. – Distance to the Web can be felt.
  30. 30. Summary • ASP.NET MVC – Version 3.0 released as separate Product. – Easy to start with REST, if you know any Web- Platform. – Advanced goals can be easily reached with small effort. – It's the raw Web.
  31. 31. Summary • WCF 4.0 WebAPIHTTP – Currently a Preview Release. – Easy to adopt from the WCF perspective. – Advanced goals can be reached, with less high effort. – Still Abstracted from the web.
  32. 32. Resources • WCF 4.0 WebHTTP – Part of the Platform • http://www.microsoft.com/downloads/en/details.aspx?FamilyID=0a3 91abd-25c1-4fc0-919f-b21f31ab88b7 – Hotfix for jQuery • http://wcf.codeplex.com/ • ASP.NET MVC 3.0 – Released Product • http://www.asp.net/mvc • WCF Web API – CTP 4 • http://wcf.codeplex.com/releases/view/64449

×