We had a Web application that used Windows Azure Table Storage (Microsoft’s highly scalable “NoSQL” implementation), and I was asked to do a prototype client using the final bits for Microsoft’s Windows Phone 7 SDK. Microsoft’s claimed strategic benefit in “The Cloud” is the integration of tools and technologies, and I was more than ready to enjoy some time in a single IDE, with a single SDK to recall.
My initial steps were very encouraging. Windows Phone 7 programming is done using Silverlight. Silverlight apps generally use the Model-View-ViewModel architecture, in which the View (the actual user interface) uses data binding to communicate with the interface logic in the ViewModel. This decoupling has at least two major advantages: Since there is little, if any, logic in the View, the developer can create a basic “programmer’s UI,” and graphic designers can, in parallel, create a snazzy look. The second advantage is that since there are no actual pixels or screens in the ViewModel, it’s much easier to automate testing of the interface logic.
Because I had mocked the Model objects coming from Table Storage, I was able to rapidly iterate and concentrate on the challenges of the mobile app. (Cue the distant rumble of an approaching storm.) I spent my time making sure that the most risky aspects of development—the mobile interface logic—were going to work. Indeed they did, and I sent the client a cheerful and confident message. (Cue the first drops of rain beginning to fall.)
It was time to do what was supposed to be the easiest part of the project: Add a “Service Reference” to the Azure Web Service and replace my mocked Model with the real thing. This was supposed to be the easy part because Microsoft is “all in” to the cloud. Because Windows Communication Foundation embodies all the lessons learned from SOAP. Because Microsoft’s whole claim to strategic value is that it provides complete end-to-end technology.
Yet, as it turns out, Windows Phone 7 does not allow you to use WCF to connect to Azure Table Storage out of the box. You need to install “WCF RIA Services for Silverlight 4.” Except that Windows Phone 7 is implemented on Silverlight 3.5. At which point, you will take solace in the fact that Windows Azure Table Storage can support a REST-ful interface.
Representational State Transfer is the architecture of the Web. It uses HTTP for transport and status codes, and it has a small set of verbs with well-defined semantics. Everything about it is human-readable and easy enough to mock for testing purposes: requests and responses, document definitions, and status codes (well, they’re encoded as numbers, such as the 404 that even grandparents have become familiar with). It is explicitly designed to work well with intermediaries, which means that you can use a tool like Fiddler 2 to study and even modify conversations and be confident in the results you see.