3 Replies Latest reply on Sep 4, 2008 12:02 PM by bitwyse

    Accessign webservice result from another mxml file

    amthekkel
      HI,
      I have an mxml application that uses the <mx:webservice function to load a wsdl and get some values. I have tested the code and it works fine and i can get the result and fault methods correctly.
      I would now like to call this service from another mxml file and use access the result or fault string accordingly.
      example scenario would be that when i load my main page, i would like the lookup values obtained from using the webservice to be available.

      i tried the following but didnt get any luck. Here lookup is the mxml file which contains the webservice, which i am importing in this file. GetLookValuesWithAuth is the operation name.
      {
      var l:lookup=new lookup;
      var s:AsyncToken=l.es.GetLookupValuesWithAuth.send();
      s.addResponder(new mx.rpc.Responder(onSResult,onSFault));
      }

      public function onSResult(e:ResultEvent):void{
      Alert.show("value is");
      var xy:XMLList=XMLList(e.result);
      lplist=xy.descendants("LOOKUPVALUES");
      Alert.show("lookup is "+lplist.toXMLString()+xy.toXMLString());
      }

      public function onSFault(e:FaultEvent):void
      {
      Alert.show("Fault is "+e.toString());
      }

      An example of the webservice call in lookup.mxml is shown below

      <mx:WebService id="e1" wsdl="{wsdl " result="resultHandler(event)" fault="mx.controls.Alert.show(event.fault.faultString.toString())>
      <mx:operation name="GetLookupValuesWithAuth" resultFormat="e4x">
      <mx:request>
      <databaseName>{database name}</databaseName>
      <userName>{username}</userName>
      <password>{password}</password>
      <lookupID>05855b98-75c7-4117-a91c-db59e9ea0204</lookupID>
      </mx:request>
      </mx:operation>

      Any suggestions?
        • 1. Re: Accessign webservice result from another mxml file
          Level 7

          "amthekkel" <webforumsuser@macromedia.com> wrote in message
          news:g9ovt2$e63$1@forums.macromedia.com...
          > HI,
          > I have an mxml application that uses the <mx:webservice function to load a
          > wsdl and get some values. I have tested the code and it works fine and i
          > can
          > get the result and fault methods correctly.
          > I would now like to call this service from another mxml file and use
          > access
          > the result or fault string accordingly.
          > example scenario would be that when i load my main page, i would like the
          > lookup values obtained from using the webservice to be available.
          >
          > i tried the following but didnt get any luck. Here lookup is the mxml file
          > which contains the webservice, which i am importing in this file.
          > GetLookValuesWithAuth is the operation name.
          > {
          > var l:lookup=new lookup;
          > var s:AsyncToken=l.es.GetLookupValuesWithAuth.send();
          > s.addResponder(new mx.rpc.Responder(onSResult,onSFault));
          > }
          >
          > public function onSResult(e:ResultEvent):void{
          > Alert.show("value is");
          > var xy:XMLList=XMLList(e.result);
          > lplist=xy.descendants("LOOKUPVALUES");
          > Alert.show("lookup is "+lplist.toXMLString()+xy.toXMLString());
          > }
          >
          > public function onSFault(e:FaultEvent):void
          > {
          > Alert.show("Fault is "+e.toString());
          > }
          >
          > An example of the webservice call in lookup.mxml is shown below
          >
          > <mx:WebService id="e1" wsdl="{wsdl " result="resultHandler(event)"

          I have no idea about web services, but it seems to me you should have a
          closing curly bracket in the wdsl property.

          HTH;

          Amy


          • 2. Re: Accessign webservice result from another mxml file
            amthekkel Level 1
            Hi Amy,

            that was copying mistake, the actual wsdl call had the proper braces.. I have tested the lookup file on its own and it works fine.

            I need to call the webservice in that file from a different mxml file.
            I know you don't deal much with webservice, but thanks for raising this issue.

            cheers
            abhi
            • 3. Re: Accessign webservice result from another mxml file
              bitwyse Level 1
              There are several ways to skin the cat. Hard coding references between the two components. NOT recommended, and loose coupling ( using Flex events ). Using events is the way to go for scalability, programmability and a few other abilities I'm sure.

              That being said, events can be confusing. All you have to do is to google Flex loose coupling to find many good examples. Below are a couple good ones. . . .

              http://www.adobe.com/devnet/flex/articles/loose_coupling.html
              http://flexblog.faratasystems.com/?p=170