views:

51

answers:

1

Hello, i'm trying to invoke a webservice written in nuSoap from a AS3 Flash app; i've read that, starting from AS3, webservice support has been removed in Flash (really don't understand why...); i've tried thid party solutions (be.wellconsidered, carlo alducente) but they don't work with the wsdl that nusoap generates. I'm really worried and i must use Flash and not Flex, can anyone help me?

Thanks in advance c.

+1  A: 

It's not lightweight (it adds something like 130 Kb to your swf), but you can use Flex's Webservice api in an Actionscript project without requiring any black magic other than adding the necessary swc's manually.

I've done this myself and have had no problems. I've added flex.swc, framework.swc, rpc.swc and utilities.swc (plus all the swc's in the locale folder). I didn't put much though to it, really, just added all swc's I found in the SDK until it compiled. Since the compiler will only add the referenced classes, it shouldn't make much difference and it was quick and easy.

I'm pasting some code, perhaps it's of help (most examples I've found use mxlm):

    private function setupWebService():void {
        _ws = new WebService();
        _ws.addEventListener(LoadEvent.LOAD,handleWsdlLoad);

        _ws.getFeeds.addEventListener(InvokeEvent.INVOKE,handleGetFeedsInvoke);         
        _ws.getFeeds.addEventListener(ResultEvent.RESULT,handleGetFeedsResult);
        _ws.getFeeds.addEventListener(FaultEvent.FAULT,handleGetFeedsFault);
        _ws.loadWSDL(_wsdlUrl);
    }   
    //  at some point, call this method; not sure if you have to wait until wsdl is loaded
    //  I think it's not necessary; if I recall correctly, all calls are enqueued
    private function testGetFeeds():void {
        _ws.getFeeds("some_param");
    }

Hope it helps.

PS. This is the WebService class I'm referring to in the code:

import mx.rpc.soap.WebService;  
Juan Pablo Califano
thank you very much !
Cris
Sure, no problem!
Juan Pablo Califano