tags:

views:

1178

answers:

2

What is the real difference between these resultformats for HTTPService in Flex :

text
object
xml
e4x

Especially, the last three seem pretty close to each other by their description.

+1  A: 

The classtype of the returned object differs.

  • text => String
  • object => A generic object that you can use like a hash
  • e4x => an object of type XML
  • xml => I forget... a String?
Marc Hughes
A: 

I recently had some issues with the "object" and "e4x" resultFormat.

I have a base WebService Class that I use for sending requests and receiving results. By default, all results come back as "object". However, sometimes Flex looks at the data, and converts it to an appropriate type. For instance, if you have an XML result that looks like the following, it will convert it to an Array Object (not sure why...but...):

<root>
    <child>text</child>
    <child>text text</child>
</root>

Now, an Array Object like this can easily be cast as XML, since, as a string it is also XML.

However, some XML documents are returned as an ObjectProxy, which cannot be cast as XML, when the resultFormat is "object".

I tried using "e4x", as it was suggested here, but then I ran into problems with namespaces not being preserved correctly.

I finally tried "xml", and I am getting the expected results. It's interesting that when you inspect the event result property using the Flex Debugger, it is said to be an Array, even when you specify a resultFormat of "xml". I guess this allows for easily casting to ArrayCollection...not sure....

Eric Belair