I subclass ServiceLocator with an AS class rather than an MXML file.
In that class I declare the service variables, set some properties on
them (I usually set makeObjectsBindable to false), and in the
initServices() function call loadWSDL() on each of them.

The external xml file I spoke of is a config file for the whole app
that holds any number of settings that may need to be adjusted. The
items of interest to this discussion are the WSDL urls, and this is
done to facilitate using the same swf in different environments (dev,
integration, production, etc). So when my app starts up I load and
parse the config file, store it in the model, and then select (via
E4X) and load the WSDLs. Then I move on to whatever actions the app
needs to perform.

I suppose your analogy of selecting rows from a db does hold true in
some cases. If your app deals with a large number of services or there
is a possibility that you may not use some services then yes, my
approach may be inappropriate. However, the app I am currently working
on (and most I can think of) only deal with a handful of services (<=
5) and I know they will all be used, so doing the loading up front
makes sense.

To each his own.

Ben


--- In flexcoders@yahoogroups.com, "Leggett, Samuel B CTR NETPDTC,
N634" <[EMAIL PROTECTED]> wrote:
>
> I'm not trying to spar with you Ben. This discussion has been beneficial
> to myself and others who have read it, but it is degrading. So, I would
> like to add more clarity to my statements because it appears that there
> are some misunderstandings. Perhaps because I did not articulate myself
> fully?
>  
> > Altering a core class in a widely used framework and building your
> > apps to rely on that non-standard behavior is simpler? How so?
> First Cairngorm 2.1 is still in beta, so I wouldn't consider it widely
> used or a standard yet. Secondly, it isn't that hard to add a few lines
> of code to a class and recompile it; that is a pretty common task. In
> *context* to what I was proclaiming is that it is simpler for the
> ServiceLocator to make the call to loadWSDL internally INSTEAD of the
> client making that call and keeping track of how many times that call
> has been invoked. 
>  
> I have posted this recommendation on the Cairngorm discussion in hopes
> that it get's put in version 2.1. It would make it a more seamless
> change from Cairngorm 2.0 to 2.1 if they do add the call to loadWSDL in
> the ServiceLocator itself. 
>  
> > Again, how so? Loading a handful of text files during app startup is
> > not exactly what I would call a "performance penalty".
> Performance hit then. :) Think of it as I just need one record in the
> database, but I will select all of them. Logically, selecting all
> records in a database when only one is required would be superfluous.
> Loading all the WSDLs is superfluous also.
>  
>  
> Additionally, why are you storing your web services in an xml file? I
> store mine in a Services.mxml file as suggested. Is there any benefit to
> be gained from that? How does the ServiceLocator know to look at the xml
> file? Are you inheriting from the ServiceLocator with special logic to
> extract the services from that xml file? If you are, that seems
> unnecessary. The ServiceLocator was designed to read from the
> Services.mxml, right? Has that changed with version 2.1? Where is that
> documented?
>  
> -Bruce
>  
>  
>  
>  
>  
>  
>  
>  
>  
>  
> ________________________________
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of ben.clinkinbeard
> Sent: Wednesday, November 15, 2006 12:35
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Re: Cairngorm 2.1 why the ServiceLocator dosen't
> extends UIComponent anymore?
> 
> 
> 
> > The ServiceLocator should invoke that method, it's simpler that way.
> Altering a core class in a widely used framework and building your
> apps to rely on that non-standard behavior is simpler? How so?
> 
> > Your application will endure performance penalties from that.
> Again, how so? Loading a handful of text files during app startup is
> not exactly what I would call a "performance penalty".
> 
> Ben
> 
> --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> , "Leggett, Samuel B CTR NETPDTC,
> N634" <samuel.leggett.ctr@> wrote:
> >
> > > When you call getWebService(), you are calling it through your
> > > subclass of ServiceLocator. 
> > That is true; however, your subclass should not need to call loadWSDL.
> > The ServiceLocator should invoke that method, it's simpler that way.
> > 
> > > As far as needing to iterate over all of the services, I suppose
> that
> > > is true in some cases, but is that really a big deal? I would argue
> > > its not. 
> > That's ok. Your application will endure performance penalties from
> that.
> > 
> > ________________________________
> > 
> > From: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> [mailto:flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> ] On
> > Behalf Of ben.clinkinbeard
> > Sent: Tuesday, November 14, 2006 10:59
> > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> 
> > Subject: [flexcoders] Re: Cairngorm 2.1 why the ServiceLocator dosen't
> > extends UIComponent anymore?
> > 
> > 
> > 
> > Hi Bruce,
> > 
> > loadWSDL() is an asynchronous call, so you would need to implement a
> > listener to determine when the wsdl has been loaded, and only then
> > return from the getWebService() method.
> > 
> > As far as needing to iterate over all of the services, I suppose that
> > is true in some cases, but is that really a big deal? I would argue
> > its not. Personally, I have an xml config file where I store all
> > references to remote services, so getting a list of web services is a
> > simple E4X expression.
> > 
> > When you call getWebService(), you are calling it through your
> > subclass of ServiceLocator. Its an inherited method, yes, but you're
> > calling it through MyAppServices or whatever you name it.
> > 
> > HTH,
> > Ben
> > 
> > --- In flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > , "Leggett, Samuel B CTR NETPDTC,
> > N634" <samuel.leggett.ctr@> wrote:
> > >
> > > I agree with you Ben except it seems superfluous to try and load all
> > of
> > > the WSDLs upon creation of the ServiceLocator. Doing it that way
> means
> > > you have to iterate all the services of the ServiceLocator including
> > > RemoteObjects. I also don't believe that the loadWSDL() call belongs
> > in
> > > a subclass of ServiceLocator either; it is the responsibility of the
> > > ServiceLocator itself to ensure that the services returned are ready
> > for
> > > invocation. 
> > > 
> > > I would wrap the call to loadWSDL() in ServiceLocator's
> > getWebService()
> > > method something like this using a dictionary to determine whether
> or
> > > not a call to loadWSDL has been made on a given WebService:
> > > 
> > > 
> > > private var loadedWSDL : Dictionary;
> > > ...
> > > public function getWebService( serviceId : String ) : WebService
> > > {
> > > 
> > > var webService:WebService = 
> > > WebService( getServiceForId( serviceId ) );
> > > 
> > > if(this.loadedWSDL[serviceId] != true)
> > > {
> > > 
> > > webService.loadWSDL();
> > > // You could move the line below to a LOAD event handler
> > > providing that you can get the serviceId 
> > > // passed to it.
> > > loadedWSDL[serviceId] = true;
> > > 
> > > }
> > > 
> > > return webService;
> > > 
> > > 
> > > }
> > > 
> > > Note that this method hasn't been tested it is just psuedo code. Of
> > > course you need to inititalize the loadedWSDL dictionary upon
> > > construction of the ServiceLocator. 
> > > 
> > > -Bruce
> > > 
> > > 
> > > ________________________________
> > > 
> > > From: flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > [mailto:flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > ] On
> > > Behalf Of ben.clinkinbeard
> > > Sent: Monday, November 13, 2006 16:08
> > > To: flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com> 
> > > Subject: [flexcoders] Re: Cairngorm 2.1 why the ServiceLocator
> dosen't
> > > extends UIComponent anymore?
> > > 
> > > 
> > > 
> > > > I would just have ServiceLocator's getWebService method make a
> call
> > > to loadWSDL.
> > > 
> > > I wouldn't recommend that. Calling loadWSDL() more than once on the
> > > same resource will produce erratic results. Personally, I have an
> > > initServices() method in my ServiceLocator subclass that gets called
> > > once my app is initialized, and it calls loadWSDL() on all the
> > > different services used in my app. Unless you have an obscene amount
> > > of different web services that you use I would recommend this
> > approach.
> > > 
> > > HTH,
> > > Ben
> > > 
> > > --- In flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com>
> > > , "Leggett, Samuel B CTR NETPDTC,
> > > N634" <samuel.leggett.ctr@> wrote:
> > > >
> > > > I would just have ServiceLocator's getWebService method make a
> call
> > to
> > > > loadWSDL. Let me know if you experience any problems recompiling
> the
> > > > Cairngorm library
> > > > 
> > > > Bruce Leggett 
> > > > 
> > > > ________________________________
> > > > 
> > > > From: flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com>
> > > [mailto:flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com> 
> > <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com>
> > > ] On
> > > > Behalf Of Douglas McCarroll
> > > > Sent: Monday, November 13, 2006 13:50
> > > > To: flexcoders@yahoogroups.com
> <mailto:flexcoders%40yahoogroups.com>
> <mailto:flexcoders%40yahoogroups.com>
> > <mailto:flexcoders%40yahoogroups.com> 
> > > > Subject: Re: [flexcoders] Cairngorm 2.1 why the ServiceLocator
> > dosen't
> > > > extends UIComponent anymore?
> > > > 
> > > > 
> > > > 
> > > > > so I report this issue to the community to see if it is a wanted
> 
> > > > behavior or a bug
> > > > 
> > > > Hi Paolo,
> > > > 
> > > > Based on your description of inconsistent results being returned
> by 
> > > > loadWSDL() it certainly *sounds* buggy.
> > > > 
> > > > Hopefully the Cairngorm authors are reading this, scratching their
> 
> > > > heads, and thinking that they should investigate. :-)
> > > > 
> > > > In the meantime, me, I'd probably do what you've done - make 
> > > > ServiceLocator extend UIComponent, even if it's a kludge.
> > > > 
> > > > Also, have you searched flexcoders? I know that there have been
> > other 
> > > > posts on this issue. Try Googling "inurl:flexcoders loadWSDL" 
> > > > 
> > > > Douglas
> > > > 
> > > > Paolo Bernardini wrote:
> > > > > Thanks for the reply Douglas
> > > > > 
> > > > > I thought there was a reason for the change from version 2.0 to
> > 2.1 
> > > > > and like you said probably is that UIComponent includes 
> > > > > functionality not needed to the serviceLocator, but I was hoping
> > it
> > > to
> > > > 
> > > > > be backward compatible with not extra work.
> > > > > Unfortunately my skill are not good enough to solve this by
> myself
> > > so 
> > > > > I report this issue to the community to see if it is a wanted
> > > behavior
> > > > 
> > > > > or a bug, and point me to the right direction.
> > > > >
> > > > > 
> > > > >
> > > >
> > >
> >
>



Reply via email to