3

I'm working with webservices for iOS whose Request and Response are in JSON format. While accessing this webservice through flash builder, I'm getting response in XML format. But running the same app in iOS returns JSON.

 private function service_activate(webservices:mx.rpc.http.HTTPService):void{

            var args:String=new String("{\"SessionGuid\":\""+sessionid.text +"\"}");
            webservices.resultFormat="text";
            webservices.contentType="application/json";
            webservices.send(args);
           }

    <fx:Declarations>
        <s:HTTPService id="webservice"
                   url="http://webservices..."
                   method="POST" contentType="application/x-www-form-urlencoded"
                   result="webservice_resultHandler(event)"
                   fault="webservice_faultHandler(event)" />
    </fx:Declarations>

Is there any way to get FlashBuilder response as JSON?

nijas
  • 1,879
  • 2
  • 15
  • 13
  • `contentType` declares in what format the data will be sent, not how you wish to receive it. With `URLRequest` you could send a manually constructed request header, but AFAIK you can't use URLRequests with HTTPService. Right? – Creynders Jan 31 '13 at 16:19
  • You can try setting the Accept header as discussed in this question: http://stackoverflow.com/questions/4196139/set-json-content-type-on-shttpservice-in-flex – dannrob Apr 26 '13 at 14:04

1 Answers1

0

Is this a REST service? Is is Spring? You may be able to add the ".xml" to the end of the url before the parameters:

i.e.

http://localhost/rest/users/byLastName.xml?lastName=Smith

If it's Spring: Look and see if a ContentNegotiatingViewResolver is defined in your application context and what media types are defined in there.

TomSchober
  • 433
  • 4
  • 12