Sunday, August 28, 2011

DEV306 The WCF Web Community - REST, jQuery and WebSockets

Jeremy Boyd
Apologies that this post is fairly nonsensical. I've put my raw NZ TechEd 2011 notes up here for my reference. I'd like to think that I'll refine them over time, but that probably won't be the case.
CodePlex
 WebAPI
 jQuery for RIA Services
 Express Interop Libraries

HTML5 Labs
 Efforts around WebSockets

Web APIs

E.g. hooking into the twitter API

Be RESTful
 Clear identification of resources using URIs
 Allow for manipulation of those resources through HTTP

Using the WCF Web API

PM> Install-Packager WebApi.All

Declaring a Service
 Specify [ServiceContract]
 [WebGet]
 [WebInvoke(Method="PUT", UriTemplate="")]

fiddler

OData support
public IQueryable GetSomeTs();
More useful in .NET to .NET scenarios

Formatters to return, for example, images.

jQuery

Rise of "single page" Web applications - E.g. gmail

jQuery allows you to:
 Load data on demand using XHR or WebSockets
 Bind that data to the view
 Wire up new events dynamically (e.g. .live())

RIA Services - OData endpoint that can be queried over LINQ.

PM> Install-Package RIAServices.Toolkit.All
(or download samples)
.dataSource()

Sockets on the Web

Currently a request for a resource on the web carries the request and response headers. Heavy tax when doing lots of small "chatty" messages.
High frequency, low latency messaging. Want something more like a TCP socket.
Polling for data can get lots of header tax.

Client Side
WebSocket
ws://server:port
wss://server:port

Server Side
WebSocketHost WebSocketService

E.g. Instant TradeMe updates!
Server messages back to the client - remote control options

http://html5labs.interoperabilitybridges.com/