web-services - 带参数的 actionscript 3 soap webservices 调用方法

标签 web-services apache-flex actionscript soap

我想使用 actionscript 3 在 soap-webservice 上调用一个函数。

该函数有多个不同类型的参数(int string)。

这是我目前的代码。

    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 服务定义的必要参数,如下所示:

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

所以我的问题是:如何为方法调用提供参数用户名、密码、productid 和 languageCode?

最佳答案

WebServiceRemoteObject 共享同一个名为 AbstractService 的基类。该接口(interface)提供方法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)); 

关于web-services - 带参数的 actionscript 3 soap webservices 调用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7915744/

相关文章:

flash - 如何在 iOs 的 Flash 应用程序中播放视频 (iPhone Packager)

apache-flex - Flex 弹出管理器 : How can I detect the existence of a modal popup?

java - JSON 有模式吗?

python - 自定义域路由到 Flask 服务器,自定义域始终显示在地址栏中

java.sql.SQLException : Parameter index out of range (3 > number of parameters, 这是 2)

apache-flex - 中继器内的 Flex Datagrid - 数据绑定(bind)警告

apache-flex - Flash Builder 4.7 Ant 构建问题

apache-flex - 是否要求()调用Flex ActionScript构造函数?

flash - 需要能够用鼠标绘制箭头并能够选择它

c# - 如何异步调用两个方法?