Being new to the Flex set up I'm not fully up to speed on its features
or limitations but I'm sure there must be something that could help to
automate the process. That isn't to say that I'm not impressed by the
simplicity of declaring a web service in mxml. That is good stuff but,
particularly for complex objects like those you describe as being
problematic, it would be nice to be able to either generate the client
side class or populate the object automatically.

I'm sure I will revisit this as I spend more time in Flex and if I
ever manage to get anything together I will post it to the group...



--- In flexcoders@yahoogroups.com, "Franck de Bruijn"
<[EMAIL PROTECTED]> wrote:
>
> It would be great if we would have some component that could handle
this,
> but I'm afraid it'll be extremely hard to accomplish:
> 
> *     You would need some sort of a 'reflection' API, and I'm not sure if
> that exists in Flash/Flex.
> *     It'll be tricky to deal with nested custom objects and collections
> of nested custom objects
> *     Plus, there are always these subtle naming issues.
> 
>  
> 
> It would be no option for me to start writing XML-files and the like in
> order to make the conversion automatic. Then, it's better to program the
> conversions out in your own factory ActionScript methods.
> 
>  
> 
> Another cue you could follow is to have the conversions automatically
> generated. That's what I'm after ...
> 
>  
> 
> Cheers,
> 
> Franck
> 
>  
> 
>   _____  
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of grahampengelly
> Sent: Wednesday, August 16, 2006 5:55 PM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: Deserializing WebService call...
Flex/Cairngorm
> 
>  
> 
> Yes, I'm not sure of the specifics myself but from my exploratory
> rummaging in the docs it looks like FDS handles all of that mapping.
> As I am using .NET on the server it looks like manual deserialization
> into my objects is the way forward.
> 
> I have begun implementing my app with the factory methods you
> suggested and all appears to be working well. Shame I can't get the
> object mapping without using Java/FDS. Perhaps once I have got to
> grips with it a bit more I might look into writing some sort of
> component for the web service users amongst us, which , judging by the
> volume of posts on this group regarding web services, amounts to a
> fair few folk.
> 
> Cheers
> 
> Graham
> 
> --- In [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com>
ups.com,
> "ben.clinkinbeard"
> <ben.clinkinbeard@> wrote:
> >
> > There is a decent chance I am wrong about this but I think when you
> > use RemoteObject with FDS you set up some sort of Java <-> AS class
> > mapping in a config file.
> > 
> > Ben
> > 
> > 
> > --- In [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com>
ups.com,
> "grahampengelly" <graham@> wrote:
> > >
> > > Thanks Ben & Franck for your help. Like you Franck I couldn't
see why
> > > it would work to cast one completely unrelated thing to another but
> > > this is the way it appeared to be being done in the samples.
> > > 
> > > Of course, what I hadn't got to grips with is that the two samples
> > > that I was studying are both using RemoteObject rather than
WebService
> > > calls and consequently are returning something that can be cast...
> > > 
> > > Thanks...
> > > 
> > > Graham
> > > 
> > > --- In [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com>
> ups.com, "ben.clinkinbeard"
> > > <ben.clinkinbeard@> wrote:
> > > >
> > > > Nothing definitive here but I do have a couple of suggestions. Any
> > > > time I see ObjectProxy mentioned in an error description, I
> > > > immediately wonder if makeObjectsBindable is at fault. Try
> setting it
> > > > to false on your WS and see what happens.
> > > > 
> > > > Personally, I always use e4x as my resultFormat (for various
> reasons),
> > > > so I don't have experience casting to a custom object but if
you do
> > > > end up needing to use Franck's suggested methodology I would
> certainly
> > > > recommend creating a factory that will accept the SOAP return
values
> > > > and return an instance of your custom object.
> > > > 
> > > > HTH,
> > > > Ben
> > > > 
> > > > 
> > > > --- In [EMAIL PROTECTED] <mailto:flexcoders%40yahoogroups.com>
> ups.com, "grahampengelly" <graham@> wrote:
> > > > >
> > > > > I am just getting up to speed with the Cairngorm architecture
> > and have
> > > > > been struggling with this problem for a while. I have got to the
> > point
> > > > > where I am getting a response from my web service call that has
> > > the data
> > > > > in that I expect but I cannot seem to get it to deserialize
> into the
> > > > > object that I need.
> > > > > 
> > > > > The code (I have used IResponder rather than the cairngorm
> Responder
> > > > > here as suggested during an earlier post here 
> > > > > <http://groups.
> <http://groups.yahoo.com/group/flexcoders/message/47366>
> yahoo.com/group/flexcoders/message/47366> )
> > > > > 
> > > > > public function result( data:Object ):void
> > > > > {
> > > > > var event:ResultEvent = data as ResultEvent;
> > > > > 
> > > > > var testString:String = "";
> > > > > for each(var thing:Object in event.result)
> > > > > {
> > > > > testString += " " + thing + " ";
> > > > > }
> > > > > //test alert 1
> > > > > Alert.show(testString);
> > > > > //test alert 2
> > > > > Alert.show("event.result.Id = " +
> event.result.Id + ",
> > > > > event.result.Name = " + event.result.Name);
> > > > > 
> > > > > var tObj:TestObj = event.result as TestObj;
> > > > > Alert.show("TestObj.Id = " + tObj.Id);
> > > > > 
> > > > > }
> > > > > The test alerts print out:
> > > > > test 1: Graham 1
> > > > > test 2: "event.result.Id = 1, event.result.Name = Graham
> > > > > 
> > > > > The subsequent line throws an exception:
> > > > > 
> > > > > TypeError: Error #1034: Type Coercion failed: cannot convert
> > > > > mx.utils::[EMAIL PROTECTED] to HASAW.ClientApp.Model.TestObj.
> > > > > 
> > > > > The object that I am trying to create from the results looks
like
> > > this:
> > > > > 
> > > > > public class TestObj implements ValueObject
> > > > > {
> > > > > 
> > > > > public var Id:int;
> > > > > public var Name:String;
> > > > > public function TestObj()
> > > > > {
> > > > > Id = 0;
> > > > > Name = "";
> > > > > }
> > > > > }
> > > > > 
> > > > > 
> > > > > I have tried various implementations and can't get the web
service
> > > > > response to cast to TestObj. To be honest, I wouldn't have
thought
> > > that
> > > > > it should cast to TestObj but I have followed all of the code
> > samples
> > > > > for Cairngorm and they all do it like this.
> > > > > 
> > > > > I am using .NET for the web service which may be an issue as the
> > > samples
> > > > > don't. It is returning the following SOAP in event.result.body
> > > > > 
> > > > > <?xml version="1.0" encoding="utf-8" ?> - <#> 
> > > <soap:Envelope
> > > > > xmlns:soap="http://schemas.
> <http://schemas.xmlsoap.org/soap/envelope/> xmlsoap.org/soap/envelope/"
> > > > > xmlns:xsi="http://www.w3.
> <http://www.w3.org/2001/XMLSchema-instance>
org/2001/XMLSchema-instance" 
> > > > > xmlns:xsd="http://www.w3. <http://www.w3.org/2001/XMLSchema>
> org/2001/XMLSchema">
> > > > > <soap:Body> - <#> <GetTesterResponse xmlns=""> 
> - <#>
> > > > > <GetTesterResult> <Id>1</Id> 
> 
> > > > > <Name>Graham</Name> </GetTesterResult> 
> > > > > </GetTesterResponse> </soap:Body> </soap:Envelope>
> > > > > I know I could manually populate the object with the values
> but the
> > > > > objects I will be deserializing in the application are much more
> > > complex
> > > > > than this which would make a manual approach a pain.
> > > > > 
> > > > > Thanks in advance...
> > > > > 
> > > > > Graham
> > > > >
> > > >
> > >
> >
>






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to