simplfuzz
simplfuzz

Reputation: 12905

Flex HTTPService Resultformat

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

Answers (3)

Wei
Wei

Reputation: 97

from the manual of HTTPService:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/rpc/http/HTTPService.html#resultFormat

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

Eric Belair
Eric Belair

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

Marc Hughes
Marc Hughes

Reputation: 5858

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?

Upvotes: 1

Related Questions