Sunday, April 11, 2010

The Data URI

Typically, an image is included in a web page by referencing an image file:

<img src="take-this.jpg" />


But it's also possible to put the image directly inside the web page source. This is done using a data URI:

<img src="data:image/jpeg;base64,image-data-goes-here" />



The URI contains the content-type of the image ("image/jpeg" in this case, since this image is a JPEG) and the image data encoded in base64.

This is supported by most browsers. Internet Explorer support lags behind, with only version 8 supporting it (to a limited extent).

This technique shouldn't be used on a regular basis, since it bloats the size of the web page considerably and makes it take longer to load. Including images as separate files (the typical way) lets the user explore the page while the more bandwidth intensive images are loading.

Check out my Data URI Generator to generate a data URI from an image of your choosing.

Thursday, April 8, 2010

Bad HealthVault Method Schema URLs

One thing to note when working with the HealthVault XML method schemas is that the links to these schemas in the HealthVault Developer Center (http://developer.healthvault.com/methods/methods.aspx), as well as in the GetServiceDefinition response, are not always correct. Some versions of some methods refer to the version 1 schemas, when they actually have their own schemas.

For example, the URL to the GetThings3 request schema is listed as:

https://platform.healthvault-ppe.com/platform/XSD/method-getthings.xsd

This URL incorrectly points to the version 1 schema. The version number must be added to the end of the file name in order to get the correct schema:

https://platform.healthvault-ppe.com/platform/XSD/method-getthings3.xsd

This holds true for the following methods:

CreateConnectPackage2 request
GetServiceDefinition2 response
GetThings3 request, response
OverwriteThings2 request
PutThings2 request