Navigating the Programmable Web
Don Box and Steve MaineURI JockeysMicrosoft Corporation
About This Talk…Goals and Bits
GoalsHow do my programs use the web?How do my programs become part of the web?How do I do this efficiently and pragmatically?
BitsStuff that's already shipped (lots)Stuff that will ship in Orcas (lots more)Stuff that will ship in TBD (a couple of things)
About The Web…Stating the Obvious
GET is More Important Than
You Think
It’s the URI, Stupid
Formats Matter
It's The URI, StupidQuery, S-Expression, or Opaque Identifier
The web pivots on URIsEasy to write down, share, and compareHierarchy matches many information modelsCan be treated as opaque identifier (a la a GUID)Can be treated as a structured expression (a la S-Expr)
URI-space for a given service often infiniteMay also be state/data dependentCommonplace to use template syntax to specify "holes" in URI space (a la A9 and Joe Gregorio)
It's The URI, Stupid,UriTemplates: Embrace Infinity
System.UriTemplate ("Orcas") provides runtime support for URI template syntaxUriTemplate.Bind fills in template holes with actual valuesUriTemplate.Match extracts actuals from concrete URIUriTemplateTable provides matching over multiple candidate templates
Most specific match wins
It's The URI, Stupid,UriTemplates
Uri baseAddress = new Uri( “http://localhost:81” );string artist = "Led Zeppelin";string album = "Four"; UriTemplate template = new UriTemplate(“music/{artist}/{album}?format={format}" );
Uri boundUri = template.BindByPosition( baseAddress, artist, album, "rss" ); //boundUri:// http://localhost:81/music/Led%20Zeppelin/Four?format=rss
UriTemplateMatch match = template.Match( baseAddress, boundUri );
Debug.Assert( match.BoundVariables[“artist”] == artist );Debug.Assert( match.BoundVariables[“album”] == album );Debug.Assert( match.BoundVariables[“format”] == “rss” );
Using URIs and UriTemplates
demo
Watch Steve Code…
GET is More Important Than You ThinkView It vs. Do It
GET CHAOS
Bounded SemanticsMeans “retrieve”No “unsafe” side-effectsExpectation of idempotency
Unbounded SemanticsMeans “do something”
Side-effects allowedNo expectation of idempotency
Most of the world is GETThe rest is relative chaos
GET is More Important Than You ThinkView It vs. Do It
GET CHAOS
“Add”, “Create”, or “Invoke”?
POST PUT DELETE OTHER
“Replace” or “Partial
Update”?
“Delete” or “Rollback”?
What aboutSUBSCRIBE
NOTIFYUPSERT
ENQUEUEMKCOL
…
GET is More Important Than You ThinkView It vs. Do It
Turn off DELETE
Turn off PUT Turn off POST
Turn off GET
Degree of Resultant Apocalypse
Rectal Itching
The Simpsons Movie
Dogs/cats sleepingtogether; mass hysteria
The Oprah Channel
Lindsay Lohan
Smooth Jazz
GET is More Important Than You ThinkWebGet/WebInvoke
[WebGet] ("orcas") adds GET support to WCF service operations
Allows target URI space to be specified as URI templateTemplates parameters mapped to method parametersWebOperationContext provides easy access to web specifics (e.g., headers, status codes)
[WebInvoke] provides same for other HTTP methods
POST is default method
GET is More Important Than You ThinkWebHttpClient : The Opaque/Transparent Duality
[WebGet]/[WebInvoke] work great for "transparent" URI with well-understood structure
Ideal for server, OK (at best) for client
WebHttpClient ("experimental") is a more flexible client-side programming model
Supports both transparent and opaque URIEasier to use and more scalable than current WebClient API
Using WebGet and WebHttpClient
demo
Watch Steve Code…
Formats MatterSchemas, Schemas and more Schemas
Uniform operations are half the web "reach" propositionUniform formats for HTTP entity bodies are the other halfHTML was the ubiquitous format for projecting UXAlas, multiple format(s) for exchanging data
Original vision for "web data" based on plain old XML (POX)JSON offers simpler format/data modelRSS/ATOM constrain POX by adding list structureSOAP constraints POX by adding header processing model
Formats MatterWCF and Formats
WebGet/WebInvoke supports XML, JSON, or opaque binary formats for request/response data
SOAP and POX were in the box in V1
SyndicationFeed/SyndicationItem provide rich programming model for dealing with RSS/ATOM data
Usable standalone or as WCF message contentIntegrates with serialization stacks for feed/item extensibility
Fun with Formats
demo
Watch Steve Code…
Stuff We UsedThe Code/Time Continuum
Already Shipped
System.UriWebClient
WPFWCF
Ships in “Orcas”
UriTemplate[WebGet]
SyndicationFeedLINQ for XML
JSON Formatter
Speculative Bits
WebHttpClient
"Orcas" and the WebCode and Ideas
GET is More Important Than
You Think
It’s the URI, Stupid
Formats Matter
UriTemplate
[WebGet]
SyndicationFeed
LINQ for XML
JSON Formatter
Talk amongst ourselves
discussion
Please fill out your eval
evaluation
© 2007 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.