bpurcell.org - Using URL Parameters in a Flex HTTPService
Calendar
SunMonTueWedThuFriSat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

Subject Archives
Amazon EC2 (15)
ColdFusionMX (155)
Corvette (3)
Flash Lite (4)
Flash Media Server (5)
Flash Player (3)
Flex (39)
General Web Dev (14)
HDTV (3)
Jboss (1)
Jquery (2)
JRun (59)
Max 2003 (3)
Other (33)
PC Hardware (16)
Software (17)
SpatialKey (7)
Wireless (8)
Working Out (1)

RSS Feed
Feed Listing

Site Contents
Home
My Blog
ColdFusion
JRun
Flex
Wireless & Networking
Hardware & Gadgets
HDTV
Software Picks
Pictures
Contact Me
Search


My Articles & Papers
Flex Performance
Server/Client
mm.com Under the Hood
Multiple Instances of CFMX
Multiple Instance Config
NLB with ColdFusion
Clustering CFMX for J2EE
Multi-Tier Hardware LB w CFMX
Cisco CSS & Coldfusion MX
JRun 4 Jini based Clustering
WiFi Growth

2ID Tacweb

Other Hobbys
Body-For-Life Challenge

Personal Projects
Family Pool
Deck Gate

username:
password:
 

 
Viewing Individual Entry / Main
August 31, 2004

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>

Comments

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!


 
Page Render Time:390