1 Reply Latest reply on May 7, 2008 1:11 PM by ntsiii

    How do I get an array back out of the ResultEvent from a WebService call

    Mike Bauer
      I have a web service that replies with an array of moderately complex objects. All the other calls I make return simple types, like String or bool, but this one is an array of object, each with several properties.

      What I can't figure out is how to use what I am getting back, the ResultEvent, to grab the elements of this "array". I tried casting like such:
      var results:Array = result.result as Array;

      But it throws all sorts of errors at me. I have confirmed, using WireShark, that the response packet does include the array of objects.

      Here is a sample of the response I am trying to process:
      <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv=" http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns2:getPendingMessagesOut xmlns:ns2=" http://providers.server.bindpoint.com"><ns2:messages><ns1:userSource xmlns:ns1=" http://common.bindpoint.com/gen">user1</ns1:userSource><ns1:destinationBindpointName xmlns:ns1=" http://common.bindpoint.com/gen">general</ns1:destinationBindpointName><ns1:payload xmlns:ns1=" http://common.bindpoint.com/gen">test</ns1:payload></ns2:messages></ns2:getPendingMessages Out>
      </soapenv:Body></soapenv:Envelope>
        • 1. Re: How do I get an array back out of the ResultEvent from a WebService call
          ntsiii Level 3
          set resultFormat="e4x" on your HTTPService tag, then in the handler do:
          var xmlResult:XML = XML(event.result);
          trace(xmlResult.toXMLString)

          Then use e4x expressions to select the desired list of nodes. It will return an XMLList, which has many similarities to Array.

          If you want to stick with the default nested object structure, examine the result object (objUtil.toString(), if i recall correctly) to determine how to craft the correct navigational path.

          Tracy