2 Replies Latest reply on Jul 3, 2008 12:12 AM by stigbn

    Reuse of Webserivce instance ?

      Hi all

      What is best practice when calling a webservice using the autogenerated webservice classes in Flex ?

      Right now I create a new webservice instance and hook up events for each call to a webservice method. I am considering if it would be better to have a single instance of the webservice object, and use this for all webservice calls ? - then I only need to hook up result and fault events once. So are there any problems in using a single webservice instnace for all webserivce calls ?


        • 1. Re: Reuse of Webserivce instance ?
          ntsiii Level 3
          No problems that I have ever seen. I always use a single instance of the WebService or HTTPService.

          In case you haven't discovered it yet, the send() methods return an AsyncToken, which is a dynamic object that is associated with the particular send call. You can put almost anything in that object, including callback functions. I typically just use a string callId, and sometimes a nextProcess string. In the result handler, you can access those properties, and know how to handle the result.

          There are examples in the docs, and I have posted some here as well.

          • 2. Re: Reuse of Webserivce instance ?
            stigbn Level 1
            Hi Tracy

            Thanks for the answer - that was just what I was hoping. Do you have some links to the examples you are mentioning ?