views:

487

answers:

1

hi,

im using the webservice component in my flex app but find im using the same code over and over again when using the same webservice calls through my app.

Are there any best practices for creating webservice components? Should i be putting all the code in an actionscript class and if so have you any samples?

+2  A: 

You may consider creating proxy classes for your web services. Flex 3 builder automatically does it for you but I've found it extremely bloated. You can take a look at it and create your own simple proxies.

I usually start with creating methods like this-

public function GetProducts(id:String, onSucess:Function, onFailure:Function) {
    //1. Create web service component and set properties
    //2. Call the WS and get a token
    //3. Add a responder to the token with closures wrapping onSuccess and onFailure
}
Chetan Sastry