0 Replies Latest reply on Jul 10, 2006 5:02 PM by CompositeKev

    Newbie - How to parse WS response with namespace

      I am a complete newbie to Flex, ActionScript et al, so please forgive me if my questions appear simplistic.

      I've implemented, and got working, the sample app which invokes a web service and displays the Top 5 popular posts from a blog service.

      I now want to modify this app so it calls my own homegrown web service. I have been able to get the invocation working, and I get a valid response, which I confirmed by displaying the lastResult object in a textbox.

      My problem now is I want to parse through the result document, which contains a namespace, and populate items on the form - I have not yet been successful in my attempts.

      Here is the source code to my MXML application, followed by the WS response document;

      MXML App
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="wsBlogAggr.getMostPopularPosts.send()">
      import mx.controls.Alert;
      public var csw:Namespace =
      new Namespace(" http://kevinobrien.composite.com/services/webservices/adobe/blogSvc/blogPort");

      <mx:WebService id="wsBlogAggr"
      wsdl=" http://localhost:9400/services/adobe?wsdl"
      <mx:operation name="getMostPopularPosts" resultFormat="e4x">
      <mx:request format="xml">
      <ns1:getMostPopularPosts xmlns:ns1=" http://kevinobrien.composite.com/services/webservices/adobe/blogSvc/blogPort">

      <mx:Panel x="10" y="10" width="475" height="400" layout="absolute" title="Most Popular Posts">

      <mx:TextArea text="{wsBlogAggr.getMostPopularPosts.lastResult.csw::getMostPopularPostsResponse.csw::Co lumnList.csw::row.csw::item}"/>

      <mx:ComboBox x="48" y="30" id="cbxNumPosts" change="wsBlogAggr.getMostPopularPosts.send()">
      <mx:Object label="Top 5" data="5"/>
      <mx:Object label="Top 10" data="10"/>
      <mx:Object label="Top 15" data="15"/>

      <mx:DataGrid x="48" y="80" id="dgTopPosts" columnWidth="400" dataProvider="{wsBlogAggr.getMostPopularPosts.lastResult}" width="350">
      <mx:DataGridColumn headerText="Top Posts" dataField="csw::getMostPopularPostsResponse.ColumnList.row.item"/>
      <mx:DataGridColumn headerText="Clicks" dataField="getMostPopularPostsResponse.ColumnList.row.item" width="75"/>
      <mx:LinkButton x="48" y="264" label="Select an item and click here for full post" click="navigateToURL(new URLRequest(dgTopPosts.selectedItem.postLink));"/>


      WS Response Doc
      <ns1:getMostPopularPostsResponse xmlns:ns1=" http://kevinobrien.composite.com/services/webservices/adobe/blogSvc/blogPort">

      I tried creating an XMLListCollection object, but I got a compile error that, being a newbie, did not make sense. Here is the syntax I used.

      <mx:XMLListCollection id="xc"

      Can anyone help with info on how to parse the response doc?