Flex :: Posting XML without using

Alternate title: How I spent my weekend!

I needed to post a bit of XML to a a webserver (non-CF) for processing. I have done it in CFML using the following:

OK, easily enough in CFML, right? I thought I would build a new interface to my application using Flex. The post of XML to a webserver in Flex is as follows:

In theory this should work, in reality, it did not. I kept getting errors from the webserver stating that the XML was not formed correctly. Using ServiceCapture, I was able to verify that the xml going in was good. I also opened up my initial XML file with a hex editor to verify that there was nothing preceding the XML. All that checked out fine, but I still received errors.

It took quite a bit of research and a lot of trial and error, but I finally found the following snippet in the "ActionScript 3.0 Cookbook":

It's a bit verbose and may not be as pretty as the <mx:HttpService> tag, but it did the job and it allowed me to post my XML directly to the server for processing without containing it in a form field or as a name/value pair.

Sometimes the seemingly simplest of things can be a bit of a time consuming nightmare! There are a ton of resources out in the InterWeb, thankfully.

I <3 teh Int3rW3b

Related Blog Entries

Comments
Sudhir srinivas's Gravatar hi,
i notice that if i send a single element xml via POSt, it gets converted as a GET request in my server. did you observe the same?

xml = "<test/>"
method = "POST"

comes into my server as a GET HTTP request and hence has no accompanyng data.

if i sent "<test><dummy>true</dummy></test>", it comes in fine
# Posted By Sudhir srinivas | 9/27/07 12:56 PM
Bluny's Gravatar I read article ,and thank your reply.I test and those code run fine now.
# Posted By Bluny | 10/20/07 12:13 AM
BlogCFC was created by Raymond Camden. This blog is running version 5.9.1.001. Contact Blog Owner