1 Reply Latest reply on Oct 6, 2011 2:24 PM by Flex harUI

    Flex - Parsing a SOAP Response (Please Help!)


      Greetings Experts!


      I have a SOAP response from a webservice (see below) that i am trying to parse to a datagrid.  The information that comes back to the result handler is in the format below.  I'm trying to figure out how to grab everything in ns1:data and populate that information to a grid.  I'm very new to flex - anyone out there who can help?  I'm 5 days in and need relief from the experts!  LOL!


      Thanks so much!








      <?xml version='1.0' encoding='utf-8'?>

      <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">


      <ns2:getNextTuplesResponse xmlns:ns2="http://www.domain.com/application/xsd">


      <ns1:data xmlns:ns1="http://domain.com/xsd">1-0</ns1:data>

      <ns1:data xmlns:ns1="http://domain.com/xsd">1317300</ns1:data>

      <ns1:data xmlns:ns1="http://domain.com/xsd">FEC:0 Application</ns1:data>

      <ns1:data xmlns:ns1="http://domain.com/xsd">Local</ns1:data>



      <ns1:data xmlns:ns1="http://domain.com/xsd">66-0</ns1:data>

      <ns1:data xmlns:ns1="http://domain.com/xsd">1316957248000</ns1:data>

      <ns1:data xmlns:ns1="http://domain.com/xsd">FEC:0  en</ns1:data>

      <ns1:data xmlns:ns1="http://domain.com/xsd">Local</ns1:data>



      <ns1:data xmlns:ns1="http://domain.com/xsd">66-1</ns1:data>

      <ns1:data xmlns:ns1="http://domain.com/xsd">13169000</ns1:data>

      <ns1:data xmlns:ns1="http://domain.com/xsd">FEation cn199</ns1:data>

      <ns1:data xmlns:ns1="http://domain.com/xsd">Local</ns1:data>














      There was one response that is close, but i'm not sure how to get it over the hump.





      You'll have to use NAMESPACES.  The code below is for illustration, you'll have to figure out the exact syntax that works, but to access data within XML that has namespaces (ns2, ns1) you could do something like ...


      var ns1:Namespace;

      var ns2:Namespace;

      var myData:XMLListCollection;


      myXML = XML(event.result.Data); // the data returned from the service

      ns2 = myXML.namespace("ns2"); // declare the namespaces

      ns1 = myXML.namespace("ns1");

      myData = new XMLListCollection( myXML.ns2::serviceResponse.return.ns1::data ); // use those namespaces to access the pieces of data you are interested in.