3 Replies Latest reply on Jul 10, 2009 7:45 AM by PeakDigital

    Communicate with a Perl script?


      There is an old Perl script on a web site I do not control that I need to send to via POST and harvest its result.


      I have tried setting up an HTTPService in my app with the Perl script's URL, set up fault handler and event handler functions. When I execute it, as far as I can tell nothing happens. There is no fault, and no result.


      My app has several HTTPServices sending POST to PHP and they're working fine. Is there something totally different about Perl?


      Searching for "Perl" on this board didn't give me any results. Can anyone point me in the right direction on this?




        • 1. Re: Communicate with a Perl script?
          meshgraphics Level 2

          The first thing you should do is create an html form and post to a perl file.  If you cant do that you cant do it form flex.

          • 2. Re: Communicate with a Perl script?
            PeakDigital Level 1

            Thanks for the reply and suggestion. I did that before starting in Flex, the HTML form works perfectly.



            An update... I tried converting all the values to strings and this time I am at least getting a faultEvent response. I'll see if I can figure out what it means.

            • 3. Re: Communicate with a Perl script?
              PeakDigital Level 1

              This keeps getting more strange.  It did start sending a result back that I was able to review in debug mode. However, the Perl script was only seeing part of the parameters, and misreading some of the ones it did see. For example, out of 9 parameters, it saw only 3, and one of them - the year - it misread. I submitted 2009 for the year, and it picked it up as 2001.Other times posting identical parameters it just choked.


              I have tried defining the POST parameters in Actionscript in an object, like:


              var objPerlScript_Params:Object=new Object;

              I also made a static request definition in MXML, with the same result.


              My last attempt last night was to try cURL in PHP. It worked perfectly on the first try.

              $ch = curl_init();    // initialize curl handle
              curl_setopt($ch, CURLOPT_POST, 1); // set POST method
              curl_setopt($ch, CURLOPT_POSTFIELDS, "item1=2&itemb="something"); // add POST fields
              $result = curl_exec($ch);

              My only theory at this point is that something in the way Flex formats the POST data is incompatible with the old Perl script. I wonder if it uses some old encoding type that is incompatible with Flex's default "application/x-www-form-urlencoded" ??


              So I guess I'll be building this solution in PHP, then pass the finished data in XML to my Flex app. I was hoping to avoid that extra step. Hopefully posting this workaround can help someone else out there.