Amazon SimpleDB for Windows Phone Part 2 -- Using Fiddler
Almost immediately after writing the code to connect to the SimpleDB, I started running into HTTP error codes. No 200’s for me. Since my code is directly working with HttpWebRequest objects and their corresponding HttpWebResponse objects, I could just look through the response object and its properties to see what went wrong. But if you want to see what actually went over the wire, both on the way out and back in, there’s such a better way to do it. Fiddler.
If you don’t know what Fiddler is, it’s an awesome tool to view all http requests and their responses from your machine. It’s like the network console of IE’s F12 tool or Firebug for Firefox. And you get to see everything in excellent detail, mess with it, and replay requests to name just a couple features. Here’s how Fiddler describes itself:
“Fiddler is a Web Debugging Proxy which logs all HTTP(S) traffic between your computer and the Internet. Fiddler allows you to inspect traffic, set breakpoints, and “fiddle” with incoming or outgoing data.”Getting it to work with a browser is not hard. But I wanted to use it with the Windows Phone Emulator. At first I had some trouble, but after finding this article by Eric Lawrence (Fiddler’s daddy), I was able to enable it and get down to business. Go read that article to get it running for your emulator. Eric’s article talks about viewing IE requests through fiddler, but it should work the same for your app’s networking code.
Viewing SimpleDB TrafficThe default way of connecting to SimpleDB is over https. However, that complicates debugging inside of Fiddler for a couple different reasons. During development, it’s easy enough to just set the connect URI for SimpleDB to http://sdb.amazonaws.com.
The first problem I ran into was that I was getting a HTTP 403 Error. Forbidden. Sounds so mean and uninviting. Honestly, the 403 error response is not very useful. But the payload of the response from SimpleDB was a big help. Here is the XML response that I received:
[sourcecode language=“xml”] <?xml version="1.0"?> <Response> <Errors> <Error> <Code>SignatureDoesNotMatch</Code> <Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</Message> </Error> </Errors> <RequestID>f41fca3f-ce59-8219-0c3c-af70c12cdda4</RequestID> </Response>[/sourcecode]
We now have a more specific error message that says SignatureDoesNotMatch. Meaning the signature that I calculated and sent along in the request is not the same as what they calculated. I don’t remember the specifics on how I found what the problem was, but as I mentioned in Part 1, the values of the query string should be in alphabetical order except for the AWSAccessKeyId. Using Fiddler, I was able to see this error message easily, search the net for this error code and solve the problem.
Missed the rest of the series? Check ‘em out:
Amazon SimpleDB for Windows Phone Part 1 – Signature