I have never been comfortable with the "black box" conversion from xml
to mx:Object.  I went with xml in 1.5 and am delighted with e4x.  I read
the post above on XMLEncode with interest and plan to look at that, but
since I hav so far been in control of both ends, the data type problems
has not been an issue.

 

You should know about AsyncToken and the ACT pattern.  It lets you match
up results to the corresponding data call, so you can decide how to
porcess the result.  You can even define a handler function, which I
think is known as "closure".  More info is availble on all this.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Chris Luebcke
Sent: Wednesday, January 31, 2007 3:48 PM
To: [email protected]
Subject: [flexcoders] Re: Flex 2 HTTPService best practices

 

So I tried setting the resultFormat to "object" for a service that
returns a fairly deep XML structure. I found that it did a pretty good
job of mapping the text nodes to the correct types (Boolean, String
and Number); it didn't map "2006-11-17" to a Date, but hey, you can't
be all things to all people.

Anybody else out there have experience with resultFormat="object"? Is
there any documentation that specifically describes how the object
graph is put together and what the text-node-to-object rules are? I
suppose I could go look at the source code, but figured I might as
well ask around first.

Thanks,
Chris

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Chris Luebcke" <[EMAIL PROTECTED]> wrote:
>
> Hi Ian, I'm using XML over HTTPService in my current app and may be
> able to help with some of this. Responses inline below.
> 
> --- In [email protected]
<mailto:flexcoders%40yahoogroups.com> , Ian Shafer <ian@> wrote:
> > ...regarding using HTTPService:
> > 
> > * Should I be using it? I'm choosing to use HTTPService because I
don't
> > want to pay for FDS and it (HTTPService) *seems* simple so that if
there
> > are problems, I could easily be able to fix them (as opposed to
using
> > FDS and Adobe's proprietary encoding). Also, XML over HTTP is
simple and
> > always works. Hooking up remote objects just seems like a pain.
> 
> The answer to that question ultimately comes down to your specific
> project needs, of course. I'm not using FDS (for the usual reasons),
> and there doesn't appear to be an open-source (or otherwise really
> cheap) alternative to using AMF3 to communicate to a Java backend. So
> that really leaves some flavor of XML over HTTP as the raw message
> language and protocol. We deliberated between SOAP, REST and homegrown
> XML message protocols, and ultimately settled on homegrown for a
> variety of reasons I won't bore you with. Again, it really depends on
> your specific needs, but so far our solution is shaping up very
nicely.
> 
> > * What is the best resultFormat to use. As far as I can tell,
there are
> > three: object, e4x, and xml. The xml format seems obsolete since
we now
> > have e4x. Is there any reason to use xml? I get e4x (pretty sweet, I
> > think this is a *great* language feature). The only drawback I've
found
> > so far is the datatype of e4x values. They all seem to be Strings.
I get
> > this, but I wonder if there's an easy way to say "all @quantity
fields
> > are numeric" so it'll sort nice in a DataGrid. object seems cool,
but
> > I'm not 100% clear how it works.
> 
> Me neither, frankly. I might consider trying it, though, given that
> there is apparently some basic type casting done when you use this
> format, according to the dev guide:
> 
> "By default, the resultFormat property value of HTTPService components
> and WebService component operations is object, and the data that is
> returned is represented as a simple tree of ActionScript objects. Flex
> interprets the XML data that a web service or HTTP service returns to
> appropriately represent base types, such as String, Number, Boolean,
> and Date. To work with strongly typed objects, you must populate those
> objects using the object tree that Flex creates."
> 
> > Can I tell HTTPService which class to
> > bind the objects to? I don't use Flex Builder (again, I don't like
to
> > pay for software, and I don't have the money), so it's tough to
> > introspect the objects at runtime (although I did see something
about
> > command line debugging, I'll have to look into that).
> 
> I believe this creates a new graph of objects with dynamically created
> properties. I don't believe there's any configurable mechanism for
> mapping XML to particular object classes or types; I think if you need
> mapping different from what resultFormat="object" gives you, you need
> to roll your own. Not positive, though.
> 
> > * I want to call (HTTPService.send()) my service with different
query
> > parameters. What's the best way to do this? Currently, I'm creating
a
> > new HTTPService in AS and generating the URL every time it is
called.
> > This doesn't seem right to me.
> 
> Nah, it ain't :) Create a single HTTPService and modify its request
> property; this property takes "an object of name/value pairs", which
> just means that it'll treat every property name on the object as a
> parameter name and will call toString() on the property value to get
> the parameter value.
> 
> You may want to look at Cairngorm's implementation of the Service
> Locator pattern, which provides an application-wide singleton that
> wraps you services, allowing central definition of services along with
> global access to them. I like the pattern, your mileage may vary.
> 
> > * Should I use a service-config.xml file? I haven't been able to
find
> > good documentation on this?
> 
> Only applies to FDS, I'm pretty sure.
>

 

Reply via email to