Psyked *
it’s easy once you know how.Link: POSTing XML data, without using HTTPService
Posted by James - 21/06/09 at 06:06:49 pm[This came up a while ago, but I thought I'd promote the link I found that solved my woes.]
The situation: I’m trying to interact with a REST API, via Flex and AIR. Now, I know that the HTTPService class exists in Flex to make it really quick and easy to send and recieve data, but the downside of the HTTPService class is that it assumes a little top much. It assumes for example, that any data you’re trying to send comes in a name/value pair – which my data doesn’t. The REST webservice I’m using requires raw XML data, but the HTTPService class doesn’t do that.
The solution? Well, there’s only one – don’t use the HTTPService class, and code everything yourself. Thankfully, this link I found tells you exactly how to do that, along with examples.
http://tacfug.org/blog/index.cfm/2007/3/26/Flex–Posting-XML-without-using-mxhttpservice-



You can try post raw xml as text by.
var request:HTTPService = new HTTPService();
request.method = “post”;
request.resultFormat = “text”;
request.contentType = “text/xml”;
request.request = xml.toString();
request.send();
Also work with json by setting.
request.contentType = “application/json”;
request.request = JSON.encode(data);
Comment by Wai Lam — 22 June 2009 #
Thanks Wai – that looks like a good solution too.
Comment by James — 22 June 2009 #
We use HTTPService for some of our XML POSTs to our RESTful web service. It seems to work fine for us.
somevalue
anothervalue
Comment by Logan — 22 June 2009 #
Oops, it ate my code:
http://pastie.org/520067
Comment by Logan — 22 June 2009 #
Just wanted to say hello all. This is my first post.
I came to learn a lot here.
Comment by Hydrolyze — 16 October 2009 #
Hello.
My PC worked slowly, many errors. Help me, please to fix buggs on my computer.
I used Windows XP.
With best regards,
trertance
Comment by trertance — 9 November 2009 #