3 Replies Latest reply on Feb 9, 2011 9:00 AM by gpjax

    httpmultiservice problem

    eugene.p

      Hi,


      I need some help with httpmultiservice. I couldn't find any example how its being used.
      Could someone please provide me at least some dummy example to get started
      ??

       

      THnx

        • 1. Re: httpmultiservice problem
          UbuntuPenguin Level 4

          multiservice ?

          • 2. Re: httpmultiservice problem
            jmessary Level 1

            Haven't seen a "multiservice" but here is an example of an HTTPService to return results from a php page.

             

             

            <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                           xmlns:s="library://ns.adobe.com/flex/spark"
                           xmlns:mx="library://ns.adobe.com/flex/mx"
                           width="100%" height="100%" creationComplete="init();">

             

            *******SCRIPT IN YOUR MXML*********************************************************************

            <fx:Script>
                    <![CDATA[

             

                      protected function init():void

                      {

                           my_service.send();

                      }

                      protected function get_product_service_resultHandler(event:ResultEvent):void
                        {
                            Alert.show(""+event.result);                         
                        }

            </fx:Script>

            ****************************************************************************************** ***************

             

             

            ****************************FX DECLARATION*******************************************************

            <fx:Declarations>

             

                <s:HTTPService id="my_service" url="SCRIPT LOCATION" result="my_service_resultHandler(event)" resultFormat="e4x">
                        <s:request>
                            <action>some_function</action>               
                        </s:request>
                    </s:HTTPService>

            </fx:Declarations>

            ****************************************************************************************** **************

             

             

             

            ******PHP********************************************************************************* ****

            <? header("Content-type: text/xml");

             

            //This variable is in the <request> array from your mxml page.

             

            $action=$_REQUEST['action'];

             

            switch($action)
            {
                 case "some_function":    some_function();
                                                       break;
                 //multiple cases allows for one script page to be used for all of your service calls
            }

             


            //Function to login a user.
            function some_function()
            {
                
                 $xml="";

                    $xml="<?xml version='1.0' encoding='utf-8'?>";
                     $xml .= "<data>";
                         $xml.="<result>";
                             $xml.="<node_name>Hello World</node_name>";
                         $xml.="</result>";
                     $xml .= "</data>";
                                
                 echo $xml;
            }

             

            ****************************************************************************************** ***************