Debugging webservice problems on iOS devices

Most apps we develop integrate with a server through some kind of XML or JSON based webservice. Sometimes these webservicesa already exist. But more often our customers are developing them at the same time or even after we develop our iPhone and Android apps. Inevitably this leads to minor but time consuming problems getting the Apps and the webservice to play nicely together. A lower and upper case character mixed up somewhere can mean hours of debugging.

So there are a number of options to troubleshoot:

  • DO NOT: Rig up some debugging code in the iPhone or Android client to spit out details about the call. This is a bad idea – the code is often forgotten and sits around in production causing an extra performance hit.
  • AS A LAST RESORT: Examine log files on the server. This can be painful. Often the logs are buried somewhere deep on the server – i assume to fool the iranians ;). And even if you find them, chances are they won’t contain any clues to what is going wrong.
  • DO: Use an HTTP proxy. This works well, can be switched off and on without requiring code change and is quite easy to set up. Since we develop on Mac’s we use the free burp HTTP monitor. Check out http://www.tuaw.com/2011/02/21/how-to-inspect-ioss-http-traffic-without-spending-a-dime/ for a step by step instruction. Basically you change your iPhone network settings to send all WiFi traffic through your HTTP proxy on your PC. Then you can see all HTTP traffic between your device and the server, reproduce it and even change requests to the server. The nice thing about this is that you can use this with any app, even apps that have been downloaded from the App store.Of course the HTTP proxy method doesn’t work if you enforce valid SSL certificates in your app. But that is easily solved by putting debugging code in the app that allows self-signed certificates to be used.
Advertisements