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
• Supports several wire formats:
15. What is JSON?
• JavaScript Object Notation
• Format for bridging JavaScript and objects
– Easier for browsers than XML
• ASP.NET AJAX other AJAX toolkits use it
– Other web-aware clients also (Silverlight, etc.)
17. WCF / AJAX Integration
• WCF AJAX support in Visual Studio
– Script manager, VS Project Templates
• WCF automatically generates JS proxy
• Usage pattern similar to existing one:
– Add service to Script Manager control
– Write JavaScript code to work with proxy
• Configuration not required
– Via the WebScriptServiceHostFactory (.svc file)
18. Agenda – Session 10
SOAP, JSON, POX, REST styles
WebGet and WebInvoke
UriTemplate in 3.5
20. [WebGet] And [WebInvoke]
• Binds a WCF operation to URI
space and HTTP method
• 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)
21. • Other Parameters
– BodyStyle – Indicates whether the Request/
Response are wrapped or not
– RequestFormat – Json or Xml
– ResponseFormat – Json or Xml
– UriTemplate – Rich binding to URI
22. 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
23. • {productId} hole / variable gets bound
to productId parameter in operation
24. WCF REST Starter Kit
• Microsoft.ServiceModel.Web.dll
– New features supporting RESTful services
• Visual Studio 2008 Templates
– REST Collections/Singleton Services
– Atom Feed/Atom Publishing Protocol
– HTTP/POX Services
25. • REST Samples
• Codeplex Project
– Released at PDC
– Written by WCF team
– Features may be included in .NET 4.0