4 Replies Latest reply on May 25, 2006 3:24 AM by ckshah

    Accessing webservice result - e4x format

    badu
      Hi

      (Flex 2 Beta version)

      I am having trouble gaining access to the child elements from a webservice call with a resultformat type of e4x.
      I am receiving the results as expected but I haven't been able to gain access to elements nested within the XML. I would like to be able to gain access to the ''modules'' elements within the results.

      For example, using the e4x format I should be able to access elements from the WSDL results:

      event.result.ns1::findEquipmentReturn.modules;
      (See the below code for complete app, just outputting to text field at the moment)

      Any help would be appreciated.
      Cheers
      Wayne




        • 1. Re: Accessing webservice result - e4x format
          ntsiii Level 3
          I am just starting with e4x, but...

          this expression:
          txt1.text = event.result.ns1::findEquipmentReturn
          would return the text node of findEquipmentReturn node, and in your xml there isn't any text node.

          You need to dot down to a node that has text. This should return something:
          txt1.text = event.result.ns1::findEquipmentReturn.centre.description;

          To get to modules, something like:
          event.result.ns1::findEquipmentReturn.modules.modules[0].id;

          Tracy
          • 2. Re: Accessing webservice result - e4x format
            badu Level 1
            Thanks for your response Tracy.

            I have tried drilling down in dot syntax with no luck.
            The only results I can output are at the event.result.ns1::findEquipmentReturn level.
            I get nothing when trying to access anything sub elements.

            txt1.text = event.result.ns1::findEquipmentReturn.centre.description; I agree with you that this should work according to the documentation I've seen but no go.


            • 3. Re: Accessing webservice result - e4x format
              ntsiii Level 3
              Put the result into a variable typed XML. Then do xml.toXMLString(), to see if it is structures the way you think.

              Tracy
              • 4. Re: Accessing webservice result - e4x format
                ckshah
                hi,

                u can send httprequest this way

                <mx:HTTPService id="FolderReq" url=" http://deepakt:8080/PopMailConnector/servlet/GetFolderList " method="POST" showBusyCursor="true"
                useProxy="false" resultFormat="e4x" result="initList(event)" fault="mx.controls.Alert.show(event.fault.faultDetail)">
                <mx:request>
                <rand>
                Math.rand();
                </rand>
                </mx:request>
                </mx:HTTPService>

                and

                retrive data in result event by calling initList method as mentioned above

                and then use this

                [Bindable]
                public var XLC:XML;
                public function initList(event:Event) : void
                {
                XLC = event.target.result;
                }
                u can get the result in e4x format