运行我的Flex应用程序后,它成功获取SOAP响应并在下拉框中填充值,但它们是空的,换句话说,当我将鼠标悬停在我的下拉框中时,我可以看到它有三个空值
我的灵活代码
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function
dropDownList_creationCompleteHandler(event:FlexEvent):void
{
myResults.token = myservice.myUsers();
}
]]>
</fx:Script>
<fx:Declarations>
<myservice:myservice id="myservice"/>
<s:CallResponder id="myResults"/>
</fx:Declarations>
<s:FormItem label="Label">
<s:DropDownList id="dropDownList"
creationComplete="dropDownList_creationCompleteHandler(event)"
labelField="name">
<s:AsyncListView list="{myResults.lastResult}"/>
</s:DropDownList>
</s:FormItem>
XML
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<myusersResponse xmlns="http://Services.com">
<myusersReturn>
<name>Nicole</name>
<age>50</age>
</myusersReturn>
<myusersReturn>
<name>Jayne</name>
<age>40</age>
</myusersReturn>
<myusersReturn>
<name>Alex</name>
<age>33</age>
</myusersReturn>
</myusersResponse>
</soapenv:Body>
</soapenv:Envelope>
答案 0 :(得分:1)
检查xmlns namspace。
我写的以下代码模拟你的问题很好:
<?xml version="1.0" encoding="utf-8"?>
<![CDATA[
import mx.collections.XMLListCollection;
import mx.events.FlexEvent;
import mx.messaging.messages.SOAPMessage;
[Bindable]
var _result:*;
protected function
dropDownList_creationCompleteHandler(event:FlexEvent):void
{
var xml:XML = <Body>
<myusersResponse>
<myusersReturn>
<name>Nicole</name>
<age>50</age>
</myusersReturn>
<myusersReturn>
<name>Jayne</name>
<age>40</age>
</myusersReturn>
<myusersReturn>
<name>Alex</name>
<age>33</age>
</myusersReturn>
</myusersResponse>
</Body>;
_result = new XMLListCollection(new XMLList(xml.myusersResponse.myusersReturn));
}
]]>
</fx:Script>
<fx:Declarations>
</fx:Declarations>
<s:FormItem label="Label">
<s:DropDownList id="dropDownList"
creationComplete="dropDownList_creationCompleteHandler(event)"
labelField="name">
<s:AsyncListView list="{_result}"/>
</s:DropDownList>
</s:FormItem>
但是如果你将xmlns =“http://Services.com添加到myusersResponse标签,它就会失败。
编辑: 如果您需要命名空间解决方法,我刚刚在此处使用名称空间解决方案My flex code does not parse the soap response properly
回答了Jack Moores问题