Skip navigation
Currently Being Moderated

WebService response object in XML - parsing attributes

May 6, 2013 12:10 PM

Tags: #flex-4.6 #soap #web_services

Hi- new to Flex and I'm trying to parse out the attributes of the response object. I can get the entire object and see that its working, but I cant get just a single attribute. It pulls weather info for world cities. For example, I just want the location name and temperature.


Any advice on this? Thanks!


<?xml version="1.0"?>

<!-- fds\rpc\RPCResultFaultMXML.mxml -->

<mx:Application xmlns:mx=""




            import mx.rpc.soap.SOAPFault;        



            import mx.controls.Alert;

            import mx.utils.ObjectUtil;


            public function showErrorDialog(event:FaultEvent):void {

                // Handle operation fault.

      , "Error");


            public function defaultFault(event:FaultEvent):void {

                // Handle service fault.

                if (event.fault is SOAPFault) {

                    var fault:SOAPFault=event.fault as SOAPFault;

                    var faultElement:XML=fault.element;

                    // You could use E4X to traverse the raw fault element returned in the SOAP envelope.

                    // ...


      , "Error");              


            public function log(event:ResultEvent):void {

                // Handle result.




                //var len:int;

                //len = event.result.length;




                //var myXML:XML = new XML(event.result);






    <mx:WebService id="WeatherService" wsdl=""


        <mx:operation name="GetWeather"










    <mx:TextInput id="myCity" text="Madrid"/>

    <mx:TextInput id="myCountry" text="Spain"/>

    <!-- Call the web service operation with a Button click. -->

    <mx:Button width="60" label="Get Weather"


    <!-- Display the Weather -->

    <mx:Label text="Weather:"/>

    <mx:TextArea text="{WeatherService.GetWeather.lastResult}" height="200"/>


  • Currently Being Moderated
    May 9, 2013 12:28 PM   in reply to mole2000

    The WSDL says GetWeatherResponse is a string, and it appears to be a string of XML, so set <mx:operation resultFormat="object"> as this will unwrap the SOAP response value and leave a string typed value intact. You can then create a new ActionScript 3.0 E4X-based XML instance from the unwrapped string:


        var myXML:XML = new XML(event.result.toString());


    You can then travese the XML document using E4X syntax, a simple example is included below:




    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points