InfoPath saved my life (well, almost)

It saved me a bit of time at least. Back to my SmartPhone application for tracking business mileage. I’d written the client. I’d created the database. I’d done the stored procs. I’d crafted a web service (or two in fact, one to submit the data and one to report on it). All was well in the world. Now all I wanted was some way to get to that reporting web service.

The web method signature looks a little like this:

public List<Journey> GetJourneysForPeriod(string Username, DateTime StartDate, DateTime EndDate)

In other words I’m returning a list of Journey objects which just happen to look a bit like the class on the left. I was thinking of writing some sort of smart client application – probably based on Excel – to get my data out. But then I remembered the oft-forgotten, XML-tastic, data-gathering, form rendering application that is InfoPath (and remember folks, Forms Server in the 2007 Microsoft Office System lets you render InfoPath forms in a web browser – not that that’s relevant here but it is cool).

So here’s how easy it is to create my report in InfoPath

  • Open InfoPath
  • Select Design a Form based on a web service to receive data and enter the URL of the web service
  • Select my operation (GetJourneysForPeriod) and we’re ready to get started
  • Drag the query fields from the data source into the query area and do the same for the data fields

Er, that’s it. I now have a working report. Okay, so I can tidy it up a bit by changing some of the controls that InfoPath has associated with the fields, adding a title and some additional layout and setting the data fields to read-only etc. But in 4 steps and about 1min flat I had a working report that queried my web service and rendered a nice list of journeys just as I’d been hoping for. I’ve said it before and I’ll say it again, InfoPath – what a great tool for dealing with XML data!