iPhone Development – RSS, XML, ASP.NET and Generic Handlers

As soon as your boss gets an iPhone, he’s going to be asking you how to get to your corporate data from the road. Good side is that you’ll need to get both a Mac and an iPhone but then you need to make it all happen. We focused on delivering a solution quickly that was very simple, adjustable and quick to market. Related Articles Call of Duty

Specifically for us, we have corporate statistics that our executives wanted to be able to view easily from the road without having to boot up a laptop, find wireless, login to our web app, navigate to the statistics page… you know the drill. Instead, they should be able to pull their iPhone out and push a ‘stats’ button. Boom! There are the stats.

Many people are searching for the golden sample iphone application that they can model and forget that there is back-end infrastructure required to feed that data to the requesting iPhone. To get that done, you’re probably already thinking a nice web service feeding back XML. SOAP comes to mind but the current release of the iPhone SDK is light in support. This is where most people will direct you to using REST. REST is cool in that it is an URL based requestor but it takes a lot of work to set it up.

Remember that part of our goal is ‘quick to market’ so why not consider the generic HTTP handler that is in Visual Studio.

Here’s what you do:

1. follow the sample for building an RSS reader and get it wired into your iphone. Follow it word for word and it will work great. Here is the link: [Click Here]
2. now in Visual Studio add a public generic handler. This will be a .ASHX file
3. in your SQL database, build a table that houses a user name to iphone ID relationship
4. edit the generic handler to take in two parameters — one for the requested operation (in our case: stats) and one for the iphone ID.
5. if they are validated respond to them with the stats in XML using context.response
6. test this in your browser passing the correct parameters so you know it’s
working before you start trying to hit it from the iphone.
7. now adjust your iphone app to use your new URL with parameters.

Once you get the basics working:

1. create a corporate db table that houses iphone ID to user Id relationships and check it as the first operation on the handler. This makes the handler extremely secure because you can’t get past the front door without a valid iphone Id. BTW, we used UDID to get the addresses to be used. You have to do this for the ad-hoc provisioning anyway so you’re doubly covered.
2. create a logging function that writes date, time, user, iphone and function to a table
3. enhance the iphone app to allow drill down capabilities (just another operation)

A couple of notes: 

this is scaleable by way of the parameters passed. 
you can adjust the output at the asp.net level instead of the iphone. 
this is very secure in that only the registered iphones will get in.

Good Luck

Dan Ribar
1st Guard Corporation

Author: Dan Ribar

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>