我正在使用wsdl和soap调用Web服务。我编写了一个flex代码,它在文本区域中返回[object AsyncToken]作为输出。这意味着什么剂量? 代码:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:WebService id="DirectoryService" useProxy="false" wsdl="http://cmuicds.rutgers.edu/uicds/core/ws/services/DirectoryService.wsdl">
<mx:operation name="GetIncidentList" makeObjectsBindable="true"
resultFormat="e4x"
result="onResult(event);"
fault="onFault(event);"/>
</mx:WebService>
<mx:ApplicationControlBar dock="true">
<mx:Button id="button"
label="Get incidents from web service"
click="button_click()"/>
<mx:ComboBox id="cmb" dataProvider="{zipfls}" labelField="name" width="241" height="24"/>
<mx:TextArea id="textArea" x="10" y="40" width="616" height="61"/>
</mx:ApplicationControlBar>
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import flash.utils.ByteArray;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.utils.ObjectUtil;
import mx.collections.ArrayCollection;
import mx.rpc.soap.mxml.WebService;
[Bindable] private var zipfls:ArrayCollection;
private var flag:Boolean;
//private var byte:ByteArray;
private function button_click():void
{
DirectoryService.GetIncidentList();
//DirectoryService.GetIncidentListRequest();
flag = DirectoryService.canLoadWSDL();
//flag = DirectoryService.hasOwnProperty();
Alert.show("Testing....." + flag);
//Alert.show("Description GetIncidentList " +DirectoryService.GetIncidentList);
//Alert.show("Testing Arraaay....." + );
var objt:Object = DirectoryService.GetIncidentList();
textArea.text = objt.toString()
}
private function onResult(evt:ResultEvent):void
{
//Alert.show("Hi");
zipfls = evt.result as ArrayCollection;
//byte = new ByteArray();
//textArea.text = ObjectUtil.toString(evt.result);
// byte = evt.result as ByteArray;
Alert.show("Is data comming in? " + zipfls);
}
private function onFault(evt:FaultEvent):void
{
Alert.show(evt.type);
}
]]>
</mx:Script>
</mx:Application>
答案 0 :(得分:0)
AsyncToken
是对服务电话的引用。当呼叫返回时,AsyncToken
将分派一些事件并包含服务呼叫的结果。但是,您不需要使用Flex框架代码在后台处理的AsyncToken
。你想看的是onResult函数,它被设置为GetIncidentList操作的处理程序。
试试这段代码:
import mx.controls.Alert;
import flash.utils.ByteArray;
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.utils.ObjectUtil;
import mx.collections.ArrayCollection;
import mx.rpc.soap.mxml.WebService;
[Bindable] private var zipfls:ArrayCollection;
private var flag:Boolean;
private function button_click():void
{
flag = DirectoryService.canLoadWSDL();
DirectoryService.GetIncidentList();
Alert.show("Testing....." + flag);
}
private function onResult(evt:ResultEvent):void
{
Alert.show("Is data comming in? " + evt.result);
textArea.text = ObjectUtil.toString(evt.result);
}
private function onFault(evt:FaultEvent):void
{
Alert.show(evt.type);
}