3 Replies Latest reply on Dec 5, 2007 9:04 AM by interstar

    Huh? HTTPService returns same as sent

    interstar
      Newbie trying Flex and hitting a very confusing bug.

      I have an html server running on my local machine that expects a form with one field : "source", and returns another string. (both input and output are plain text, not XML)

      I'm trying to call this from a Flex client with the following :

      <mx:HTTPService id="httpservice" url=" http://127.0.0.1:8080/compile"
      method="POST" resultFormat="text" contentType="application/x-www-form-urlencoded"
      result="{Alert.show(String(event.result))}" >

      <mx:request>
      <source>{source.text}</source>
      </mx:request>
      </mx:HTTPService>

      What happens when I fire this off with an httpservice.send() is that I get the alert box popping up - but it contains the string that I'm sending (ie. the contents of the "source" tag.) rather than the result I'm expecting the server to return.

      If I call the same server from an ordinary HTML form in the browser, I get the expected result.

      So I'm assuming the server is working, and this is something I've done wrong in the Flex. But can't see what it could be. Am I short circuiting something? Putting the posted contents into the return event by mistake??
        • 1. Re: Huh? HTTPService returns same as sent
          atta707 Level 2
          two things come to my mind:

          1) add fault event listerner and see if something is breaking
          2) try removing request tag from HTTPService and add the {source.text} as argument to send method.

          ATTA
          • 2. Re: Huh? HTTPService returns same as sent
            ntsiii Level 3
            And use a result handler function instead of trying to do the work in-line:
            result="{Alert.show(String(event.result))}"
            instead:
            result="onResult(event)"

            private function onResult(event:ResultEvent):void
            var xmlResult:XML = XML(event.result);
            Alert.show(xmlResult.toXMLString());
            ...
            {

            Tracy
            • 3. Re: Huh? HTTPService returns same as sent
              interstar Level 1
              OK, solved it.

              Thanks for the help everyone.

              Was actually a combination of causes. Basically the Flex client was passing the data up to my server with lines separated by CHR(13) but because my server was running on the same (Windows) box, it thought that line-separators were CHR(13) CHR(10). Then, *because* it couldn't digest the incoming string *it* was just spitting the string out again.

              I thought my server was OK because Firefox was passing up the form with the 13-10 line separator and so my server was behaving correctly in that context.