1 / 22

Implementing RESTful Services With Windows Communication Foundation 3.5 SP1

Implementing RESTful Services With Windows Communication Foundation 3.5 SP1. Concepts and Introduction(Part 1 of 2). Session Objectives. Provide you with an overview of REST Understand the REST support of WCF 3.5 Learn how to build an AJAX-Friendly service

Télécharger la présentation

Implementing RESTful Services With Windows Communication Foundation 3.5 SP1

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. Implementing RESTful Services With Windows Communication Foundation 3.5 SP1 • Concepts and Introduction(Part 1 of 2)

  2. Session Objectives • Provide you with an overview of REST • Understand the REST support of WCF 3.5 • Learn how to build an AJAX-Friendly service • Learn how to build a HI-REST service • Get you fired up with Demos

  3. Agenda • Why The Web Works • What is REST? • How REST works in WCF 3.5 • LO-REST Demo (AJAX) • HI-REST Demo (AJAX & Silverlight 2.0)

  4. Why The Web Works • Simple & Open • Addressing scheme – URI • Application protocol – HTTP • Representation Format - (X)HTML • Response Codes – HTTP Status • Scales Best When • Stateless • Cached • It works because people find value in it

  5. How do we move from a web of pages to a web of services? Circa 1998

  6. SOAP Web Services • HTTP POST of an XML Message (SOAP Envelope) • WSDL describes SOAP service • WS-* provides extended functionality • Standardized and interoperable • <s:Envelope> • <s:Header> • <Action s:mustUnderstand="1"> • http://t.org/IService1/GetData • </Action> • </s:Header> • <s:Body> • <GetData> • <value>1</value> • </GetData> • </s:Body> • </s:Envelope>

  7. WCF 3.0 SOAP/HTTP Bindings • basicHttpBinding • Conforms to WS-I Basic Profile 1.1 standards • Compatibile with ASP.NET Web Services (asmx) • wsHttpBinding • A composable protocol stack allowing standards based additions • WS-Security

  8. Agenda • Why The Web Works • What is REST? • How REST works in WCF 3.5 • LO-REST Demo (AJAX) • HI-REST Demo (AJAX & Silverlight 2.0)

  9. RESTfulTenents • The Web of Services should work the way the Web of Pages works. • Simple & Open • The Universal API - HTTP • Linked Resources • Services Scale Best When • Stateless • Cached • Built into the HTTP protocol when leveraged properly

  10. REST Continuum • Well Constructed URIs • HTTP Verbs • GET – Fetch • PUT – Update / Insert • DELETE – Delete • POST – Append • Standard Representations Hi-REST Lo-REST RESTfullness Purists Pragmatists • POST to 1 URI OK • Querystrings OK • HTTP Verbs • GET – Fetch • POST - Overloaded • AJAX Services • POX OK

  11. The Microsoft Position • SOAP is great • REST is great • Use WCF to build either one and go in peace

  12. Agenda • Why The Web Works • What is REST? • How REST works in WCF 3.5 • LO-REST Demo (AJAX) • HI-REST Demo (AJAX & Silverlight 2.0)

  13. webHttpBinding • New “web-friendly” WCF Binding in Fx 3.5 • Allows for the development of RESTful services • Does not use SOAP envelopes • HTTP and HTTPS Transports Only • Works across REST Continuum • Supports all HTTP verbs • Web Message Encoding • JSON • XML • Binary (streams)

  14. [WebGet] and [WebInvoke] • Indicate the HTTP Method for the operation • WebGet – Don’t make me write it • WebInvoke – All verbs other than GET (Method parameter takes in the name of the Verb) • Other Parameters • BodyStyle – Indicates whether the Request / Response are wrapped or not • RequestFormat – Json or Xml • ResponseFormat – Json or Xml • UriTemplate – Covered next …

  15. UriTemplate • String that allows you to define the structure of the URI, as well as to define “Holes” • The “Holes” are variables • You Bind the template with parameters to fill the holes • {productId} hole / variable gets bound to productId parameter in operation Hole [OperationContract] [WebGet(UriTemplate=“product/{productId}")] ProductGetProduct(intproductId);

  16. WebGet/WebInvoke Examples [OperationContract] [WebInvoke( Method=“PUT", ResponseFormat=WebMessageFormat.Json, UriTemplate=“product/{productId}")] ProductUpdateProduct(intproductId, product p); [OperationContract] [WebGet(ResponseFormat=WebMessageFormat.Json, UriTemplate=“product/{productId}")] ProductDataGetProduct(intproductId);

  17. webHttpBinding Endpoint Behaviors • Endpoint Behaviors - extend run-time behavior for an endpoint • webHttp - enables the Web programming model for a WCF service • enableWebScript – ASP.NET AJAX friendly endpoint behavior • Aligns nicely with ASP.NET AJAX client • SubClasses webHttp • Provides ASP.NET AJAX proxy generation • Only supports GET and overloaded POST • Does not support UriTemplates

  18. Demo LO-REST (AJAX Friendly)

  19. Demo HI-REST

  20. Summary • REST principles borrow from principles of the web • Architectures vary with regard to adherence to REST principles • webHttpBinding supports architectures across the REST continuum • enableWebScript • Productivity features for ASP.NET AJAX applications • Imposes limitations • webHttp – Provides ability to implement services that adhere to strictest of standards

  21. Resources • "AJAX Integration and JSON support" in .Net 3.5 conceptual docs • "Web Programming Model" in .Net 3.5 conceptual docs • Posting of Various Valuable WCF Docs • Steve Maine's Blog • HTTP Programming with WCF and the .NET Framework 3.5 (MSDN Magazine) • WCF, WF and .NET 3.5 Whitepapers by David Chappell

More Related