1 / 38

Make Yourself Comfortable and REST with Microsoft .NET

MID307. Make Yourself Comfortable and REST with Microsoft .NET. Howard Dierking Program Manager, WCF Microsoft. Agenda. Why REST? REST and WCF 4.0 A Look Into the Future. REST is an architectural style grounded in the characteristics that make the Web successful. Broad Interoperability.

elkan
Download Presentation

Make Yourself Comfortable and REST with Microsoft .NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MID307 Make Yourself Comfortable and REST with Microsoft .NET Howard Dierking Program Manager, WCF Microsoft

  2. Agenda • Why REST? • REST and WCF 4.0 • A Look Into the Future

  3. REST is an architectural style grounded in the characteristics that make the Web successful

  4. Broad Interoperability Article source: http://digitallife.today.com/_news/2011/05/02/6569632-facebook-marriage-killer?gt1=43001

  5. Proliferation of Devices

  6. Increased Scale Demands “The Server”

  7. Traditional Web Service • [ServiceContract(Namespace = "http://samples.microsoft.com/wcf/restcart")] • public interface ICartService • { • [OperationContract(Action = "GetCart")] • CartDtoGetCart(); • [OperationContract(Action = "ClearCart")] • void ClearCart(); • [OperationContract(Action = "UpdateCartItem")] • CartDtoUpdateCartItem(intitemId, intqty); • [OperationContract(Action="RemoveCartItem")] • CartDtoRemoveCartItem(intitemId); • [OperationContract(Action = "AddCartItem")] • CartDtoAddCartItem(intitemId, intqty); • }

  8. Resources and Representations http://www.flickr.com/photos/belisario/2723280407/ Howard Dierking Teleportation Voice HTML Email

  9. A Simple Product Catalog ProductResource http://myhost/product/ GET GET http://restcartwcf4/products GET http://restcartwcf4/products/1 GET (id) POST http://restcartwcf4/products POST PUT (id) PUT http://restcartwcf4/products/1 DELETE http://restcartwcf4/products/1 DELETE (id)

  10. Setting Up the Product Catalog Demo

  11. Content Negotiation http://www.flickr.com/photos/alexgoy/3289023107/ http://www.flickr.com/photos/diwong/4553264432/

  12. Content Negotiation ProductResource http://myhost/product/ HTTP/1.1 200 OK Cache-Control: private Content-Length: 553 Content-Type: application/json; charset=utf-8 { "description":"Erik Evans magnum opus on DDD", "links":null,"name":"Domain Driven Design", "price":59.99,"productNumber":"200", "quantityOnHand":1 } GET GET http://myhost/product/1 Accept: application/json GET (id) HTTP/1.1 200 OK Content-Type: application/json POST PUT (id) DELETE (id)

  13. Automatic Content Negotiation Demo

  14. Intermediaries and Caching What did he just say? http://www.flickr.com/photos/mindonfire/2881787072/

  15. Cache Control and Revalidation ProductResource http://myhost/product/ 1 GET http://myhost/product/1 GET HTTP/1.1 200 OK Cache-Control: max-age=60 Etag:“1” ... GET (id) GET (id) POST 2 GET http://myhost/product/1 HTTP/1.1 304 Not Modified PUT (id) DELETE (id) GET http://myhost/product/1 If-None-Match: “1” 3 HTTP/1.1 304 Not Modified

  16. Optimistic Concurrency 1 PUT http://myhost/product/1 If-Match: “1” ProductResource http://myhost/product/ HTTP/1.1 200 OK Etag: “2” ... GET GET (id) GET (id) PUT http://myhost/product/1 If-Match: “1” 2 HTTP/1.1 412 Precondition Failed POST 3 GET http://myhost/product/1 PUT (id) PUT (id) HTTP/1.1 200 OK Etag: “2” DELETE (id) PUT http://myhost/product/1 If-Match: “2” 4 HTTP/1.1 200 OK Etag: “8” ...

  17. Control Caching and Validation Demo

  18. Hypermedia http://www.flickr.com/photos/albinoflea/233362073/

  19. Hypermedia GET http://myhost/product/ Accept: application/atom+xml 1 ProductResource http://myhost/product/ HTTP/1.1 200 OK GET GET <feed xmlns="http://www.w3.org/2005/Atom"> <title type="text">All Products</title> <subtitle type="text">All my products</subtitle> <id>ProductsFeed</id> <updated>2011-05-10T22:30:30-07:00</updated> <entry> <id>2</id> <title type="text">Domain Driven Design</title> <updated>2011-05-10T22:30:30-07:00</updated> <link rel="self" href="http://myhost/product/1"/> ... </entry> </feed> GET (id) GET (id) POST <link rel="self" href="http://myhost/product/1"/> PUT (id) DELETE (id) 2 GET http://myhost/product/1 HTTP/1.1 200 OK

  20. Reduce Coupling with Hypermedia Demo

  21. Future: WCF Web API Improvements • Symmetric HTTP object model on the client and server • Simplified extensibility pipeline • IoC and code-based config • Async (task of T on the client) • …and more to come… http://www.flickr.com/photos/x-ray_delta_one/4246400843/

  22. Extended Content Negotiation with Web API Demo

  23. Let’s Recap • REST Benefits • Broad interoperability • Device integration • Naturally suited for horizontal scale • Implementing REST with WCF • Resources and representations (WCF 4.0) • Content negotiation (WCF 4.0, expanded in Web API) • Leverage intermediaries (WCF 4.0) • Hypermedia (WCF 4.0, expanded in Web API)

  24. Learn more about WCF and REST • http://wcf.codeplex.com • Roy Fielding’s thesis • IANA registry of media types • IANA registry of link relationships • REST in Practice • MSDN WCF Developer Center • http://msdn.microsoft.com/en-US/netframework/aa663324.aspx • Me • Blog: http://codebetter.com/howarddierking • Email: howard@microsoft.com • Twitter: howard_dierking

  25. Required Slide Speakers, please list the Breakout Sessions, Interactive Discussions, Labs, Demo Stations and Certification Exam that relate to your session. Also indicate when they can find you staffing in the TLC. Related Content • Breakout Sessions • MID302 AppFabric Caching: How It Works and When You Should Use It • MID314 Services Made Easy with WCF 4, Microsoft Visual Studio 2010 and Windows Server AppFabric • MID311 Windows Communication Foundation RIA: Ready for Business • MID310 Windows Communication Foundation Futures • MID315 Building Highly Scalable and Available WCF Services with Windows Azure AppFabric • Hands-on Labs • MID374-HOL | Windows Communication Foundation (WCF) 4: Configuration is Much More Simple - Learn How • MID378-HOL | Windows Server AppFabric Hosting: Developer Basics - Workflow Services • MID377-HOL | Windows Server AppFabric Hosting: Developer Basics - Windows Communication Foundation (WCF) Services

  26. Required Slide Track PMs will supply the content for this slide, which will be inserted during the final scrub. Track Resources • Windows Azure Platform Training Kit • Windows Server AppFabric Training Kit • BizTalk 2010 Developer Training Kit • AppFabric Team Blog • Windows Azure AppFabric on MSDN • Windows Server AppFabric on MSDN

  27. Resources • Connect. Share. Discuss. http://northamerica.msteched.com 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

  28. Complete an evaluation on CommNet and enter to win!

  29. © 2011 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.

  30. WCF and HTTP: A Brief History

  31. The RESTful Path Richardson’s HTTP maturity model

  32. Traditional Web Service CartService.svc GetCart() ClearCart() 200 OK POST http://localhost/CartService.svc POST http://localhost/CartService.svc HTTP/1.1 Content-Type: text/xml; charset=utf-8 SOAPAction: "GetCart" Content-Length: 154 <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <GetCart xmlns="http://samples.microsoft.com/wcf/restcart"/> </s:Body> </s:Envelope> HTTP/1.1 200 OK Content-Length: 984 Content-Type: text/xml; charset=utf-8 Date: Tue, 26 Apr 2011 01:22:53 GMT <s:Envelopexmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <GetCartResponsexmlns="http://samples.microsoft.com/wcf/restcart"> <GetCartResultxmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <DateCreated>2011-04-25T18:22:53.5759314-07:00</DateCreated> <Items> <CartItemDto> <Description>Product 1</Description> <ProductNumber>1</ProductNumber> <Quantity>2</Quantity> <Subtotal>5</Subtotal> <UnitPrice>2.5</UnitPrice> </CartItemDto> </Items> <LastUpdated>2011-04-25T18:22:53.5759314-07:00</LastUpdated> ... </s:Body> </s:Envelope> Content-Type: text/xml SOAPAction: "GetCart" UpdateCartItem(itemId, Qty) RemoveCartItem(itemId) AddCartItem(itemId, Qty) ApplyShippingInfo (shippingOption, shippingAddress) ApplyBillingInfo(billingAddress, paymentType, paymentInfo) <LastUpdated>2011-04-25T18:22:53.5759314-07:00</LastUpdated> …

  33. Traditional Web Service CartService.svc GetCart() ClearCart() 500 Internal Server Error POST http://localhost/CartService.svc HTTP/1.1 Content-Type: text/xml; charset=utf-8 SOAPAction: "GetCart" Content-Length: 154 <s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <GetCart xmlns="http://samples.microsoft.com/wcf/restcart"/> </s:Body> </s:Envelope> HTTP/1.1 500 Internal Server Error Content-Length: 734 Content-Type: text/xml; charset=utf-8 Date: Wed, 27 Apr 2011 00:15:00 GMT <s:Envelopexmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:Body> <s:Fault> <faultcode>a:InternalServiceFault</faultcode> <faultstringxml:lang="en-US">...</faultstring> </s:Fault> </s:Body> </s:Envelope> UpdateCartItem(itemId, Qty) RemoveCartItem(itemId) <faultcode>a:InternalServiceFault</faultcode> <faultstringxml:lang="en-US">...</faultstring> AddCartItem(itemId, Qty) ApplyShippingInfo (shippingOption, shippingAddress) ApplyBillingInfo(billingAddress, paymentType, paymentInfo) …

  34. Simplify Etag Validation with Web API MessageHandlers Demo

  35. © 2011 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.

More Related