Reputation: 12905
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.
Upvotes: 0
Views: 5870
Reputation: 97
from the manual of HTTPService:
object: The value returned is XML and is parsed as a tree of ActionScript objects. This is the default.
array: The value returned is XML and is parsed as a tree of ActionScript objects however if the top level object is not an Array, a new Array is created and the result set as the first item. If makeObjectsBindable is true then the Array will be wrapped in an ArrayCollection.
xml: The value returned is XML and is returned as literal XML in an ActionScript XMLnode object.
flashvars: The value returned is text containing name=value pairs separated by ampersands, which is parsed into an ActionScript object.
text: The value returned is text, and is left raw.
e4x: The value returned is XML and is returned as literal XML in an ActionScript XML object, which can be accessed using ECMAScript for XML (E4X) expressions.
Upvotes: 4
Reputation: 10692
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....
Upvotes: 0
Reputation: 5858
The classtype of the returned object differs.
Upvotes: 1