Upload
shelley-hardin
View
40
Download
3
Tags:
Embed Size (px)
DESCRIPTION
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 - PowerPoint PPT Presentation
Citation preview
Implementing RESTful Services With Windows Communication Foundation 3.5 SP1
Implementing RESTful Services With Windows Communication Foundation 3.5 SP1Concepts and Introduction(Part 1 of 2)
Session ObjectivesSession Objectives
Provide you with an overview of RESTUnderstand the REST support of WCF 3.5Learn how to build an AJAX-Friendly service Learn how to build a HI-REST serviceGet you fired up with Demos
AgendaAgenda
Why The Web WorksWhat is REST?How REST works in WCF 3.5LO-REST Demo (AJAX)HI-REST Demo (AJAX & Silverlight 2.0)
Why The Web WorksWhy The Web Works
Simple & OpenAddressing scheme – URIApplication protocol – HTTPRepresentation Format - (X)HTMLResponse Codes – HTTP Status
Scales Best When StatelessCached
It works because people find value in it
How do we move from a web of pages to a web of services?
How do we move from a web of pages to a web of services?Circa 1998
SOAP Web ServicesSOAP Web Services
HTTP POST of an XML Message (SOAP Envelope)WSDL describes SOAP serviceWS-* provides extended functionalityStandardized 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>
WCF 3.0 SOAP/HTTP BindingsWCF 3.0 SOAP/HTTP Bindings
basicHttpBindingConforms to WS-I Basic Profile 1.1 standards Compatibile with ASP.NET Web Services (asmx)
wsHttpBindingA composable protocol stack allowing standards based additions
WS-Security
AgendaAgenda
Why The Web WorksWhat is REST?How REST works in WCF 3.5LO-REST Demo (AJAX)HI-REST Demo (AJAX & Silverlight 2.0)
RESTful TenentsRESTful Tenents
The Web of Services should work the way the Web of Pages works.Simple & OpenThe Universal API - HTTPLinked ResourcesServices Scale Best When
StatelessCached
Built into the HTTP protocol when leveraged properly
REST ContinuumREST Continuum
Well Constructed URIsHTTP Verbs
GET – FetchPUT – Update / InsertDELETE – DeletePOST – Append
Standard Representations
RESTfullness
Hi-RES
T
Lo-R
EST
POST to 1 URI OKQuerystrings OKHTTP Verbs
GET – FetchPOST - Overloaded
AJAX Services
POX OK
Purists Pragmatists
The Microsoft PositionThe Microsoft Position
SOAP is greatREST is greatUse WCF to build either one and go in peace
AgendaAgenda
Why The Web WorksWhat is REST?How REST works in WCF 3.5LO-REST Demo (AJAX)HI-REST Demo (AJAX & Silverlight 2.0)
webHttpBindingwebHttpBinding
New “web-friendly” WCF Binding in Fx 3.5Allows for the development of RESTful servicesDoes not use SOAP envelopesHTTP and HTTPS Transports Only
Works across REST ContinuumSupports all HTTP verbs
Web Message EncodingJSONXMLBinary (streams)
[WebGet] and [WebInvoke][WebGet] and [WebInvoke]
Indicate the HTTP Method for the operationWebGet – Don’t make me write itWebInvoke – All verbs other than GET (Method parameter takes in the name of the Verb)
Other ParametersBodyStyle – Indicates whether the Request / Response are wrapped or notRequestFormat – Json or XmlResponseFormat – Json or XmlUriTemplate – Covered next …
UriTemplateUriTemplate
String that allows you to define the structure of the URI, as well as to define “Holes”
The “Holes” are variablesYou Bind the template with parameters to fill the holes
{productId} hole / variable gets bound to productId parameter in operation
[OperationContract][WebGet(UriTemplate=“product/{productId}")]Product GetProduct(int productId);
Hole
WebGet/WebInvoke ExamplesWebGet/WebInvoke Examples
[OperationContract][WebInvoke( Method=“PUT", ResponseFormat=WebMessageFormat.Json, UriTemplate=“product/{productId}")]Product UpdateProduct(int productId, product p);
[OperationContract][WebGet( ResponseFormat=WebMessageFormat.Json, UriTemplate=“product/{productId}")]ProductData GetProduct(int productId);
webHttpBinding Endpoint BehaviorswebHttpBinding Endpoint Behaviors
Endpoint Behaviors - extend run-time behavior for an endpointwebHttp - enables the Web programming model for a WCF serviceenableWebScript – ASP.NET AJAX friendly endpoint behavior
Aligns nicely with ASP.NET AJAX clientSubClasses webHttpProvides ASP.NET AJAX proxy generationOnly supports GET and overloaded POSTDoes not support UriTemplates
DemoDemoLO-REST (AJAX Friendly)
DemoDemoHI-REST
SummarySummary
REST principles borrow from principles of the webArchitectures vary with regard to adherence to REST principleswebHttpBinding supports architectures across the REST continuum
enableWebScript Productivity features for ASP.NET AJAX applicationsImposes limitations
webHttp – Provides ability to implement services that adhere to strictest of standards
ResourcesResources
"AJAX Integration and JSON support" in .Net 3.5 conceptual docs"Web Programming Model" in .Net 3.5 conceptual docsPosting of Various Valuable WCF DocsSteve Maine's BlogHTTP Programming with WCF and the .NET Framework 3.5 (MSDN Magazine)WCF, WF and .NET 3.5 Whitepapers by David Chappell