Steven,

Heh, yeah, sorry about that, I overlooked the fact that send() _does_ in fact return a pending call object. Which is sweet. (Actually, I now even remember thinking to myself, "hey, that's cool" the first time I read that in the docs, which was all of, oh, two weeks ago... )

We're using HTTPService because that's how our back-end talks to things in the current system (XML over HTTP) and we have a very efficient layer in there that takes care of dealing with the database. My Java sensibilities tell me that the RemoteObject stuff would be a much more elegant approach but at this point my time is better spent digging into Flex than reworking an already solid (if not quite cutting edge) back-end layer.

Thanks for the tips, and I'll look forward to seeing the book when it's done

- rdo

Steven Webster wrote:

Hi Ryan,

> problem I'm having is that with HTTPService there's no event.call object
> created when invoking send() to which I can attach a reference to a
> result event handler.


I'm not in the office right now, but are you *sure* that
there's no pending call object created for HTTPService - I'm
pretty sure that there was...

Since ActionScript 2.0 is so forgiving, you can attach what
you like to the pending call object; in the sample chapter
you talk about, the decision to create onResult and onFault
handlers was a convention we chose to adopt, but you
can attach whatever else you like to that call object.

So, you should be able to declare your service in the MXML
service locator, eg:

<mx:HTTPService id="mildyBetterThanCgiScript" ... />

and then do something like:

var pendingCall = mildlyBetterThanCgiScript.send();
pendingCall.timestamp = new Date();

Then, when you receive an asychronous event from your
call, you could do:

var timeOfCall = event.pendingCall.timestamp;
mx.core.Application.alert( "Call was made at: "+timeOfCall );

by way of example....

Maybe someone else can confirm that there's a pendingCall
object, but I seem to remember when writing the book, that
there was, and that this pattern we suggested was the
same for RemoteObject, WebService *and* HTTPService

Lemme know what works for you.

Incidentally, I'm interested as to what you're using HTTPService
for; is talking to your backend via RemoteObject a possibility ?

Best,

Steven

--
Steven Webster
Technical Director
iteration::two

So if I'm creating business delegate objects using
> references to the calling command (Responder), I have to add result and
> fault event listeners to the HTTPService for each business delegate,
> which causes all delegates to receive those events each time the
> HTTPService is invoked (instead of just the delegate that actually
> submitted the request). I suppose I could serialize requests and keep
> the appropriate responder as a static property of the delegate, but that
> seems like a restrictive solution. Any ideas? Thanks
>
> - rdo
>






Reply via email to