2011-10-27 81 views
3

我想使用ActionScript 3.動作3肥皂web服務調用方法與參數

函數有每個不同類型的(INT串)的多個參數來調用上的Web網頁的功能。

這是迄今爲止的代碼。

<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> 

所以我的問題是:

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); 
     } 
    } 

,因爲它不具有由web服務這樣定義提供的necessay參數失敗如何提供參數的用戶名,密碼,產品ID和languageCode的方法調用?

回答

3

WebServiceRemoteObject共享相同的基類AbstractService。該界面提供了方法getOperation(name:String):AbstractOperation。我的建議是使用以下結構:

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)); 
+0

謝謝,但我的問題是更多關於如何格式化參數?正如你所看到的那樣,由xml定義了一個嚴格的佈局。和gameListGetOperations.arguments只是一個數組。 – clamp

+2

我從xml看到的是它期望2個可選參數 - 認證和語言代碼。我會建議嘗試:'.arguments = [{密碼:「xx」,用戶名:「xx」,ProductId:「xx」},「languageCode」];'我錯過了什麼? –

+0

好吧,我不知道這很容易。 – clamp