Link: POSTing XML data, without using HTTPService

[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-

, , , ,

About James

James is a Senior New Media Developer at MMT Digital, and has BA(Hons) in Design for Interactive Media from the University of Gloucestershire. He loves designing and producing all sorts of website and Flash-related things, as well as prattling on about technologies.Day-to-day he works with Flash, Dreamweaver, Director, Microsoft Office Sharepoint Server 2007 (MOSS) and in his spare time he mucks about in Flex and Wordpress.Follow James on Twitter.

6 Responses to “Link: POSTing XML data, without using HTTPService”

  1. Wai Lam 22nd June, 2009 at 4:52 am # Reply

    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);

  2. James 22nd June, 2009 at 8:14 am # Reply

    Thanks Wai – that looks like a good solution too.

  3. Logan 22nd June, 2009 at 12:15 pm # Reply

    We use HTTPService for some of our XML POSTs to our RESTful web service. It seems to work fine for us.

    somevalue
    anothervalue

  4. Logan 22nd June, 2009 at 12:17 pm # Reply

    Oops, it ate my code:
    http://pastie.org/520067

  5. Hydrolyze 16th October, 2009 at 2:20 am # Reply

    Just wanted to say hello all. This is my first post.

    I came to learn a lot here.

  6. trertance 9th November, 2009 at 3:06 pm # Reply

    Hello.
    My PC worked slowly, many errors. Help me, please to fix buggs on my computer.
    I used Windows XP.
    With best regards,
    trertance

Leave a Reply

Note: This post is over 2 years old. You may want to check later in this blog to see if there is new information relevant to your comment.