5 Replies Latest reply on Jan 20, 2007 3:43 AM by hwzv

    UTF encoding for HTTPRequest

    hwzv Level 1
      We are sending data with a HTTP Service.
      <mx:HTTPService id="employees" useProxy="false" method="POST" url=" http://xxxxx:8080/WebServiceXXX/SnoopServlet"/>

      However I am losing some of the German Umlaute (some special German chars). The reason is, that the encoding (I am talking about the character encoding, not the form encoding) is not send with the POST request. Any chance to set this for the Service, e.g. explicitly setting the character set to UTF-8 for the POST request.
        • 1. UTF encoding for HTTPRequest
          Hugo_Core Level 1
          hi hwzv,

          I had the sample problem, i too use special characters.

          The problem isn´t from the Flex, is from the receiver Service. Per Exemple , for php we have to specify the CharSet type in the script.

          Here's a quote from a old post :

          quote:



          Very Nice!

          On the same subject i leave you with a dout:

          - I have a RIA similiar to xyco45 , but because im portuguese :P i use special characters like 'ç' or 'á'. And when i post data from flex with this caracters to the PHP Script, it changes to anothers like this '§'.

          I bet on the PHP Script..

          Tkz Core..





          quote:



          Got it!

          Here the Solution for my Question if anyone need:

          PHP:
          <?php
          ...
          header('Content-Type: text/html; charset=UTF-8;');
          ...
          mail($mailto, $subject,
          $messageproper,
          "From: [FRANCHISING]\n" .
          "MIME-Version: 1.0\n" .
          "Content-Type: text/html; charset=UTF-8;");
          ...
          ?>

          We must specifty the charSet type.




          Hope this help in same way..

          Core
          Regards
          • 2. Re: UTF encoding for HTTPRequest
            FlightGuy Level 1
            I haven't tried, but I would expect that the receiver service should honor the http header sent by flex. Have you tried this:

            myHTTPService.headers = {"Content-Type": "text/xml; charset=UTF-8"};

            in other words exactly as in the last post, but from the client to the server.

            Tim
            • 3. Re: UTF encoding for HTTPRequest
              hwzv Level 1
              First thanks for the feedback. It is already close to what I need.

              A) It is correct that it is the backend which causes the wrong decoding. My backend is a tomcat server.
              B) The solution is to give tomcat a hint, that the sent data are UTF encoded, the "hint" is the correct header. An alternative is to hardwire the backend servlet to UTF-8 encoding.
              C) On AS level it works already with the hint of yours: request.header = ...

              Only open: How do I set the same header for the tag
              <mx:HTTPService id="employees" .... headers="?????" />

              I have tried several things, but none worked.
              • 4. Re: UTF encoding for HTTPRequest
                FlightGuy Level 1
                type headers="{ {"Content-Type": "text/xml; charset=UTF-8"} }"
                • 5. Re: UTF encoding for HTTPRequest
                  hwzv Level 1
                  Yep,

                  headers="{{'Content-Type':'text/xml; charset=UTF-8'}}"

                  solves it.
                  Thanks for the help