Dealing with blob data in HealthVault XML

Posted by: Eric Gunnersons C# Compendium, on 24 May 2011 | View original | Bookmarked: 0 time(s)

I recently had a request for more information on dealing with blob data using our newly-released Mobile support, which finally got me to write something about low-level blob support.

This information applies to any application that isnt using the .NET SDK to talk to HealthVault. If you are using the .NET SDK, I recommend using the support that is provided in the SDK.

HealthVault Blob Options

HealthVault provides the capability of storing additional data such as documents, images, etc. as a blob of data attached to any of the HealthVault data types.

HealthVault provides two ways for applications to manage blob data; an inline method where the blob data is passed with the rest of the data for an item instance, and a streaming approach where blob data is accessed through http get and put requests.

Inline blob data

This method passes the blob data in a base64-encoded format with the rest of the item data. Its the simpler of the methods to use, but it has the following drawbacks:

  • The total size of a HealthVault request has a maximum, which limits the space available for blob data to approximately 5MB (this limit is subject to change).
  • The total size of a HealthVault response has a maximum size, which limits how much blob data can be retrieved, especially if multiple objects with blobs are returned.
  • When the blob data is fetched for an object, data for all blobs is fetched; it isnt possible to fetch the data for a single blob.
  • Network use will be a little higher and data will be slower since the base64 encoding is a little (about 1/3) bigger than the raw bytes.

Heres how you deal with blob data using the inline method:

Fetching blob data as inline data

Heres the <info> section of a GetThings request:


The <section>blobpayload</section> line specifies that in addition to the core part of the data item, any blob data should be passed back along with the rest of the XML. If you forget to do that, you wont get any blob data

This query returns a <blob-payload> section that comes after the <data-xml> section:

      <name />

The following elements are important:

  • name: The name of the blob.
  • content-type: The content type that was specified when the blob was saved
  • content-length: The length of the blob
  • base64data: The blob data

Uploading blob data as inline data

Heres an example of saving a blob as inline data. The blob is passed at the same time the rest of the data for the instance is passed.


The <data-xml> section is removed for the sake of brevity. The important parts are:

  • name: The name of the blob
  • content-type: The encoding of the data
  • content-length: The length of the data in bytes
  • base64data: The data expressed in base64 format

Streamed blob data

In the streamed method, the blog data is fetched or stored using separate interfaces or methods.

Fetching blob data as streamed data

Fetching the blob data is simple. If you change the filter to be:


Instead of the base64data element, you will get a blob-ref-url element that looks something like this:


You can then download the blob data directly using the URL.

Uploading blob data as streamed data

Uploading blob data through the streamed interface is considerably more complex; it requires calling the BeginPutBlob method to get the destination url and then uploading in chunks of data that are a specific size (it also supports signing data, which makes things even more complex).

If you are interested in using this to load large blobs, let me know, and Ill try to update this to show that approach as well.

Category: .NET | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 1 | Hits: 0

Similar Posts

  • Introducing Versatile DataSources more
  • How to display data from different tables using one data source more
  • An alternative to Crystal more
  • Building a class browser with Microsoft Ajax 4.0 Preview 5 more
  • Self-reference hierarchy with Telerik TreeView for Silverlight more
  • Silverlight Twitter Client with authentication more
  • How To: Display Hierarchical Data with Row Details (RadGridView for Silverlight) more
  • Using Microsoft's Chart Controls In An ASP.NET Application: Plotting Chart Data more
  • Silverlight Release History : Q2 2009 (version 2009.2.701) more
  • WPF Release History : Q2 2009 (version 2009.2.701) more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD