3 Replies Latest reply on Jul 21, 2009 8:51 AM by BobFromTheYear5K

    HTTPService.send() not sending request

    BobFromTheYear5K

      Hello,

       

      I've got what is probably a newbie problem.

       

      I have an event handler for "creationComplete" in my MXML Application tag.

       

      In my event handler, I want to send a request to a back-end PHP page.

      private function onCreated():void
      {
           // Build the HTTP Request to send to the backend PHP. 
           // Retrieves the list of images for the current Property ID.
           var httpReq:HTTPService = new HTTPService();
                     
           httpReq.method       = "POST";
           httpReq.request      = "id=" + Application.application.parameters.propertyID;
           httpReq.resultFormat = "e4x";
           httpReq.useProxy     = false;
           httpReq.url          = "http://localhost:8080/services/getPropertyFiles.php";
                          
           httpReq.addEventListener( FaultEvent.FAULT, onReqFault );
           httpReq.addEventListener( ResultEvent.RESULT, onReqResult );
      
           Alert.show( "Sending Request" );
      
              // Send the request
           httpReq.send();
           Alert.show( "Request Sent" );
      }
      

       

      If I hit the PHP page directly, it behaves as expected.  If I run my Flex app, I see the "Sending Request" Alert, but the "Request Sent" Alert is never displayed, neither of my HTTPService event handlers is ever called, Firebug shows no requests to my the back-end PHP & the Apache logs also don't show any activity for the PHP page.

       

      I'm obviously doing something wrong here, but I can't figure out what it is.

       

      Any ideas?

       

      --bob

        • 1. Re: HTTPService.send() not sending request
          Gregory Lafrance Level 6

          Try simplifying this to perhaps call google or something, just to confirm it is something with how you are configure the HTTPService.

          • 2. Re: HTTPService.send() not sending request
            BobFromTheYear5K Level 1

            Solved my own problem.

             

            Here's the source in case it helps anyone else:

             

                        private function onCreated():void
                         {
                             // Build a parameters object
                             var params:Object = new Object();
                             params.id = Application.application.parameters.propertyID;
                            
                             // Build the HTTP Request to send to the backend PHP.
                             // Retrieves the list of images for the current Property ID.
                             var httpReq:HTTPService = new HTTPService();
                             httpReq.method       = "POST";
                             httpReq.request      = params;
                             httpReq.resultFormat = "e4x";
                             httpReq.useProxy     = false;
                             httpReq.url          = "http://localhost:8080/services/getPropertyFiles.php";
                            
                             // Add the listeners
                             httpReq.addEventListener( FaultEvent.FAULT, onReqFault );
                             httpReq.addEventListener( ResultEvent.RESULT, onReqResult );

             

                            // Send the request
                             httpReq.send();

                        }

             

            I replaced my parameter string with a parameter Object and voila!  Instant success.

             

            --bob

            • 3. Re: HTTPService.send() not sending request
              BobFromTheYear5K Level 1

              Hmmmm....

               

              That's odd.  The Source Insert didn't quite work that time....