[flexcoders] Re: Synchronous web service calls

2008-04-29 Thread jerusalem_pilgrim
Why can't you just use a web service calls counter in your code? 
Every time a request goes out, increment it, every time you get a
response, decrement it.  The Print Receipt button only gets enabled
if the counter is back to 0.


--- In flexcoders@yahoogroups.com, byte.sensei [EMAIL PROTECTED] wrote:
 data to produce a PDF receipt.  The problem is, if a user clicks Print 
 Receipt before all the save order web services have finished, then 
 they only get a partial receipt.  There's also not an easy way to 
 determine if all the web service calls are finished, so I can't 
 disable/enable the button based on that.




RE: [flexcoders] Re: Synchronous web service calls

2008-04-29 Thread Tracy Spratt
Yes, this works well.  Just be sure to increment the counter in the
fault handler as well so that in case of an error you run your
completion code.  You can even track which calls have returned
successfully and which error(very rare), and can inform the user, or
even re-send the failed call, or whatever.  

 

I use an array, push in a callId on send, associate that callId with the
call via AsyncToken, and on result/fault, remove the element. (keep a
list of faults if desired)

 

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of jerusalem_pilgrim
Sent: Tuesday, April 29, 2008 10:13 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Synchronous web service calls

 

Why can't you just use a web service calls counter in your code? 
Every time a request goes out, increment it, every time you get a
response, decrement it. The Print Receipt button only gets enabled
if the counter is back to 0.

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, byte.sensei [EMAIL PROTECTED] wrote:
 data to produce a PDF receipt. The problem is, if a user clicks Print

 Receipt before all the save order web services have finished, then 
 they only get a partial receipt. There's also not an easy way to 
 determine if all the web service calls are finished, so I can't 
 disable/enable the button based on that.

 



[flexcoders] Re: Synchronous web service calls

2008-04-29 Thread byte.sensei
Thanks for the replies.  This is (sort of) the direction I was headed, 
although I like your specific idea below.  I guess I'm still holding on 
to the synchronous world of coding I came from. ;)  I feel like I'm 
always having to come up with ways to deal with Flex's asynchronous 
behavior, and it seems to require alot of additional code/handling (in 
my opinion).  

Anyway, thanks for the specific counter idea below -- I'll give it a 
shot!


--- In flexcoders@yahoogroups.com, jerusalem_pilgrim 
[EMAIL PROTECTED] wrote:

 Why can't you just use a web service calls counter in your code? 
 Every time a request goes out, increment it, every time you get a
 response, decrement it.  The Print Receipt button only gets enabled
 if the counter is back to 0.
 
 
 --- In flexcoders@yahoogroups.com, byte.sensei byte.sensei@ wrote:
  data to produce a PDF receipt.  The problem is, if a user 
clicks Print 
  Receipt before all the save order web services have finished, then 
  they only get a partial receipt.  There's also not an easy way to 
  determine if all the web service calls are finished, so I can't 
  disable/enable the button based on that.





RE: [flexcoders] Re: Synchronous web service calls

2008-04-29 Thread Tracy Spratt
Resistance is futile.

Tracy

 



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of byte.sensei
Sent: Tuesday, April 29, 2008 10:58 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Synchronous web service calls

 

Thanks for the replies. This is (sort of) the direction I was headed, 
although I like your specific idea below. I guess I'm still holding on 
to the synchronous world of coding I came from. ;) I feel like I'm 
always having to come up with ways to deal with Flex's asynchronous 
behavior, and it seems to require alot of additional code/handling (in 
my opinion). 

Anyway, thanks for the specific counter idea below -- I'll give it a 
shot!

--- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com
, jerusalem_pilgrim 
[EMAIL PROTECTED] wrote:

 Why can't you just use a web service calls counter in your code? 
 Every time a request goes out, increment it, every time you get a
 response, decrement it. The Print Receipt button only gets enabled
 if the counter is back to 0.
 
 
 --- In flexcoders@yahoogroups.com
mailto:flexcoders%40yahoogroups.com , byte.sensei byte.sensei@
wrote:
  data to produce a PDF receipt. The problem is, if a user 
clicks Print 
  Receipt before all the save order web services have finished, then 
  they only get a partial receipt. There's also not an easy way to 
  determine if all the web service calls are finished, so I can't 
  disable/enable the button based on that.


 



[flexcoders] Re: Synchronous web service calls

2008-04-29 Thread dbronk
I actually agree with you.  Having a synchronous call would make life
so much easier in many places.  Yes, there are always ways to code
around it.  But, if I have a situation where I don't want the user to
do anything else, or any more logic to be run until I get the answer
back from the server, then it would be very nice if I could simply set
a flag for synchronous, make the call, wait for it to time out/error
out, then move on.  This kind of stuff comes up all the time and I
don't like having to add more lines of code and functions to code
around this.

But, I also agree that the default behavior should be async as in my
experience the majority of calls I want to be async.

Basically, it would be nice if the tool/language/etc. gave us, the
developer, the choice on which is the best way to implement rather
than forcing it.

I also realize that the main reason we don't have the option is
because it is not an easy thing to do.

Just my 2 cents,

Dale


--- In flexcoders@yahoogroups.com, byte.sensei [EMAIL PROTECTED] wrote:

 Thanks for the replies.  This is (sort of) the direction I was headed, 
 although I like your specific idea below.  I guess I'm still holding on 
 to the synchronous world of coding I came from. ;)  I feel like I'm 
 always having to come up with ways to deal with Flex's asynchronous 
 behavior, and it seems to require alot of additional code/handling (in 
 my opinion).  
 
 Anyway, thanks for the specific counter idea below -- I'll give it a 
 shot!
 
 
 --- In flexcoders@yahoogroups.com, jerusalem_pilgrim 
 elephantium@ wrote:
 
  Why can't you just use a web service calls counter in your code? 
  Every time a request goes out, increment it, every time you get a
  response, decrement it.  The Print Receipt button only gets enabled
  if the counter is back to 0.
  
  
  --- In flexcoders@yahoogroups.com, byte.sensei byte.sensei@ wrote:
   data to produce a PDF receipt.  The problem is, if a user 
 clicks Print 
   Receipt before all the save order web services have finished, then 
   they only get a partial receipt.  There's also not an easy way to 
   determine if all the web service calls are finished, so I can't 
   disable/enable the button based on that.
 





[flexcoders] Re: Synchronous web service calls

2008-04-29 Thread Amy
--- In flexcoders@yahoogroups.com, byte.sensei [EMAIL PROTECTED] 
wrote:

 OK, so I understand that Flex web service calls are asynchronous, 
and I 
 understand the many cases where this makes sense since you don't 
have 
 to hold up the UI experience while waiting for a web service or 
remote 
 procedure to return a result.
 
 However, I keep running into instances where this makes my life 
hell. 
 One example is the submission of an order on a Flex site I have.  
 Because of the way the order is handled, it is split into multiple 
 (smaller) orders and then each order is submitted/saved via a web 
 service call.  This means that one order could have 10+ web service 
 calls.  I have a Print Receipt button which then uses the saved 
order 
 data to produce a PDF receipt.  The problem is, if a user 
clicks Print 
 Receipt before all the save order web services have finished, then 
 they only get a partial receipt.  There's also not an easy way to 
 determine if all the web service calls are finished, so I can't 
 disable/enable the button based on that.

Is this what you want?

http://tinyurl.com/5zzxlz