有没有办法使用FLEX从Flash CS5提供的soap Web服务类?
答案 0 :(得分:1)
Here are some instructions来自做同样事情的人。
引用一些相关段落:
首先,您需要从flash cs5链接到flex webservices库,您可以在以下链接中找到它:
在您的Flash文档中,首先需要导入Web服务命名空间:C:\ Program Files(x86)\ Adobe \ Adobe Flash Builder 4 \的SDK \ 4.1.0 \框架\库
import mx.rpc.soap.*;
import mx.rpc.events.*;
import mx.rpc.AbstractOperation;
然后当您需要调用Web服务时,您需要初始化对象然后加载WSDL调用,在事件Load触发后,您可以从此Web服务调用任何方法:
var uNameWebService:WebService;
var serviceOperation:AbstractOperation;
CallService_btn.addEventListener(MouseEvent.CLICK, InitWebService);
function InitWebService(event:MouseEvent):void
{
Result_txt.text = "INIT"
uNameWebService = new WebService();
uNameWebService.loadWSDL("http://localhost:55166/Service1.asmx?WSDL");
uNameWebService.addEventListener(LoadEvent.LOAD, BuildServiceRequest);
}
function BuildServiceRequest(evt:LoadEvent)
{
Result_txt.text = "START"
serviceOperation = uNameWebService.getOperation("GetName");
serviceOperation.addEventListener(FaultEvent.FAULT, DisplayError);
serviceOperation.addEventListener(ResultEvent.RESULT, DisplayResult);
serviceOperation.send();
}
function DisplayError(evt:FaultEvent)
{
trace("error");
}
function DisplayResult(evt:ResultEvent)
{
var UserName:String = evt.result as String;
Result_txt.text = UserName;
}