The Amazon cloud, explained.

Home / Blog / SimpleDb and the iPhone - Part 2

Generating the hash with CommonCrypto didn’t turn out to be as difficult as I had imagined.

The ‘salt’ value that you use in the hash is your AWS secret. Amazon will calculate the same type of hash with your secret on its end - if the two values match, you are in business.

My code to generate the hash as follows.:

iphone5

Once this signature is generated, it is just a matter of tacking it onto the query string and parsing the XML coming back as shown below.

iphone6

Parsing the Response

Parsing Amazon’s response is just a matter of parsing the incoming XML. There are a few different ways of parsing XML on the iPhone. I chose to use their NSXMLParser, which does SAX-style XML parsing. Again, the scratchpad is a handy of having a look at what that XML looks like. Below is a snippet from a QueryWithAttributes response.

iphone7

Building up the rest of the SimpleDb library is just a matter of parsing all of the various responses. I’ve posted my code at http://static.learnaws.com/SimpleDb_Archive.zip with the caveat that I did not implement the full SimpleDb API. I’m implementing as much as I need for the various iPhone applications that I’m building. As I flesh out this implementation, I’ll post updates.

Please see ‘Part 3’ for an example of how to use this wrapper…

Comments are closed.