2

一旦我运行我的 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>
4

1 回答 1

1

检查 xmlns 命名空间。

我为模拟您的问题而编写的以下代码可以正常工作:

<?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 标记,它会失败。

编辑:如果您需要命名空间解决方法,我刚刚在这里用命名空间解决方案回答了 Jack Moores 的问题我的弹性代码没有正确解析肥皂响应

于 2013-01-14T13:15:36.983 回答