3

i want to call a function on a soap-webservice using actionscript 3.

the function has multiple parameters each of different type (int string).

this is the as-code i have so far.

    var ws:WebService = new WebService();
    ws.wsdl = "http://.../Service.svc?WSDL";        
    ws.addEventListener(FaultEvent.FAULT, faultHandler);
    ws.addEventListener(LoadEvent.LOAD, wsdlLoaded);
    ws.loadWSDL();

    function wsdlLoaded(event:LoadEvent):void {
        trace("loaded: " + event.toString());

        ws.GameListGet.addEventListener(ResultEvent.RESULT, GameListGetHandler);            
        ws.GameListGet();

        function GameListGetHandler(event:ResultEvent):void {               
            trace("ok"+event);
        }
    }

it fails because it doesnt have the necessay parameters provided which are defined by the webservice like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:service.com" xmlns:gre="http://schemas.datacontract.org/Common">
<soapenv:Header/>
<soapenv:Body>
  <urn:GameListGet>
     <!--Optional:-->
     <urn:authentication>
        <!--Optional:-->
        <gre:Password>?</gre:NrgsPassword>
        <!--Optional:-->
        <gre:Username>?</gre:NrgsUsername>
        <!--Optional:-->
        <gre:ProductId>?</gre:ProductId>
     </urn:authentication>
     <!--Optional:-->
     <urn:languageCode>?</urn:languageCode>
  </urn:GameListGet>
</soapenv:Body>
</soapenv:Envelope>

so my question is: how do i provide the parameters username, password, productid and languageCode to the method call?

1 Answer 1

3

WebService and RemoteObject share the same base class called AbstractService. The interface provides the method getOperation(name:String):AbstractOperation. My suggestion is to use the following construct:

var gameListGetOperation:AbstractOperation = ws.getOperation("GameListGet");
gameListGetOperation.arguments = [/*here you pass all needed arguments*/];

var token:AsyncToken = gameListGetOperation.send(); // this invokes the WS operation

// pass the callbacks to handle the result or fault
token.addResponder(new Responder(resultFunction, faultFunction)); 
2
  • thanks, but my problem is more about how to format the parameters? as you can see there is a strict layout defined by the xml. and the gameListGetOperations.arguments is just an array.
    – clamp
    Oct 27, 2011 at 14:10
  • 2
    what I see from the xml is that it expects 2 optional parameters - authentication and language code. I would suggest trying:.arguments = [{Password: "xx", Username: "xx", ProductId: "xx"}, "languageCode"]; Am I missing something? Oct 27, 2011 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.