Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
943
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
23
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. © 2012 MPS Partners.. All rights reserved. Why do you need REST June 27, 2013 Brown Bag presentation by: Mayank Srivastava www.MayankSrivastava.com
  • 2. Agenda o Understanding REST o REST Vs. SOAP o Web API Vs. WCF o Web API features.
  • 3. 3 Interaction over HTTP
  • 4. 4 Interaction over HTTP
  • 5. 5 What is SOAP? • An XML info set based on messaging protocol. • SOAP messages have an envelope, headers and a body • Transport neutral “interoperable” model. • RPC based development approach.
  • 6. 6 What is REST • REST = Representational State Transfer – As introduced by Roy Fielding in 2000 • REST is the architectural style for the Web, to building services hosted and consumed over HTTP. Uniform interface, HTTP Data formats & Content types, client-server, stateless, cacheable, scalable. General Use of terms: RESTful Service  HTTP Service  No SOAP WEB API == HTTP Service == RESTful Service.
  • 7. 7 REST Vs. SOAP • SOAP focuses on verbs (methods) while REST focuses on noun (resource) SOAP: .GetProduct() .UpdateLocations() .DeleteUser() REST: (Uniform Interface HTTP verbs) Product { } Location { } User { } With SOAP you define custom operation that tunnel thru POST SOAP is a message protocol where REST is an architectural design for the web
  • 8. 8 Why REST? • Do you need transport neutrality? • Do you need WS* features? • Benefits of already developed Web features like caching and scalability. • Basic SOAP is just like REST but without the benefits. • Fewer code transition layers • It is the standard for communication in the “cloud”. • Universal interface that everyone understands.
  • 9. 9 Why REST? What about security? All the your Web application supports • Token based • Active directory • OAuth 2.0 Client Server Resource request   Redirect to credential challenge Credentials   Links and tokens to access resource & access token
  • 10. 10 Universal interface that everyone understands. Your RESTful Service
  • 11. 11 Example SOAP message over HTTP POST http://wcftest.azurewebsites.net/Service1.svc HTTP/1.1 Content-Type: application/soap+xml; charset=utf-8; action="http://tempuri.org/IStockTicker/GetQuote" Host: wcftest.azurewebsites.net Content-Length: 168 <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"> <s:Body> <GetQuote xmlns="http://tempuri.org/"> <stockTicker>MSFT</stockTicker> </GetQuote> </s:Body> </s:Envelope> </s:Envelope> ______________________________________________________________________________________________________________________ HTTP/1.0 200 OK Content-Length: 187 Content-Type: application/soap+xml; charset=utf-8 <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"> <s:Body> <GetQuoteResponse xmlns="http://tempuri.org/"> <GetQuoteResult>28.33</GetQuoteResult> </GetQuoteResponse> </s:Body> </s:Envelope>
  • 12. 12 Example “RESTful” request/response GET http://webapitest.azurewebsites.net/stocks?symbol=msft HTTP/1.1 Host: webapitest.azurewebsites.net ______________________________________________________________________________________________________________________ HTTP/1.0 200 OK Content-Length: 5 Content-Type: application/json; charset=utf-8 33.12
  • 13. 13 Why SOAP • SOAP interoperability is a requirement • Non HTTP transports - TCP, UDP, Named Pipes, MSMQ, custom bindings • WS-* based security.
  • 14. 14 Implementation Options WCF • WCF classic • WCF Data Services • WCF RIA Services • WCF Web HTTP (aka WCF REST) ASP.NET • ASP.NET Web Services • ASP.NET MVC • ASP.NET Web API • ASP.NET Web API OData • ASP.NET SignalR
  • 15. 15 Recommendation: WCF • WCF classic • WCF Data Services • WCF RIA Services • WCF Web HTTP (aka WCF REST) ASP.NET • ASP.NET Web Services • ASP.NET MVC • ASP.NET Web API • ASP.NET Web API OData • ASP.NET SignalR For SOAP ------ WCF classic For REST ------ ASP.NET WEB API
  • 16. 16 ASP.NET Web API (Code Demos) • Simplicity • Self Hosting • Consuming from Server Side. • Attribute routing - http://attributerouting.net/ • OData (emerging functionalities)
  • 17. 17 ASP.NET SignalR (Code Demos) • Web socket based communication. • Falls back to poll approach in the browser doesn’t support Web socket. • http://signalr.net/
  • 18. 18 Questions?