2 Replies Latest reply on Aug 13, 2006 2:14 PM by francois-yanick

    Trying to display result of a Web Service

      Hi, I try to test my first call to web service through Flex without any success. I created a simple web service in coldfusion to return the actual value of the session.language; which can be 1 or 2 and 1 is the default value in case the session have not yet initialized any session.language variable (see the code of my CFC).

      In Flex, I tried to call this web service, which seems to work. But, I have a hard time to display the value (1 or 2; depending on the result returning by the web service call) in my label (see the code of my Flex page).

      mushhitechFlex.cfc (can be called as this: http://www.mushhitech.com/cfc/mushhitechFlex.cfc?wsdl):

      <cffunction name="getActiveLanguage"
      description="Cette fonction sert à retourner la valeur du language d'après la session en cour. Soit 1 pour Français ou 2 pour English. À noter qu'une valeur par défaut est retourner dans l'éventualité ou la session n'est pas encore définie et/ou que la variable Session.language n'existe pas."
      hint="Fonction pour retourner la valeur de session.language - si elle existe - ou bien 1 dans le cas contraire."
      <cfset lang = 1>
      <cfif IsDefined("Session.language") and IsNumeric(Session.language)>
      <cfset lang = Session.language>
      <cfreturn lang>

      And here is my Flex Source Code to call the function getActiveLanguage:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
      backgroundGradientColors="[#FFFFFF, #B5DEFF]"
      horizontalAlign="center" verticalAlign="top"
      horizontalScrollPolicy="off" verticalScrollPolicy="off">

      import mx.rpc.http.HTTPService;
      import mx.rpc.soap.WebService;
      import mx.controls.Alert;
      import mx.rpc.IResponder;
      import mx.rpc.events.FaultEvent;

      <mx:WebService id="getSessionLanguage"
      wsdl=" http://www.mushhitech.com/cfc/mushhitechFlex.cfc?wsdl"
      fault="Alert.show(event.fault.faultString), 'Error'">
      <mx:operation name="getActiveLanguage">
      <!-- no parameter are needed for this function -->

      <mx:Button id="myButton" label="Get Lang" click="getSessionLanguage.getActiveLanguage.send()"/>
      <mx:Label id="myLabel" text="{getSessionLanguage.getActiveLanguage.result}" color="black" fontSize="18"/>

      Can somebody help me to understand what I have to do to make the result appear correctly in the label "myLabel"???