I have been doing a lot of Flex work over the last couple of weeks. I have to say, it is like a dream come true after having written my fair share of code in the Macromedia Flash IDE which is something akin to eating beans with a toothpick, you get there in the end but it is a long and arduous journey. FlexBuilder, built on Eclipse, is a fully featured IDE that relieves a lot of the frustration.
Anyway, back to the plot… Being a .NET developer at heart my first foray into Flex has been a front end that sits on top of some .NET web services. There are a few options as to what you put behind your Flex apps but .NET was the best fit for the job and my skills…
So off I went and all was going swimmingly until I tried to send an array of integers from the flex app to my .NET web service. The darn thing wouldn’t work. So I opened up (the excellent, probably worth another post) Service Capture and had a look at what was being submitted to the web service.
Flex, it appears, was serializing my int array like so:
My web service was expecting:
So what did I do? I spent a while looking around the FlexCoders Yahoo group. Could’t find exactly what I was after so I posted the problem…
The upshot is there seems to be a couple of serialization bugs that Adobe are planning to sort out in the imminent service update. Whether they are responsible for my problem I didn’t find out but here’s hoping.
In the meantime my options are to send literal XML to my web service rather than allow Flex to serialize it for me. This, I imagine will require some adjustments to the back end too although I haven’t tried it yet and don’t really want to if I can help it, simply because I shouldn’t have to in this day and age.
There are various solutions I could implement on the server such as some sort of custom deserialization but this is all very complicated just so as I can pass an array of integers and besides which, if this is due to a bug I’ll have to undo it all when it is fixed.
Another alternative suggested on the group was to use JSON. It turns out that there is a Flex JSON implementation and a .NET one, neither of which I had heard of before. Sam Shrefler explains… Thanks Sam that looks just the ticket.