SlideShare a Scribd company logo
1 of 52
WCF & ASP.NET Web API – An
Architect’s Primer
 Presented at Southern California .NET Architecture User
  Group; Feb 21st 2013.




Adnan Masood MS (CS). MCSD. MCPD.
Software Architect & Doctoral Candidate
blog.AdnanMasood.com
adnan.masood@owasp.org
About Me
Adnan Masood works as a system architect / technical lead for Green dot
Corporation where he develops SOA based middle-tier
architectures, distributed systems, and web-applications using
Microsoft technologies. He is a Microsoft Certified Trainer holding several
technical certifications, including MCPD (Enterprise Developer), MCSD
.NET, and SCJP-II. Adnan is attributed and published in print media and
on the Web; he also teaches Windows Communication Foundation (WCF)
courses at the University of California at San Diego and regularly presents
at local code camps and user groups. He is actively involved in the .NET
community as cofounder and president of the of San Gabriel Valley .NET
Developers group.

Adnan holds a Master’s degree in Computer Science; he is currently a
doctoral student working towards PhD in Machine Learning; specifically
discovering interestingness measures in outliers using Bayesian Belief
Networks. He also holds systems architecture certification from MIT and
SOA Smarts certification from Carnegie Melon University.
Abstract
WCF vs. ASP.NET Web API – An Architect’s Primer

ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a
broad range of clients, including browsers and mobile devices. The new ASP.NET Web
API is a continuation of the previous WCF Web API projection. WCF was originally
created to enable SOAP-based services and other related bindings. However, for simpler
RESTful or RPCish services (think clients like jQuery) ASP.NET Web API is a good
choice.

In this meeting we discuss what do you need to understand as an architect to implement
your service oriented architecture using WCF or ASP.NET web API. With code
samples, we will elaborate on WCF Web API’s transition to ASP.NET Web API and
respective constructs such as Service vs. Web API controller, Operation vs. Action, URI
templates vs ASP.NET Routing, Message handlers, Formatters and Operation handlers vs
Filters, model binders. WebApi offers support for modern HTTP programming model with
full support for ASP.NET Routing, content negotiation and custom formatters, model
binding and validation, filters, query composition, is easy to unit test and offers improved
Inversion of Control (IoC) via DependencyResolver.
Agenda
 Difference between Web API and WCF REST Services
 How to Migrate from WCF Web API to ASP.NET Web API
 Model for RESTFul Maturity
 WCF or Web API – confusing?
 WCF evolution and strengths
 What ASP.NET Web API brings to the table?
 Architectures and comparing non functional requirements
Architectural Questions
 What is the purpose of the WebAPIs?
 Why do we need REST HTTP services? What’s wrong with
  SOAP-over-HTTP?
 Why did the WebAPIs move from WCF to ASP.NET MVC?
 Is there still a use for WCF? When should I choose Web APIs
  over WCF?
History of Web Services
  1989 - Tim Berners-Lee invents HTTP/HTML
  1998 - XML 1.0, SOAP begins ratification
  2001 - SOAP standard
  2000 - Fielding dissertation on REST
History of SOAP
Before SOAP we did this…
  HTTP GET/POST with Plain Old XML (POX)
  Out-of-band exchange of DTD or schema
SOAP evolved to provide us
  Specifications
  Tooling
  Metadata
  Productivity
  location transparency
Tools Evolution
 ASP.NET Web Services (ASMX)
 Web Services Enhancements (WSE)
 •.NET 3.0 => WCF = SOAP+WS*
 •.NET 3.5 => WCF = SOAP+WS*/ HTTP
 WebHttpBinding, contract attributes, JSON
 •REST Starter Kit (Codeplex)
 •WCF 4 => Features from starter kit
 •WCF Web API => ASP.NET Web API
SignalR
 What is ASP.NET SignalR
 ASP.NET SignalR is a new library for ASP.NET developers that makes it
  incredibly simple to add real-time web functionality to your applications.
  What is "real-time web" functionality? It's the ability to have your server-
  side code push content to the connected clients as it happens, in real-
  time.
 You may have heard of WebSockets, a new HTML5 API that enables bi-
  directional communication between the browser and server. SignalR will
  use WebSockets under the covers when it's available, and gracefully
  fallback to other techniques and technologies when it isn't, while your
  application code stays the same.
 SignalR also provides a very simple, high-level API for doing server to
  client RPC (call JavaScript functions in your clients' browsers from
  server-side .NET code) in your ASP.NET application, as well as adding
  useful hooks for connection management, e.g. connect/disconnect
  events, grouping connections, authorization.
The WCF Web API => ASP.NET
Web API
 WCF Web API -> ASP.NET Web API
 Service -> Web API controller
 Operation -> Action
 Service contract -> Not applicable
 Endpoint -> Not applicable
 URI templates -> ASP.NET Routing
 Message handlers -> Same
 Formatters -> Same
 Operation handlers -> Filters, model binders
Integrated stack
 Modern HTTP programming model
 Full support for ASP.NET Routing
 Content negotiation and custom formatters
 Model binding and validation
 Filters
 Query composition
 Easy to unit test
 Improved Inversion of Control (IoC) via DependencyResolver
 Code-based configuration
 Self-host
SOAP
 Simple Object Access Protocol
 Uses a standard XML Schema over HTTP
 Extremely cross platform compatible
 Extremely Slow
REST
 Representable State Transfer
 Uses standard HTTP
 Can use any text format including XML
XML vs JSON
  XML tag based document formatting
  Javascript Notation by Douglas Crockford
  JSON less verbose than XML, more lightweight
  Mobile devices have limited bandwidth
Public APIs
  Twitter
  Facebook
  Flickr
  Amazon
  iTunes
WebAPI
  Available now as Nuget Package
  Built-in as part of MVC 4
  Take advantage of HTTP features directly
Default route will use http method for action
  Controller/action/id
  API/Controller/id GET/POST/PUT/DELETE




HTTP methods as Actions
HTTP Method meanings
  Get - Return an existing document
  Post - Create a new document
  Put - Update a document
  Delete - Self explanatory
Configure Transport
  Set Xml or JSON based on Content-Type or Accept
  header
  Accept: application/xml
  Can also use Odata
Return Codes
  Now have the ability to specify return codes beside 200
  HttpResponseMessage<YourEntity>
  HttpStatusCode.Created 201
  response.Headers.Location = new Uri()
Http Status codes
  201 Created
  200 Success/204 Success but No Content
  403 Not authorized
  404 Does not exist
  500 Server Error
  301 Uri Moved
Security
  [Authorize()]
  https over port 443
  Security Tokens
  OAuth
Testing WebAPI
  Download Fiddler2
  Firebug (Firefox)
  Chrome
  On Mac use CocoaRestClient
Consuming WebAPI
  Web Apps
  (ASP.NET, MVC, PHP, Java, ColdFusion, Ruby(Rails), Pyt
  hon, Perl(if you are masochistic))
  JavaScript/JQuery
  Mobile (iOS, Android, WP7, Blackberry OS)
Develop WebAPI and iOS on
Same Computer
  Parallels or VMWare
  Set Network Adapter to Bridged
  Run Visual Studio as Administrator
  Host on IIS (do not use IIS Express or Casini)
Consuming WebAPI
in iOS
  Use NSURLConnection delegate or GCD
  Show progress while waiting on response
  Use JSON over XML
  NSJSONSerialization class (new in iOS 5)
XML Parsing in iOS
  NSXMLParser (Slowest)
  libxml2 (C api)
  TBXML (DOM, Fastest, no write or xpath)
  TouchXML (DOM supports xpath, no write)
  KissXML (based on Touch, can write)
  GDataXML (DOM, from Google)
  RaptureXML (DOM, supports xpath)
Create DefaultHttpClient();
    Create request with HttpGet(Url);
    Create response handler BasicResponseHandler();
    httpClient.execute(request, handler);




Call WebAPI from Android
JSON in Android
  use the JSONObject to parse
  JSONObject jo = new JSONObject(jString);
  jo.getJSONObject(“car”);
  jo.getJSONArray(“cars”);
XML Parsing in Android
  DOM, SAX and Pull
  W3C Dom parser
  Standard Java Sax Parser
  SJXP (Pull parser)
WebAPI as persistence
  Don’t use WebAPI as default persistence on Mobile
  Both Android and iOS have device persistence
  local storage, CoreData and SQLite
  iCloud to sync between iOS devices
Demo




       Slides courtesy Michelle L. Bustamante
Comparison

 Transport Coupling
   HTTP is an application protocol, not just a transport protocol
   TCP, named pipes, MSMQ, UDP are transport only
   WCF is decoupled, message can traverse any
 Performance
   Sometimes a faster protocol/serialization mechanism is needed




                                                   Slides courtesy Michelle L. Bustamante
Security
 Web API
     HTTP Services
     HTTPS / SSL
     Authorization header or custom headers
     OAuth 2.0
 WCF Services
     HTTPS / SSL
     SOAP Message Security
     WS-Trust
     OAuth 2.0

                                               Slides courtesy Michelle L. Bustamante
Error Handling
 Mostly automatic
 Helpful to control how things are returned to Ajax clients
 Setting status code and message




                                                 Slides courtesy Michelle L. Bustamante
Hosting
 IIS or Self hosting




                        Slides courtesy Michelle L. Bustamante
Feature Comparison
 Productivity
     Design effort
     Complexity
     Client code and proxy generation
     Communication stack
 State
   Both should be stateless
   Caching
   Built in to HTTP, but beware
The WS* Overload




                   Slides courtesy Michelle L. Bustamante
SOAP vs REST – Focus on the
necessities




                      Slide courtesy Michelle L. Bustamante
Web API Selling Points
 If we need a Web Service and don’t need SOAP, then ASP.Net
  Web API is very useful.
 Web API - Used to build simple, non-SOAP-based HTTP Services
  on top of existing WCF message pipeline.
 Web API - No need for configurable like WCF REST services
 Web API - No need for Data contracts
 Web API - Could create fully blown REST Services
 Simple service creation with Web API. With WCF REST
  Services, service creation is difficult.
 WCF is any wire protocol. Web API is focused at one thing, being
  easy to define and expose and consume, while also facilitating
  doing things in a RESTful way.
 Web API is light weight architecture.
The hypermedia Venn Diagram
The unified model? Kinda, sorta
Obsolete
Revision - WCF to ASP.NET Web
API
   ApiController (!=Controller, no common BaseClass)
   ASP.NET Routing (MapHttpRoute)
   Convention over Configuration
   Web API to go / NuGet Packages
   Web API hosted in ASP.NET: AspNetWebApi
   Self-hosted Web API: AspNetWebApi.Selfhost
   HttpClient including XML and JSON formatters:
   System.Net.Http.Formatting
     JsonValue for navigating and manipulating JSON:
 System.Json
 Go Live License
How to Migrate from WCF Web
API to ASP.NET Web API
 http://wcf.codeplex.com/wikipage?title=How%20to%20Migrate
  %20from%20WCF%20Web%20API%20to%20ASP.NET%20
  Web%20API
Competing with Node.JS?
Resources & Credits
   http://www.asp.net/web-api
   http://blogs.msdn.com/b/henrikn/
    http://weblogs.asp.net/scottgu/archive/tags/Web+API/defa
   ult.aspx
    http://stackoverflow.com/questions/tagged/asp.net-web-api
    https://github.com/ChristianWeyer/Thinktecture.Web.Http
    http://blog.alexonasp.net
    http://aspnet.uservoice.com/forums/147201-webapi/suggestions/2618312-allow-for-
    non-asynchronouscalls-to-the-web-api
   Thanks to Michele Leroux Bustamante’s slide-deck from Windows Azure
    connections, March 26-29, 2012 Las Vegas, NV which I thoroughly enjoyed.
   Ida Flatow’s article on web API http://www.codeproject.com/Articles/341414/WCF-or-
    ASP-NET-Web-APIs-My-two-cents-on-the-subjec
   Alexander Zeitler’s Web API Round up
   David Fekke Web API - www.fekke.com/Media/Default/powerpoint/webapi.ppt
Summary
 Choose wisely and quantitatively; avoiding the shiny object
  syndrome.
 Enterprise WCF implementations will continue to be
  important…
 The trend to HTTP services is here to stay, embrace it
 If you are starting from scratch for a mobile / web heavy
  service, look at HTTP services first
Thank You!
 Adnan Masood
 adnan.masood@owasp.org
   @adnanmasood
  Blog: www.AdnanMasood.com
  Pasadena .NET User Group: www.sgvdotnet.org

More Related Content

What's hot

Web Services - Architecture and SOAP (part 1)
Web Services - Architecture and SOAP (part 1)Web Services - Architecture and SOAP (part 1)
Web Services - Architecture and SOAP (part 1)Martin Necasky
 
Chp3 - Les Services Web
Chp3 - Les Services WebChp3 - Les Services Web
Chp3 - Les Services WebLilia Sfaxi
 
Role based access control
Role based access controlRole based access control
Role based access controlPeter Edwards
 
Appels de procédures distants (RPC)
Appels de procédures distants (RPC)Appels de procédures distants (RPC)
Appels de procédures distants (RPC)Heithem Abbes
 
Tp2 - WS avec JAXRS
Tp2 - WS avec JAXRSTp2 - WS avec JAXRS
Tp2 - WS avec JAXRSLilia Sfaxi
 
iOS Architecture
iOS ArchitectureiOS Architecture
iOS ArchitectureJacky Lian
 
Les web services
Les web servicesLes web services
Les web servicesdihiaselma
 
Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Peter R. Egli
 
Integrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere PortalIntegrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere PortalHimanshu Mendiratta
 
Using Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in RubyUsing Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in RubyLaunchAny
 
Architecture jee principe de inversion de controle et injection des dependances
Architecture jee principe de inversion de controle et injection des dependancesArchitecture jee principe de inversion de controle et injection des dependances
Architecture jee principe de inversion de controle et injection des dependancesENSET, Université Hassan II Casablanca
 
WEB SERVICE SOAP, JAVA, XML, JAXWS
WEB SERVICE SOAP, JAVA, XML, JAXWSWEB SERVICE SOAP, JAVA, XML, JAXWS
WEB SERVICE SOAP, JAVA, XML, JAXWSLhouceine OUHAMZA
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )Ahmed Emad
 
Architecture orientée service (SOA)
Architecture orientée service (SOA)Architecture orientée service (SOA)
Architecture orientée service (SOA)Klee Group
 
Chp2 - Vers les Architectures Orientées Services
Chp2 - Vers les Architectures Orientées ServicesChp2 - Vers les Architectures Orientées Services
Chp2 - Vers les Architectures Orientées ServicesLilia Sfaxi
 

What's hot (20)

Support de cours technologie et application m.youssfi
Support de cours technologie et application m.youssfiSupport de cours technologie et application m.youssfi
Support de cours technologie et application m.youssfi
 
Web Services - Architecture and SOAP (part 1)
Web Services - Architecture and SOAP (part 1)Web Services - Architecture and SOAP (part 1)
Web Services - Architecture and SOAP (part 1)
 
Webservices
WebservicesWebservices
Webservices
 
Chp3 - Les Services Web
Chp3 - Les Services WebChp3 - Les Services Web
Chp3 - Les Services Web
 
Role based access control
Role based access controlRole based access control
Role based access control
 
Appels de procédures distants (RPC)
Appels de procédures distants (RPC)Appels de procédures distants (RPC)
Appels de procédures distants (RPC)
 
Site JEE de ECommerce Basé sur Spring IOC MVC Security JPA Hibernate
Site JEE de ECommerce  Basé sur Spring IOC MVC Security JPA HibernateSite JEE de ECommerce  Basé sur Spring IOC MVC Security JPA Hibernate
Site JEE de ECommerce Basé sur Spring IOC MVC Security JPA Hibernate
 
Tp2 - WS avec JAXRS
Tp2 - WS avec JAXRSTp2 - WS avec JAXRS
Tp2 - WS avec JAXRS
 
iOS Architecture
iOS ArchitectureiOS Architecture
iOS Architecture
 
Les web services
Les web servicesLes web services
Les web services
 
Soap, wsdl et uddi
Soap, wsdl et uddiSoap, wsdl et uddi
Soap, wsdl et uddi
 
Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)Web Services (SOAP, WSDL, UDDI)
Web Services (SOAP, WSDL, UDDI)
 
Support JEE Spring Inversion de Controle IOC et Spring MVC
Support JEE Spring Inversion de Controle IOC et Spring MVCSupport JEE Spring Inversion de Controle IOC et Spring MVC
Support JEE Spring Inversion de Controle IOC et Spring MVC
 
Integrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere PortalIntegrate any Angular Project into WebSphere Portal
Integrate any Angular Project into WebSphere Portal
 
Using Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in RubyUsing Sinatra to Build REST APIs in Ruby
Using Sinatra to Build REST APIs in Ruby
 
Architecture jee principe de inversion de controle et injection des dependances
Architecture jee principe de inversion de controle et injection des dependancesArchitecture jee principe de inversion de controle et injection des dependances
Architecture jee principe de inversion de controle et injection des dependances
 
WEB SERVICE SOAP, JAVA, XML, JAXWS
WEB SERVICE SOAP, JAVA, XML, JAXWSWEB SERVICE SOAP, JAVA, XML, JAXWS
WEB SERVICE SOAP, JAVA, XML, JAXWS
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
 
Architecture orientée service (SOA)
Architecture orientée service (SOA)Architecture orientée service (SOA)
Architecture orientée service (SOA)
 
Chp2 - Vers les Architectures Orientées Services
Chp2 - Vers les Architectures Orientées ServicesChp2 - Vers les Architectures Orientées Services
Chp2 - Vers les Architectures Orientées Services
 

Viewers also liked

ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiTiago Knoch
 
WCF tutorial
WCF tutorialWCF tutorial
WCF tutorialAbhi Arya
 
Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF)Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF)Peter R. Egli
 
C# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTC# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTDr. Awase Khirni Syed
 
The Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIThe Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIEyal Vardi
 
The ASP.NET Web API for Beginners
The ASP.NET Web API for BeginnersThe ASP.NET Web API for Beginners
The ASP.NET Web API for BeginnersKevin Hazzard
 
Overview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB APIOverview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB APIPankaj Bajaj
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web APIhabib_786
 
ASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsIdo Flatow
 
Introduction to ServiceStack
Introduction to ServiceStackIntroduction to ServiceStack
Introduction to ServiceStackmobiweave
 
Resource-Oriented Web Services
Resource-Oriented Web ServicesResource-Oriented Web Services
Resource-Oriented Web ServicesBradley Holt
 
Mysql gdb-101022041146-phpapp01
Mysql gdb-101022041146-phpapp01Mysql gdb-101022041146-phpapp01
Mysql gdb-101022041146-phpapp01Bob Huang
 
Wcf security session 2
Wcf security session 2Wcf security session 2
Wcf security session 2Anil Kumar M
 
Denis Venter-111512819 - Blogging Week 1
Denis Venter-111512819 - Blogging Week 1Denis Venter-111512819 - Blogging Week 1
Denis Venter-111512819 - Blogging Week 1OSA Creative Marketing
 

Viewers also liked (20)

ASP.NET Mvc 4 web api
ASP.NET Mvc 4 web apiASP.NET Mvc 4 web api
ASP.NET Mvc 4 web api
 
WCF tutorial
WCF tutorialWCF tutorial
WCF tutorial
 
Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF)Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF)
 
C# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENTC# ASP.NET WEB API APPLICATION DEVELOPMENT
C# ASP.NET WEB API APPLICATION DEVELOPMENT
 
Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF)Windows Communication Foundation (WCF)
Windows Communication Foundation (WCF)
 
The Full Power of ASP.NET Web API
The Full Power of ASP.NET Web APIThe Full Power of ASP.NET Web API
The Full Power of ASP.NET Web API
 
The ASP.NET Web API for Beginners
The ASP.NET Web API for BeginnersThe ASP.NET Web API for Beginners
The ASP.NET Web API for Beginners
 
Windows Communication Foundation (WCF) Best Practices
Windows Communication Foundation (WCF) Best PracticesWindows Communication Foundation (WCF) Best Practices
Windows Communication Foundation (WCF) Best Practices
 
Overview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB APIOverview of Rest Service and ASP.NET WEB API
Overview of Rest Service and ASP.NET WEB API
 
ASP.NET WEB API
ASP.NET WEB APIASP.NET WEB API
ASP.NET WEB API
 
ASP.NET Web API
ASP.NET Web APIASP.NET Web API
ASP.NET Web API
 
ASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP FundamentalsASP.NET Web API and HTTP Fundamentals
ASP.NET Web API and HTTP Fundamentals
 
WCF
WCFWCF
WCF
 
Introduction to ServiceStack
Introduction to ServiceStackIntroduction to ServiceStack
Introduction to ServiceStack
 
Resource-Oriented Web Services
Resource-Oriented Web ServicesResource-Oriented Web Services
Resource-Oriented Web Services
 
Mysql gdb-101022041146-phpapp01
Mysql gdb-101022041146-phpapp01Mysql gdb-101022041146-phpapp01
Mysql gdb-101022041146-phpapp01
 
Wcf security session 2
Wcf security session 2Wcf security session 2
Wcf security session 2
 
Web 2.0 Trabajo Practico
Web 2.0 Trabajo PracticoWeb 2.0 Trabajo Practico
Web 2.0 Trabajo Practico
 
Denis Venter-111512819 - Blogging Week 1
Denis Venter-111512819 - Blogging Week 1Denis Venter-111512819 - Blogging Week 1
Denis Venter-111512819 - Blogging Week 1
 
Eşşafihu cancer treatment and medicine 8
Eşşafihu  cancer  treatment  and  medicine 8Eşşafihu  cancer  treatment  and  medicine 8
Eşşafihu cancer treatment and medicine 8
 

Similar to Web API or WCF - An Architectural Comparison

A Microsoft primer for PHP devs
A Microsoft primer for PHP devsA Microsoft primer for PHP devs
A Microsoft primer for PHP devsguest0a62e8
 
Scalable Web Architectures and Infrastructure
Scalable Web Architectures and InfrastructureScalable Web Architectures and Infrastructure
Scalable Web Architectures and Infrastructuregeorge.james
 
.Net3.5 Overview
.Net3.5 Overview.Net3.5 Overview
.Net3.5 Overviewllangit
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET PresentationRasel Khan
 
Net35 Overview
Net35 OverviewNet35 Overview
Net35 Overviewllangit
 
Windows Azure AppFabric
Windows Azure AppFabricWindows Azure AppFabric
Windows Azure AppFabricDavid Chou
 
Web development concepts using microsoft technologies
Web development concepts using microsoft technologiesWeb development concepts using microsoft technologies
Web development concepts using microsoft technologiesHosam Kamel
 
Xml web services
Xml web servicesXml web services
Xml web servicesRaghu nath
 
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)Arrow Consulting & Design
 
Best of Microsoft Dev Camp 2015
Best of Microsoft Dev Camp 2015Best of Microsoft Dev Camp 2015
Best of Microsoft Dev Camp 2015Bluegrass Digital
 
Vijay Oscon
Vijay OsconVijay Oscon
Vijay Osconvijayrvr
 
DevNext - Web Programming Concepts Using Asp Net
DevNext - Web Programming Concepts Using Asp NetDevNext - Web Programming Concepts Using Asp Net
DevNext - Web Programming Concepts Using Asp NetAdil Mughal
 
Enterprise Software Architecture
Enterprise Software ArchitectureEnterprise Software Architecture
Enterprise Software Architecturerahmed_sct
 
2014 q3-platform-update-v1.06.johnmathon
2014 q3-platform-update-v1.06.johnmathon2014 q3-platform-update-v1.06.johnmathon
2014 q3-platform-update-v1.06.johnmathonaaronwso2
 
Difference between wcf and asp.net web api
Difference between wcf and asp.net web apiDifference between wcf and asp.net web api
Difference between wcf and asp.net web apiUmar Ali
 

Similar to Web API or WCF - An Architectural Comparison (20)

A Microsoft primer for PHP devs
A Microsoft primer for PHP devsA Microsoft primer for PHP devs
A Microsoft primer for PHP devs
 
Scalable Web Architectures and Infrastructure
Scalable Web Architectures and InfrastructureScalable Web Architectures and Infrastructure
Scalable Web Architectures and Infrastructure
 
.Net3.5 Overview
.Net3.5 Overview.Net3.5 Overview
.Net3.5 Overview
 
sMash_for_zOS-users
sMash_for_zOS-userssMash_for_zOS-users
sMash_for_zOS-users
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 
Net35 Overview
Net35 OverviewNet35 Overview
Net35 Overview
 
Windows Azure AppFabric
Windows Azure AppFabricWindows Azure AppFabric
Windows Azure AppFabric
 
Web development concepts using microsoft technologies
Web development concepts using microsoft technologiesWeb development concepts using microsoft technologies
Web development concepts using microsoft technologies
 
Xml web services
Xml web servicesXml web services
Xml web services
 
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
Getting Started with ASP.NET Core 1.0 (formerly ASP.NET 5)
 
Best of Microsoft Dev Camp 2015
Best of Microsoft Dev Camp 2015Best of Microsoft Dev Camp 2015
Best of Microsoft Dev Camp 2015
 
Owin & katana
Owin & katanaOwin & katana
Owin & katana
 
Vijay Oscon
Vijay OsconVijay Oscon
Vijay Oscon
 
DevNext - Web Programming Concepts Using Asp Net
DevNext - Web Programming Concepts Using Asp NetDevNext - Web Programming Concepts Using Asp Net
DevNext - Web Programming Concepts Using Asp Net
 
Enterprise Software Architecture
Enterprise Software ArchitectureEnterprise Software Architecture
Enterprise Software Architecture
 
2014 q3-platform-update-v1.06.johnmathon
2014 q3-platform-update-v1.06.johnmathon2014 q3-platform-update-v1.06.johnmathon
2014 q3-platform-update-v1.06.johnmathon
 
Running PHP In The Cloud
Running PHP In The CloudRunning PHP In The Cloud
Running PHP In The Cloud
 
Windows Azure
Windows AzureWindows Azure
Windows Azure
 
WCF And ASMX Web Services
WCF And ASMX Web ServicesWCF And ASMX Web Services
WCF And ASMX Web Services
 
Difference between wcf and asp.net web api
Difference between wcf and asp.net web apiDifference between wcf and asp.net web api
Difference between wcf and asp.net web api
 

More from Adnan Masood

Spark with Azure HDInsight - Tampa Bay Data Science - Adnan Masood, PhD
Spark with Azure HDInsight  - Tampa Bay Data Science - Adnan Masood, PhDSpark with Azure HDInsight  - Tampa Bay Data Science - Adnan Masood, PhD
Spark with Azure HDInsight - Tampa Bay Data Science - Adnan Masood, PhDAdnan Masood
 
Data science with Windows Azure - A Brief Introduction
Data science with Windows Azure - A Brief IntroductionData science with Windows Azure - A Brief Introduction
Data science with Windows Azure - A Brief IntroductionAdnan Masood
 
Restructuring Technical Debt - A Software and System Quality Approach
Restructuring Technical Debt - A Software and System Quality ApproachRestructuring Technical Debt - A Software and System Quality Approach
Restructuring Technical Debt - A Software and System Quality ApproachAdnan Masood
 
System Quality Attributes for Software Architecture
System Quality Attributes for Software ArchitectureSystem Quality Attributes for Software Architecture
System Quality Attributes for Software ArchitectureAdnan Masood
 
Agile Software Development
Agile Software DevelopmentAgile Software Development
Agile Software DevelopmentAdnan Masood
 
Belief Networks & Bayesian Classification
Belief Networks & Bayesian ClassificationBelief Networks & Bayesian Classification
Belief Networks & Bayesian ClassificationAdnan Masood
 
Bayesian Networks and Association Analysis
Bayesian Networks and Association AnalysisBayesian Networks and Association Analysis
Bayesian Networks and Association AnalysisAdnan Masood
 
Probabilistic Interestingness Measures - An Introduction with Bayesian Belief...
Probabilistic Interestingness Measures - An Introduction with Bayesian Belief...Probabilistic Interestingness Measures - An Introduction with Bayesian Belief...
Probabilistic Interestingness Measures - An Introduction with Bayesian Belief...Adnan Masood
 
Bayesian Networks - A Brief Introduction
Bayesian Networks - A Brief IntroductionBayesian Networks - A Brief Introduction
Bayesian Networks - A Brief IntroductionAdnan Masood
 
SOLID Principles of Refactoring Presentation - Inland Empire User Group
SOLID Principles of Refactoring Presentation - Inland Empire User GroupSOLID Principles of Refactoring Presentation - Inland Empire User Group
SOLID Principles of Refactoring Presentation - Inland Empire User GroupAdnan Masood
 
Brief bibliography of interestingness measure, bayesian belief network and ca...
Brief bibliography of interestingness measure, bayesian belief network and ca...Brief bibliography of interestingness measure, bayesian belief network and ca...
Brief bibliography of interestingness measure, bayesian belief network and ca...Adnan Masood
 

More from Adnan Masood (11)

Spark with Azure HDInsight - Tampa Bay Data Science - Adnan Masood, PhD
Spark with Azure HDInsight  - Tampa Bay Data Science - Adnan Masood, PhDSpark with Azure HDInsight  - Tampa Bay Data Science - Adnan Masood, PhD
Spark with Azure HDInsight - Tampa Bay Data Science - Adnan Masood, PhD
 
Data science with Windows Azure - A Brief Introduction
Data science with Windows Azure - A Brief IntroductionData science with Windows Azure - A Brief Introduction
Data science with Windows Azure - A Brief Introduction
 
Restructuring Technical Debt - A Software and System Quality Approach
Restructuring Technical Debt - A Software and System Quality ApproachRestructuring Technical Debt - A Software and System Quality Approach
Restructuring Technical Debt - A Software and System Quality Approach
 
System Quality Attributes for Software Architecture
System Quality Attributes for Software ArchitectureSystem Quality Attributes for Software Architecture
System Quality Attributes for Software Architecture
 
Agile Software Development
Agile Software DevelopmentAgile Software Development
Agile Software Development
 
Belief Networks & Bayesian Classification
Belief Networks & Bayesian ClassificationBelief Networks & Bayesian Classification
Belief Networks & Bayesian Classification
 
Bayesian Networks and Association Analysis
Bayesian Networks and Association AnalysisBayesian Networks and Association Analysis
Bayesian Networks and Association Analysis
 
Probabilistic Interestingness Measures - An Introduction with Bayesian Belief...
Probabilistic Interestingness Measures - An Introduction with Bayesian Belief...Probabilistic Interestingness Measures - An Introduction with Bayesian Belief...
Probabilistic Interestingness Measures - An Introduction with Bayesian Belief...
 
Bayesian Networks - A Brief Introduction
Bayesian Networks - A Brief IntroductionBayesian Networks - A Brief Introduction
Bayesian Networks - A Brief Introduction
 
SOLID Principles of Refactoring Presentation - Inland Empire User Group
SOLID Principles of Refactoring Presentation - Inland Empire User GroupSOLID Principles of Refactoring Presentation - Inland Empire User Group
SOLID Principles of Refactoring Presentation - Inland Empire User Group
 
Brief bibliography of interestingness measure, bayesian belief network and ca...
Brief bibliography of interestingness measure, bayesian belief network and ca...Brief bibliography of interestingness measure, bayesian belief network and ca...
Brief bibliography of interestingness measure, bayesian belief network and ca...
 

Recently uploaded

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingThe Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingSelcen Ozturkcan
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 

Recently uploaded (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central BankingThe Evolution of Money: Digital Transformation and CBDCs in Central Banking
The Evolution of Money: Digital Transformation and CBDCs in Central Banking
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 

Web API or WCF - An Architectural Comparison

  • 1. WCF & ASP.NET Web API – An Architect’s Primer  Presented at Southern California .NET Architecture User Group; Feb 21st 2013. Adnan Masood MS (CS). MCSD. MCPD. Software Architect & Doctoral Candidate blog.AdnanMasood.com adnan.masood@owasp.org
  • 2. About Me Adnan Masood works as a system architect / technical lead for Green dot Corporation where he develops SOA based middle-tier architectures, distributed systems, and web-applications using Microsoft technologies. He is a Microsoft Certified Trainer holding several technical certifications, including MCPD (Enterprise Developer), MCSD .NET, and SCJP-II. Adnan is attributed and published in print media and on the Web; he also teaches Windows Communication Foundation (WCF) courses at the University of California at San Diego and regularly presents at local code camps and user groups. He is actively involved in the .NET community as cofounder and president of the of San Gabriel Valley .NET Developers group. Adnan holds a Master’s degree in Computer Science; he is currently a doctoral student working towards PhD in Machine Learning; specifically discovering interestingness measures in outliers using Bayesian Belief Networks. He also holds systems architecture certification from MIT and SOA Smarts certification from Carnegie Melon University.
  • 3. Abstract WCF vs. ASP.NET Web API – An Architect’s Primer ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. The new ASP.NET Web API is a continuation of the previous WCF Web API projection. WCF was originally created to enable SOAP-based services and other related bindings. However, for simpler RESTful or RPCish services (think clients like jQuery) ASP.NET Web API is a good choice. In this meeting we discuss what do you need to understand as an architect to implement your service oriented architecture using WCF or ASP.NET web API. With code samples, we will elaborate on WCF Web API’s transition to ASP.NET Web API and respective constructs such as Service vs. Web API controller, Operation vs. Action, URI templates vs ASP.NET Routing, Message handlers, Formatters and Operation handlers vs Filters, model binders. WebApi offers support for modern HTTP programming model with full support for ASP.NET Routing, content negotiation and custom formatters, model binding and validation, filters, query composition, is easy to unit test and offers improved Inversion of Control (IoC) via DependencyResolver.
  • 4. Agenda  Difference between Web API and WCF REST Services  How to Migrate from WCF Web API to ASP.NET Web API  Model for RESTFul Maturity  WCF or Web API – confusing?  WCF evolution and strengths  What ASP.NET Web API brings to the table?  Architectures and comparing non functional requirements
  • 5. Architectural Questions  What is the purpose of the WebAPIs?  Why do we need REST HTTP services? What’s wrong with SOAP-over-HTTP?  Why did the WebAPIs move from WCF to ASP.NET MVC?  Is there still a use for WCF? When should I choose Web APIs over WCF?
  • 6. History of Web Services 1989 - Tim Berners-Lee invents HTTP/HTML 1998 - XML 1.0, SOAP begins ratification 2001 - SOAP standard 2000 - Fielding dissertation on REST
  • 7. History of SOAP Before SOAP we did this…  HTTP GET/POST with Plain Old XML (POX)  Out-of-band exchange of DTD or schema SOAP evolved to provide us  Specifications  Tooling  Metadata  Productivity  location transparency
  • 8. Tools Evolution  ASP.NET Web Services (ASMX)  Web Services Enhancements (WSE)  •.NET 3.0 => WCF = SOAP+WS*  •.NET 3.5 => WCF = SOAP+WS*/ HTTP  WebHttpBinding, contract attributes, JSON  •REST Starter Kit (Codeplex)  •WCF 4 => Features from starter kit  •WCF Web API => ASP.NET Web API
  • 9.
  • 10.
  • 11. SignalR  What is ASP.NET SignalR  ASP.NET SignalR is a new library for ASP.NET developers that makes it incredibly simple to add real-time web functionality to your applications. What is "real-time web" functionality? It's the ability to have your server- side code push content to the connected clients as it happens, in real- time.  You may have heard of WebSockets, a new HTML5 API that enables bi- directional communication between the browser and server. SignalR will use WebSockets under the covers when it's available, and gracefully fallback to other techniques and technologies when it isn't, while your application code stays the same.  SignalR also provides a very simple, high-level API for doing server to client RPC (call JavaScript functions in your clients' browsers from server-side .NET code) in your ASP.NET application, as well as adding useful hooks for connection management, e.g. connect/disconnect events, grouping connections, authorization.
  • 12. The WCF Web API => ASP.NET Web API  WCF Web API -> ASP.NET Web API  Service -> Web API controller  Operation -> Action  Service contract -> Not applicable  Endpoint -> Not applicable  URI templates -> ASP.NET Routing  Message handlers -> Same  Formatters -> Same  Operation handlers -> Filters, model binders
  • 13. Integrated stack  Modern HTTP programming model  Full support for ASP.NET Routing  Content negotiation and custom formatters  Model binding and validation  Filters  Query composition  Easy to unit test  Improved Inversion of Control (IoC) via DependencyResolver  Code-based configuration  Self-host
  • 14.
  • 15. SOAP Simple Object Access Protocol Uses a standard XML Schema over HTTP Extremely cross platform compatible Extremely Slow
  • 16. REST Representable State Transfer Uses standard HTTP Can use any text format including XML
  • 17. XML vs JSON XML tag based document formatting Javascript Notation by Douglas Crockford JSON less verbose than XML, more lightweight Mobile devices have limited bandwidth
  • 18. Public APIs Twitter Facebook Flickr Amazon iTunes
  • 19. WebAPI Available now as Nuget Package Built-in as part of MVC 4 Take advantage of HTTP features directly
  • 20. Default route will use http method for action Controller/action/id API/Controller/id GET/POST/PUT/DELETE HTTP methods as Actions
  • 21. HTTP Method meanings Get - Return an existing document Post - Create a new document Put - Update a document Delete - Self explanatory
  • 22. Configure Transport Set Xml or JSON based on Content-Type or Accept header Accept: application/xml Can also use Odata
  • 23. Return Codes Now have the ability to specify return codes beside 200 HttpResponseMessage<YourEntity> HttpStatusCode.Created 201 response.Headers.Location = new Uri()
  • 24. Http Status codes 201 Created 200 Success/204 Success but No Content 403 Not authorized 404 Does not exist 500 Server Error 301 Uri Moved
  • 25. Security [Authorize()] https over port 443 Security Tokens OAuth
  • 26. Testing WebAPI Download Fiddler2 Firebug (Firefox) Chrome On Mac use CocoaRestClient
  • 27. Consuming WebAPI Web Apps (ASP.NET, MVC, PHP, Java, ColdFusion, Ruby(Rails), Pyt hon, Perl(if you are masochistic)) JavaScript/JQuery Mobile (iOS, Android, WP7, Blackberry OS)
  • 28. Develop WebAPI and iOS on Same Computer Parallels or VMWare Set Network Adapter to Bridged Run Visual Studio as Administrator Host on IIS (do not use IIS Express or Casini)
  • 29. Consuming WebAPI in iOS Use NSURLConnection delegate or GCD Show progress while waiting on response Use JSON over XML NSJSONSerialization class (new in iOS 5)
  • 30. XML Parsing in iOS NSXMLParser (Slowest) libxml2 (C api) TBXML (DOM, Fastest, no write or xpath) TouchXML (DOM supports xpath, no write) KissXML (based on Touch, can write) GDataXML (DOM, from Google) RaptureXML (DOM, supports xpath)
  • 31. Create DefaultHttpClient(); Create request with HttpGet(Url); Create response handler BasicResponseHandler(); httpClient.execute(request, handler); Call WebAPI from Android
  • 32. JSON in Android use the JSONObject to parse JSONObject jo = new JSONObject(jString); jo.getJSONObject(“car”); jo.getJSONArray(“cars”);
  • 33. XML Parsing in Android DOM, SAX and Pull W3C Dom parser Standard Java Sax Parser SJXP (Pull parser)
  • 34. WebAPI as persistence Don’t use WebAPI as default persistence on Mobile Both Android and iOS have device persistence local storage, CoreData and SQLite iCloud to sync between iOS devices
  • 35. Demo Slides courtesy Michelle L. Bustamante
  • 36. Comparison  Transport Coupling  HTTP is an application protocol, not just a transport protocol  TCP, named pipes, MSMQ, UDP are transport only  WCF is decoupled, message can traverse any  Performance  Sometimes a faster protocol/serialization mechanism is needed Slides courtesy Michelle L. Bustamante
  • 37. Security  Web API  HTTP Services  HTTPS / SSL  Authorization header or custom headers  OAuth 2.0  WCF Services  HTTPS / SSL  SOAP Message Security  WS-Trust  OAuth 2.0 Slides courtesy Michelle L. Bustamante
  • 38. Error Handling  Mostly automatic  Helpful to control how things are returned to Ajax clients  Setting status code and message Slides courtesy Michelle L. Bustamante
  • 39. Hosting  IIS or Self hosting Slides courtesy Michelle L. Bustamante
  • 40. Feature Comparison  Productivity  Design effort  Complexity  Client code and proxy generation  Communication stack  State  Both should be stateless  Caching  Built in to HTTP, but beware
  • 41. The WS* Overload Slides courtesy Michelle L. Bustamante
  • 42. SOAP vs REST – Focus on the necessities Slide courtesy Michelle L. Bustamante
  • 43. Web API Selling Points  If we need a Web Service and don’t need SOAP, then ASP.Net Web API is very useful.  Web API - Used to build simple, non-SOAP-based HTTP Services on top of existing WCF message pipeline.  Web API - No need for configurable like WCF REST services  Web API - No need for Data contracts  Web API - Could create fully blown REST Services  Simple service creation with Web API. With WCF REST Services, service creation is difficult.  WCF is any wire protocol. Web API is focused at one thing, being easy to define and expose and consume, while also facilitating doing things in a RESTful way.  Web API is light weight architecture.
  • 44.
  • 46. The unified model? Kinda, sorta Obsolete
  • 47. Revision - WCF to ASP.NET Web API  ApiController (!=Controller, no common BaseClass)  ASP.NET Routing (MapHttpRoute)  Convention over Configuration  Web API to go / NuGet Packages  Web API hosted in ASP.NET: AspNetWebApi  Self-hosted Web API: AspNetWebApi.Selfhost  HttpClient including XML and JSON formatters:  System.Net.Http.Formatting  JsonValue for navigating and manipulating JSON:  System.Json  Go Live License
  • 48. How to Migrate from WCF Web API to ASP.NET Web API  http://wcf.codeplex.com/wikipage?title=How%20to%20Migrate %20from%20WCF%20Web%20API%20to%20ASP.NET%20 Web%20API
  • 50. Resources & Credits  http://www.asp.net/web-api  http://blogs.msdn.com/b/henrikn/  http://weblogs.asp.net/scottgu/archive/tags/Web+API/defa  ult.aspx  http://stackoverflow.com/questions/tagged/asp.net-web-api  https://github.com/ChristianWeyer/Thinktecture.Web.Http  http://blog.alexonasp.net  http://aspnet.uservoice.com/forums/147201-webapi/suggestions/2618312-allow-for- non-asynchronouscalls-to-the-web-api  Thanks to Michele Leroux Bustamante’s slide-deck from Windows Azure connections, March 26-29, 2012 Las Vegas, NV which I thoroughly enjoyed.  Ida Flatow’s article on web API http://www.codeproject.com/Articles/341414/WCF-or- ASP-NET-Web-APIs-My-two-cents-on-the-subjec  Alexander Zeitler’s Web API Round up  David Fekke Web API - www.fekke.com/Media/Default/powerpoint/webapi.ppt
  • 51. Summary  Choose wisely and quantitatively; avoiding the shiny object syndrome.  Enterprise WCF implementations will continue to be important…  The trend to HTTP services is here to stay, embrace it  If you are starting from scratch for a mobile / web heavy service, look at HTTP services first
  • 52. Thank You! Adnan Masood adnan.masood@owasp.org @adnanmasood  Blog: www.AdnanMasood.com  Pasadena .NET User Group: www.sgvdotnet.org