2 Replies Latest reply on Feb 19, 2007 12:36 PM by jerryvos

    HTTPService XML contentType and Gets

      I have a flex front-end in which I'm trying to get data from a back-end using an HTTPService. I would like the service to use a GET, and make the request using the contenttype of application/xml. So for example here's an HTTPService that does this:
      <mx:HTTPService id="testService"

      When I go ahead and do the request (using testService.send()) it always does the request as a POST. If I change the HTTPService's contentType to "application/x-www-form-urlencoded" it works correctly as a GET.

      Does anyone have any pointers on how I could get this to work the way I want it? Is this a flex bug or an undocumented feature somewhere? Any workarounds?


      Here is the output I get when I put an <mx:TraceTarget> in the app with the contentType="application/xml":
      body = "<>"
      clientId = (null)
      contentType = "application/xml"
      destination = "DefaultHTTP"
      headers = (Object)#1
      httpHeaders = (Object)#2
      messageId = "3EB110BB-955A-9601-C595-C14D38E12C14"
      method = "POST"
      recordHeaders = false
      timestamp = 0
      timeToLive = 0
      url = "/pools/list"

        • 1. Re: HTTPService XML contentType and Gets
          dave cragg Level 2
          As far as I know, when using the GET methd, the Content-type header in the request serves no purpose as no data is being sent with the request. The Content-type header is generally used with POST requests, which might explain why Flex changes the method when it encounters the contentType setting.
          • 2. Re: HTTPService XML contentType and Gets
            jerryvos Level 1
            I think I may have been confused on the way flex goes about handling data requests. The final outcome I was looking for was that requests hitting the server from the flex app would have the accept type of 'application/xml' (so you'd do a .send() on the service and it would send out a request who's header would be ... Accept: application/xml).

            I was assuming that this parameter would change that, but I'm getting the feeling that that is more of an internal to the app setting than an outbound request parameter and that the browser will probably keep the same request header no matter what.

            So if you're running your flex app on Firefox your server is always going to see (for the time being)
            Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png ,*/*;q=0.5

            Hopefully that is clear.

            Anyone want to confirm/deny that?