Programmable Web features in the BizTalk Services SDK

First, go download the SDK from

Now that you've downloaded it, you've got a whole bunch of new stuff to play with. Let me give you the guided tour of the Programmable Web stuff (the Connectivity and Identity stuff will have to wait for another day).

All the assemblies live in the \Assemblies folder underneath root installation directory. If you installed them in the default place, you'll find them in C:\Program Files\BizTalk Services SDK\Assemblies. This is where you can point your Visual Studio "Add Reference" dialog at if you want to build apps on top of this stuff. Inside this folder, you'll find four assemblies relating to the programmable web features. Here's what's in each of them:

Microsoft.ServiceModel.Web.Tools - this one contains a nifty little Visual Studio add-in that makes it easier to generate XML documents that have a specific shape. The idea behind this tool is simple -- lots of folks on the web are eschewing XSD in favor of simple web pages that say "here's what I expect the XML in this request to look like". For example, check out the FlickR API docs. Using the example instance document in that page, you could write your own parser on top of System.Xml.XmlReader and get a working solution, but what you might really like is some set of serializable types that could just parse all that stuff for you. Normally, you'd have to write a bunch of types yourself and mark them up with a bunch of XmlSerializer attributes, but that's kind of a pain. With this tool, you can just copy the example XML blob onto the clipboard, pop over to Visual Studio, and choose Edit -> Paste XML as Serializable Type. The tool will infer the document structure from the example and cough up the code for the XML Serializable type system automatically. Pretty cool, and a nice time saver. Note that you'll need to copy the add-in files to the right directory to make Visual Studio aware of the add-in -- there's handy batch file plus instructions for doing this in the Tooling sample (Samples\Web\Tooling). You may need to bounce VS after installing the tool in order to use it for the first time.

Microsoft.Workflow.Activities - this assembly contains two new Workflow Activities for integrating with simple web services. The WebGetActivity lets you do HTTP GET's on URI's, the WebInvokeActivity does everything else (POST, PUT, DELETE -- you can bring your own verb). These guys are great for bringing web resources into the declarative programs you write with Workflow.

Microsoft.ServiceModel.Web.Client - this is an experimental API we're looking at for improving the programming experience of consuming web data from imperative code. It's a spiritual cousin of the System.Net.WebClient API but has some more advanced features (a pipeline processing model, better redirect support, more access to HTTP-isms). The best place to look at this is the client side of the PhotoFeeds sample, which uses this API exclusively. This one is still quite early and we're really looking for community feedback here to tell us where we should go with this.

Microsoft.ServiceModel.Web - this is the main course. We took as many of the programmable web features we're building in Orcas for WCF and plunked them into this assembly so people didn't have to wait for Orcas Beta 2 to build apps on it and give feedback. The one thing that's in Orcas but not in these bits is JSON support (that has a hard dependency on some internal changes to System.Runtime.Serialization so we could decouple it). There's a lot in here so I'll break it down further:

  • System.UriTemplate. You can think of this as the API manifestation of Joe Gregorio's URI Template idea. URI Templates are a great idea, so we built some OM around them and put it into the platform. Now you have an easy way of constructing a whole bunch of URI's that match a specific pattern (you can also go backwards - use a UriTemplate to destructure a candidate URI into a set of pattern variables, which is pretty powerful).
  •  System.UriTemplateTable. Simple idea here -- give us a map of UriTemplate -> Some Data + a candidate URI and we'll do an efficient lookup in the table to tell you which template matches the candidate URI. Easier and faster than foreach'ing over a set of regex's. Like it's friend UriTemplate, System.UriTemplateTable is lightweight and stand-alone so you can use it anywhere (even outside of WCF).
  • [WebGet] and [WebInvoke] attributes for service operations. These two attributes give the WCF dispatch plumbing the necessary metadata to hang some code (your service operation) at a particular URI Template + HTTP Method. I'll blog a lot more about how this all works in a future post, but [WebGet( UriTemplate = "customers/{customerId}" )] captures the basic zen of the model.
  • WebHttpBinding -- this is our new standard binding for this stuff. It uses HTTP/MessageVersion.None + a new encoder that suppoerts XML, JSON (in Orcas) as well as raw byte streams. You hand us a Stream and a content-type, we'll do the right thing. But most of the time, you won't have to worry about configuring endpoints to use this binding because we have the...
  • System.ServiceModel.WebServiceHost/Factory - this is a custom service host that eliminates the need to add or configure the WCF plumbing to do simple web-style services. Hosting these things in IIS is a one-liner with zero-config. This class is all about keeping simple things simple.
  • System.ServiceModel.Syndication Namespace - this is the manage object model for producing and consuming RSS/Atom feeds. We have a format-netural OM for programmatically manipulating syndication data, plus a set of formatters that can project that data model into concrete formats (we ship Atom and RSS in the box, the whole thing's extensible so you can write your own if you want).

That should at least give you a sense of what's in this SDK (and remember, there's all the connectivity and federated identity stuff that we haven't even touched on yet). I'll be blogging about all of these in future posts, so stay tuned.

Technorati Tags: ,
#1 Darrel Miller on 5.07.2007 at 12:40 PM

This is great stuff.I was just in the process of writing my own url parsing and dispatching plumbing the other day when I discovered this little gem.I must admit I had my doubts while downloading the "BizTalk Services SDK", surely there is some mistake I kept thinking, but so far things are going great.The readme file does point to documentation where the link is actually a link to Dennis's local file system.A link to where the actual docs are would be great.