MIX07 - WCF adding System.UriTemplate, [WebGet], and [WebInvoke] - Jon Galloway

MIX07 - WCF adding System.UriTemplate, [WebGet], and [WebInvoke]


Build and parse URI's

System.UriTemplate (Orcas) - runtime support for URI template syntax
UriTemplate.Bind - A safe, smart string.format for URI construction
UriTemplate.Match - Extracts URI to dictionary
UriTemplateTable - One or more template, best match wins

HTTP GET - bound semantics, expectation of idempotency, generally "safe" Chaos - HTTP POST, PUT, DELETE, others

WebHttpClient client = new WebHttpClient()
  UriTemplate = "http://localhost/mix/data/symbols{0}";
MixData = client.Get(StockSymbol).GetBody();
return data;

WCF adds [WebGet] and [WebInvoke]

[WebGet( UriTemplate = "data/symbols/{symbol}")]
public MixData GetCurrentData(int index)
  MixLogic logic = new MixLogic();
  return logic.GetData();

[WebGet( UriTemplate = "data/results/{index}")]
public MixData GetCachedResults(string index)
int i = int.Parse(index);
if(i >= IMDB.Conptents.Length)
  // Not found logic;
[WebGet ( UriTemplate = "data/feeds/{format}" )]
public object GetFeeds(string format)
  int i = 0;
  syndicationFeed feed = new SyndicationFeed (Mix Data", "some results",
  new Uri ("http://microsoft.com"),
  from data in IMDB.contents
  select new SyndicationItem (data.StockSymbol, data.Price, etc.)...

There was cooler code which consumes an RSS feed as well

XML, JSON, or opaque binary formats (V1 already included SOAP and POX

SyndicationFeed / SyndicationItem provide rich programming model for dealing with RSS / ATOM

In Orcas:

  • UriTemplate
  • [WebGet]
  • SyndicationFeed
  • LINQ fro XML
  • JSON formatter

WebHttpClient is speculative, not in Orcas

Published Wednesday, May 2, 2007 10:49 AM by Jon Galloway
Filed under: , , ,


# re: MIX07 - WCF adding System.UriTemplate, [WebGet], and [WebInvoke]

Haytham it has to be a string in your GetData(string value)

for it to work

One important limitation with UriTemplate to keep in mind that parameter mapping ( inside of {} ) only works with string parameters, so even simple type mapping like int, bool, or dates don’t work with them.

Wednesday, December 17, 2008 4:42 PM by Taswar