I ran into something that at first confused me but once I figured out what I was missing it made sense. If you try to invoke a URL with URL parameters you will get an error. For example when trying to load them XML from my blog RSS feed with the following code:
<mx:HTTPService url="http://www.bpurcell.org/blog/rss.cfm?mode=short&mode2=cat&catid=14"
id="myHTTPData" method="GET" resultFormat="xml">
The above code will cause the following error in Flex, "HTTPService Fault: Parameters are not allowed in the url, use the request object".
The correct approach is to use the mx:request object within the HTTPService call. The following code illustrates an approach that works correctly
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
initialize="myHTTPData.send();trace('calling service');">
<mx:Script>
<![CDATA[
var myURL:String="http://www.bpurcell.org/blog/rss.cfm";
var mode:String="short";
var mode2:String="cat";
var catid="14";
]]>
</mx:Script>
<!-- If you set resultFormat to Object it turns the returning data into an object -->
<mx:HTTPService url="{myURL}" id="myHTTPData" method="GET" resultFormat="object">
<mx:request>
<mode>{mode}</mode>
<mode2>{mode2}</mode2>
<catid>{catid}</catid>
</mx:request>
</mx:HTTPService>
<mx:TextArea text="{myHTTPData.result.RDF.channel.title}" width="250" />
<mx:TextArea text="{myHTTPData.result.RDF.item[0].description}"
width="250" height="200" />
<mx:TextArea text="{myHTTPData.result}" width="250" height="500" />
</mx:Application>
People like yourselves are a 'god send' for novices like myself. Thank you for this article it was useful to me. I do however have a slant on your solution...
I need to pass the following query string/http request to FileMaker -
http://localhost:591/FMPro?-db=NGP.fp5&-format=-dso_xml&-find
I obviously can't create an Element with a leading '-' for the '-db' name to then pass the value 'NGP.fp5'. Any ideas on how I could work around this one?
Thank you for your time.
I brandon can I do the same think with a RemoteObject? I need to set the attribute "endpoint" and the "source" for dynamically call a cfc, using a flashgateway. I tried to do as you do for HTTPService, but doesn't works. I posted to the MM forum (http://www.macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=346&threadid=1088657&enterthread=y) ,but no answer by now.
thnks
-- federico
Could you please help me on how to access the session From the HTTPService request on the server side?
Many thanks for this example!