0
wsdl 웹 서비스에서 키 값 쌍을 가져 와서 Flex에서 데이터 목록을 표시하는 방법은 무엇입니까? 도와주세요.Flex List는 웹 서비스의 키 값 쌍을 표시합니다.
wsdl 웹 서비스에서 키 값 쌍을 가져 와서 Flex에서 데이터 목록을 표시하는 방법은 무엇입니까? 도와주세요.Flex List는 웹 서비스의 키 값 쌍을 표시합니다.
웹 서비스 및 제공하는 데이터 유형에 따라 다릅니다. 많은 웹 서비스가 응답을 객체 목록으로 반환 할 수 있습니다. 다른 것들은 구조화 된 문자열을 제공합니다.
필자는 예제 XML을 문자열로 반환하는 간단한 공중 날씨 웹 서비스를 사용합니다. http://www.webservicex.com/globalweather.asmx?test
나는이 목록 얻기 위해 GetCitiesByCountry의 방법을 사용하십시오 :
// 소스 코드를
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600" creationComplete="init()">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.rpc.CallResponder;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import services.globalweather.Globalweather;
private var ws:Globalweather = new Globalweather();
private var getCitiesByCountryCR:CallResponder;
private function init():void
{
getCitiesByCountryCR = new CallResponder();
getCitiesByCountryCR.addEventListener(ResultEvent.RESULT, onResult);
getCitiesByCountryCR.addEventListener(FaultEvent.FAULT, onFault);
}
private function onResult(evt:ResultEvent):void
{
var xml:XML = new XML(evt.result);
var xmlList:XMLList = xml.Table.City;
taCities.text = "";
for each (var item:XML in xmlList)
{
taCities.text += item.toString() + String.fromCharCode(13);
}
}
private function onFault(evt:FaultEvent):void
{
Alert.show("Fault!");
}
protected function getCities(event:MouseEvent):void
{
getCitiesByCountryCR.token = ws.GetCitiesByCountry(tiCountry.text);
}
]]>
</fx:Script>
<s:VGroup x="20" y="20" width="330" height="200">
<s:HGroup verticalAlign="bottom">
<s:Label text="Enter country name:"/>
<s:TextInput id="tiCountry" text="France"/>
<s:Button x="202" y="10" label="Get cities!" click="getCities(event)"/>
</s:HGroup>
<s:TextArea id="taCities" height="100%" width="100%"/>
</s:VGroup>
</s:Application>
을
http://www.webservicex.com/globalweather.asmx?wsdl 이 테스트 페이지입니다 :
이
는 서비스 설명입니다