04 November 2008

Wireshark - Must-have Utility for All Flex Developers

I was wrestling with a very subtle problem today: The Flex app was passing some variables to a Java servlet via an HTTPService,

var params:Object = new Object();
params.ServiceType = "INITIALIZE";
params.SearchID = searchID.text;
params.Description = searchDescription.text;
serviceGridReader.send(params);

Using the Wireshark tool, I filtered the capture to only give me the packets for my server. I noticed that the above params data was being sent to the server as XML. Hmm. I had the following further up in the code,

serviceGridReader.contentType = "application/xml";

I created a simple HTML page with a form and a submit button, passing the same data in hidden fields. Lo and behold -- the servlet worked fine with that. Using Wireshark, I noticed the data was being passed in this format from the HTML form,

Description=&ServiceType=INITIALIZE&SearchID=PANUNC

Once I commented out the line setting the contentType, the servlet was happy with a simple request.getParameter("ServiceType").

No comments: