This content has been marked as final. Show 5 replies
I'm pretty much in the same boat as you, just getting around to learning Flex. I spent the better part of a day trying to figure this out. The following is what I ended up with. I believe it's pretty close to what you are looking for:
First I defined the parameters (in this case I'm using XML):
var params:XML = new XML(<myXML>meh</myXML>);
then create a new HTTPSevice
var service:HTTPService = new HTTPService();
then set its atttrubutes accordingly
service.url = "url://to.your.service.name"
service.method = "post";
service.contentType = "application/xml";
service.resultFormat = "xml";
add a listener so we know when to parse results
then build the httpResult function that handles the result..
pretty basic, but I hope it helps.
Yep, that is how I would do it, though you can create the HTTPService in mxml if you want.
Also, I have heard of folks having trouble when they attempt to set the contentType. I have not tried it myself, since i have been creating my own XMLHttp sources, and have just sent my xml as a string.
I can't tell if that answers my question or not! I'll study it.
Again, I'm trying to SEND data from the browser TO the server. In HTML terms this would mean sending query data via a post or get. I have seen HTTPService examples of simply firing off a URL to receive a result, but I have NOT seen an example of actually building XML data on the Flex client side and somehow sending it to the server.
If your example I see where you define local XML in "params", but I don't see how that XML is sent to the server.
I have an example of using REST from a Flex application that communicates with Flickr. You are welcome to download the code and pick it apart:
Flickr Photo Search
Once the app has started, right click the mouse anywhere over it and select "View Source". The REST code is in the com.adobe.flickr.Flickr class.
At the bottom left corner of the View Source page you'll see a link to download the entire source.
Disclaimer: I am not a developer so don't judge the code too harshly :-) The code is not supported and use it at your own risk.
I tried the app. It's great! I'll study the source. Thanks for the help!