Web services actionscript 3带参数的soap Web服务调用方法
我想使用actionscript 3调用soap Web服务上的函数 该函数有多个不同类型的参数(int字符串) 这是我到目前为止的代码Web services actionscript 3带参数的soap Web服务调用方法,web-services,apache-flex,actionscript,soap,Web Services,Apache Flex,Actionscript,Soap,我想使用actionscript 3调用soap Web服务上的函数 该函数有多个不同类型的参数(int字符串) 这是我到目前为止的代码 var ws:WebService = new WebService(); ws.wsdl = "http://.../Service.svc?WSDL"; ws.addEventListener(FaultEvent.FAULT, faultHandler); ws.addEventListener(LoadE
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>
?
?
?
?
因此,我的问题是:如何为方法调用提供参数username、password、productid和languageCode?
WebService
和RemoteObject
共享名为AbstractService
的相同基类。接口提供了方法getOperation(名称: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));
谢谢,但我的问题更多的是如何格式化参数?正如您所见,xml定义了一个严格的布局。gameListGetOperations.arguments只是一个数组。我从xml中看到,它需要两个可选参数—身份验证和语言代码。我建议尝试:
.arguments=[{密码:“xx”,用户名:“xx”,产品ID:“xx”},语言代码]代码>我遗漏了什么吗?