DG2- GUI and Design Group

Graphical User Interface, Developers and Designers

This is a public Group - Virtual  public

Upcoming Events

No results

Active Discussions

No results

Recent Blog Entries

  • Entry posted 12/16/08 by Lenny Fontes, tagged Development in Blog public

    I’ve built many web service based applications in Flash AS 2.0; and it’s always been a nightmare to track the Asyncronous calls to a web service, pending result responses and faults. But I was recently introduces to Flex Builder 3, running the 3.2 framework, and I’m feeling MUCH better about web services. I’m having issue when attempting to use the Flexbuilder GUI under Data> Importing Web Services (WSDL). So I’ve had to create my own classes and methods to support my applications; Then I researched ASyncToken, and IResponder and I was exstatic. let me show you some code:

    <mx:Script>
    <![CDATA[
    import mx.rpc.AsyncToken;
    import mx.rpc.Responder;
    import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.rpc.soap.mxml.WebService;
      private var ws:WebService�
    private var token:AsyncToken
    private var responder:mx.rpc.Responder
    public function init():void{
    var ws:WebService = new WebService();
    ws.wsdl = "http://myservice.com/?wsdl"

    }
    public function callMyTestMethod(params:*):void
    {
    token:ASyncToken = ws.myTestMethod();
    responder = new Responder(catchResult, catchFault)
    token.faultMessage = "myTestMethod Failed"
    token.otherParams = "other parameters"
    token.addResponder(responder);
    }

    private function catchResult(e:ResultEvent):void{
    myResultObject = e.results
    //Do something with the results. And by the way,�
    //access your Token object in this method through
    //the ResultEvent.token object;
    token = e.token;
    }

    private function catchFault(e:FaultEvent):void{
    //Don't forget the FaultEvent.token object...�
    token = e.token;
    mx.controls.Alert.show(e.fault.faultString, token.faultMessage)�
    //I've created a log method to track all errors as well.
    log(e.fault.getStackTrace());
    }
    ...

    Using this AsyncToken, and Responder interface, I’ve been able to successfully re-use a single WebService component, and track responses and faults from those services without serious concern. Now that I can track objects and pass parameters in the token, I’ve been able to daisy-chain services that are co-dependant to update data in a database, without the fear of the Race Condition.  The best part about it; no more  generic addEventListeners to the WebService. I can have a different listener per method.  –Lenny

     

     

    Flex 3, WebService, ASyncToken, IResponder

Assorted Media Gallery Posts

No results

Recently Posted References

No results

Search Group Posts

Contact Us

No results

Members

  • 1-19 of 19

Sponsors

No results

Recently Posted Job Listings

No results

Adobe Announcements

  • We made a big change to the Adobe Groups homepage today. Now, when you log in, you'll see a list of all groups that you have joined right there on the page.

    No more bookmarking groups or having to go to your profile page to see the full list!