Title: Re: [flexcoders] Help regarding WebServices (FLEX) in Actionscript
Franck,

PM me directly on [EMAIL PROTECTED] and ill send though the code for the ws queue I developed. It will save you some sleepless nights believe me !

Samuel


On 15/8/06 20:28, "Franck de Bruijn" <[EMAIL PROTECTED]> wrote:


 
 

Hi Samuel,
 
Hmmmm.... Sounds a little complicated to me :)
 
I have built a small demo-application that has all the intricacies of what I call an Enterprise Administrative System. The webservices look like this:
In Flex I have ‘dynamic’ ActionScript classes that extend mx.rpc.soap.WebService.
 
Let’s take the LoginWebService as an example, to see how I deal with webservices.
 
Somewhere at application startup I do the following:
  • var loginService:LoginService;
  • loginImpl = new LoginWebServiceImpl();
  • loginService.addEventListener(LoadEvent.LOAD, handleWsLoaded);
  • loginService.addEventListener(“fault”, handleWsError);
  • loginService.loadWSDL(<your relative URL here>);

Then, in the handleWsLoaded() method you could for example enable the Login button (as I do). The loginService variable I keep somewhere statically available, so that I can always reuse it in my application.
 
After the user has entered his username/password combination, I do the following:
  • loginService.login.addEventListener(“result”, handleResultEvent);
  • loginService.login.addEventListener(“fault”, handleFaultEvent);
  • loginService.login(“username”, “password”)

Then, in your handleResultEvent you can retrieve your results (my login method gives back a UserSession object, which has all kinds of properties and a sub-object):
  • private function handleResultEvent (aEvent:ResultEvent):void
  • var userSession:UserSession;
  • userSession = UserSession.parse(aEvent.result);

Don’t bother about the UserSession part; it’s the aEvent.result part where you get your info.
 
I have to admit that I did not try this yet in Flex 2, official release. I’m still in the process of acquiring a license ... it’s a little bit of a political challenge :). But I presume that this code will still be valid; otherwise I have a huge problem myself.
 
Recently, I see al this AsyncToken stuff popping up ... I don’t know where that comes from. I never used it ... and I hope I’ll never will.
 
My 2 cents,
Cheers,
Franck


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Samuel D. Colak
Sent: Tuesday, August 15, 2006 6:34 PM
To: [email protected]
Subject: Re: [flexcoders] Help regarding WebServices (FLEX) in Actionscript


Hey Franck,

You use how many wsdl’s? Wow – I always thought that one wsdl caters for many functions. What I do, in psuedo code, is create a queue (array of objects) inside a class – the class instantiates the wsdl reference, and keeps this connected (until the app dies or the world ends) – I only need to do this once per wsdl and then when I call a webservice, I instantiate a AbstactOperation as a class inside the array. Add a couple of event catchers and you have a capability to call many webservices asynchronously and very very little code to burn. You have to be careful with the AsyncToken, as you mentioned a number of sleepless nights, as you cant guarantee that you see something in there after the send operation. This took about 2 days to work out before I suddenly “homer’d”.

Samuel

On 15/8/06 06:34, "Franck de Bruijn" <[EMAIL PROTECTED]> wrote:



 
 

Hi Samuel,
 
Good to hear that it works now. It’s the tedious hours chasing a stupid bug that gives the greatest learning curve!
 
When I start up my application I load all the WSDLs I need. For each load I register on the LoadEvent. I know how much WSDLs I’m loading, so I count the number of events that I receive back. Only when I have received all WSDLs I unlock the ‘Login’ button. In my opinion you have to wait until all WSDLs have loaded successfully, otherwise it has no use to start your application.
 
I only (try to) use MXML for the visual parts. For all other parts like models, controllers, webservices and the like I’m using actionscript.
 
Cheers,
Franck
 



From: [email protected] [mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> On Behalf Of Samuel Colak
Sent: Sunday, August 13, 2006 5:43 PM
To: [email protected]
Subject: Re: [flexcoders] Help regarding WebServices (FLEX) in Actionscript




Franck,



i managed to get it working without any issues - yes i own ifeel3.com, so there arent any security violations as the flash file is originating from the same site.



The code issue you mention is very valid for the startup - once the wsdl is cached it doesnt take much more time - i forgot to take into account that when you query an iis server running dotNet framework, the system takes 1-2 seconds to load in the dlls etc to run the application framework - in all it was a learning curve involving a few hours of banging my head against the wall.. finally it works ;)



The async stuff is usefull for dealing with multiple calls simultaneously to the wsdl. When you do what you propose, you lock the wsdl from doing anything else than one call at a time.



Thanks for the headsup on the doc/literal issue - you are quite right, but i think i got that sneaky thing covered ;)



On another note its actually very interesting that the lack of clear actionscript documentation for the components - seems adobe is pushing everyone to use mxml which actually starts to tie your hands in a number of cases i can think of. But one thing for sure, i cant wait for Flex on Mac - it pains me to run two systems side by side and my trusty macbook pro no more than an mp3 player whilst coding on a dell ;(



Oh well - such is like ;) TTFN


 

On 13 Aug 2006, at 07:47, Franck de Bruijn wrote:




Hi Samuel,
 
A few things:

  • Are you sure that you host your Flex application also at the www.ifeel3.com <http://www.ifeel3.com/> site? This is a necessity for a Flex application to communicate with a webservice, due to Flash’s security model. (unless there is somewhere a crossdomain.xml file with the correct content ... check the documentation)
  • Your code might work, but not necessarily so.. The loadWSDL() operation is asynchronous, but takes quite some time to complete. Only after the loadWSDL() has completed (and then some milliseconds more ... see some recent threads in this mailing list) you can fire your operation. To accomplish this you have to register for the LoadEvent.LOAD event
  • I don’t know where all this AsyncToken stuff comes from, but invocation of webservices can be done much simpler. Just try: tsWS.createUser(sessionId, userName, dob).
  • Expect some difficulties with Flex and the support of DOC/Literal webservices; I see that you are probably using .Net and DOC/Literal, and there are some issues with it. Also check the mailing list for this.

HTH,
Franck
 



From: [email protected] [mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> On Behalf Of Samuel Colak
Sent: Sunday, August 13, 2006 1:29 AM
To: [email protected]
Subject: [flexcoders] Help regarding WebServices (FLEX) in Actionscript


var tsWS:WebService = new WebService();
tsWS.wsdl = "http://www.ifeel3. <http://www.ifeel3.com/webservices/service.asmx?WSDL> com/webservices/service.asmx?WSDL";
tsWS.loadWSDL();

var op:AbstractOperation = tsWS["createUser"];
tsWS.addEventListener("result", doResults);
tsWS.addEventListener("fault", doFailed);
var token:AsyncToken = op.send();
token.responder = new Responder(resultOut, null);

-----------------

All,

i am tring to access some webservices i have written in dotNet from Flex. If anyone can point
out where i am going wrong, please send me an email to [EMAIL PROTECTED] <mailto:sam.colak%40im-at-home.com> at-home.com.

The WSDL is publically visible - the only part missing are the eventlistening functions.

Many thanks,
Samuel






    




    

__._,_.___

--
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




__,_._,___

Reply via email to