I suggest you read the Flex/J2EE chapter that Steven and Ali posted on
theserverside since it discusses design approaches that can apply to
HTTPService even though it focuses on HTTPService:
http://www.theserverside.com/articles/content/Flex/Flex_Chapter20.pdf.

I believe that the 3 HTTPService tag approach will suit you best. I assume
that each URL generally meets some defined set of functionality; it's just
that different parameters can be used. Something to note is that the send()
method can take an object representing the request parameters. You do not
need to always set the request and then call send(); you can pass them in
for each call. Additionally (and this is where the chapter above will
really come into play) you get a token back from each call to send() that
you can then use for keeping track of the results as they go through. This
helps you avoid the clobbering that you're worried about.

So one of your HTTPService tags might look like this:

<mx:HTTPService id="service1" url="someurl"
result="service1Result(event.call.someIdentifier, event.result)" />

Then you might use it like this:

<mx:Script>
function callService1(arg1 : String, arg2 : String) : Void
{
var call = service1.send({name: arg1, role: arg2});
call.someIdentifier=arg1 + '_' + arg2;
}

function service1Result(id : String, result : Object) : Void
{
//do something based on id with result
}
</mx:Script>

There are many different ways of implementing the ideas behind this
approach. The main thing is that you can pass the request as parameters to
send (meaning you get to customize each call without having to create copies
for binding purposes) and that you get the call object back where you can
store for retrieval later.

HTH,

Matt

-----Original Message-----
From: nts333rd [mailto:[EMAIL PROTECTED] 
Sent: Thursday, April 29, 2004 7:30 AM
To: [email protected]
Subject: [flexcoders] Best architecture for instantiating/using HTTPService?

Say I have three HTTPServices I will use, and each has 5 different 
sets of request parameters and the reuslts need to go to a 
corresponding� 5 places. The .send is under programatic control.

Should I:
* create 15 <mx:HTTPService> tags (one for each query) in mxml

* create three <mx:HTTPService> tags (one for each url) in mxml and 
programatically set the request parameters and the result callback 
function

* create one <mx:HTTPService> tag and set everything programatically

* instantiate the HTTPService objects programatically

* create a component that provides a pool

* something else

I am concerned with speed, and the possibility of collision (starting 
to programatically change an instance's properties before it's data 
has come back from the prior call.

TIA,
Tracy



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 the Yahoo! Terms of Service. 


Reply via email to