1 Reply Latest reply on Jan 23, 2008 10:37 PM by ntsiii

    Web Service, E4X, XMLListCollection

    live2design
      Hi,
      I am a .Net developer and a Flex newbie. I am using Flex Builder 2.0.1
      So here is my issue: I am trying to bind the result of a web service to a XMLListCollection. So as per the Flex documentation I set the result format to E4X and the source for the XMLListCollection as ws.op.lastResult. And when I try using the XMLListCollection as a dataProvider for a grid I am not able to see any results.

      But on the contrary if I DONT use XMLListCollection and leave the resultFormat as object, I am able to bind the web service result directly to the grid.

      I need the XMLListCollection because I would like to use the filterFunction of XMLListCollection.

      Here is the code that is not giving me results:
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" width="600" height="450" creationComplete="wsService.GetAllSchools.send()">

      <mx:WebService id="wsService"
      wsdl=" http://localhost/webservice.asmx?wsdl"
      useProxy="false">
      <mx:operation name="GetAllSchools" resultFormat="e4x">
      <mx:request>
      </mx:request>
      </mx:operation>
      </mx:WebService>

      <mx:XMLListCollection id="myXmlCollection" source="{wsService.GetAllSchools.lastResult}" />

      <mx:DataGrid id="mygrid" dataProvider="{myXmlCollection}">
      <mx:columns>
      <mx:DataGridColumn headerText="Id" dataField="Id"/>
      <mx:DataGridColumn headerText="Name" dataField="Name"/>
      </mx:columns>
      </mx:DataGrid>
      </mx:Application>
        • 1. Re: Web Service, E4X, XMLListCollection
          ntsiii Level 3
          The problem is almos certainly with the dataProvider reference expression. the problem with doing it like you are is that you can't easily debug your result.

          I advise using a result handler function. get the event.result, cast/convert it to XML, then trace the xml.toXMLString. You will be able to see your data and its exact structure.

          From looking at your code, I suspect you need to go one level deeper into the xml. The expression needs to return an XMLList. Looks like you are referencing the root node. Can't tell you what to use because I don't know your xml.

          Tracy