John Lam 1997 — 2026

Indigo and flickr: happy at last

In yesterday’s post about the Flickr bug I explained what was causing Indigo to be so unhappy. I spent some quality time with Google, and found the code samples from Doug Purdy’s PDC presentation on how to make Indigo initiate POX (Plain Old XML) style calls. Now, flickr should really fix their API, but this led to an interesting educational trip into the world of MessageEncoders in Indigo.

A MessageEncoder is responsible for marshaling a Message object to and from an Indigo transport. By writing my own MessageEncoder, I can set its MediaType property to text/xml, thereby ensuring that the Indigo plumbing accepts the mal-formed flickr response.

Once you write your own MessageEncoder, you have to inject it into the Indigo stack. To do this, you’ll need to implement a custom MessageEncoderFactory and a custom BindingElement. This is fill-in-the-form style programming – you just have to override a few mandatory methods and you’re good to go.

The really nice part of this exercise was how none of the rest of the code that I wrote yesterday had to change to make this happen. The only part that changed was replacing the reference to TextMessageEncodingBindingElement with my new FlickrEncodingBindingElement.

Here’s the source code for my implementation (cleaned up a bit from the code that I posted yesterday).

Thanks go out to Don Box, Yasser Shohoud and Kenny Wolf for pointing out the right way of making this happen.