Consuming a Web Service through Flash Remoting and CFForm
One of the lesser-known features of the Flash Remoting gateway is to act as a proxy to a web service. Using this proxy, you can effectively circumvent the cross-domain restrictions in the flash player, as all calls are local to the flash movie.
It turns out to be very easy to make the call. It is almost exactly the same as calling a local CFC
What changes is that instead of setting our service to "myPath.to.cfc", we set it to the actual web service address:
myService = connection.getService(
"http://weblogs.macromedia.com/mxna/webservices/mxna2.cfc?wsdl", responseHandler );
and then call the desired function:
myService.getMostRecentPosts(50,0,1);
I am using the MXNA Web Service (http://weblogs.macromedia.com/mxna/webservices/mxna2.cfc?wsdl) as an example.
The tricky part is that the Web Service Proxy is not enabled by default in ColdFusion’s Remoting gateway. To enable it, open the gateway-config.xml file in C:\CFusionMX7\wwwroot\WEB-INF (or similar path) and uncomment
<adapter>coldfusion.flash.adapter.CFWSAdapter</adapter>
inside the
Asher Gilbert
I've just finished building this photo album application using the remoting features and upload features recently explained on this blog. Thanks alot guys. Top Draw!
<br>
<a href="http://varian.zealio.com/screenshots/photoAlbum.jpg" target="_blank"><img src="http://varian.zealio.com/screenshots/photoAlbum-thumb.jpg" width="210" height="166" border="0"></a>
Michael
I have used most of the examples on the site to create rich interactive forms, but want to move furthur and hoped you could push me in the right direction.
Thanks in advance
Nahuel
We have a small list with some great books.
http://www.asfusion.com/bookmarks/category/flash-books
Michael
veejay
Laura
Do you want to do that in a cfform? If so, no, it is not possible.
If you want to do it in Flash (not cfform) check the Flash documentation for the Web Service component.
Douglas Knudsen
Douglas Knudsen
John Barrett
Laura, thanks so much for this, I am reading this, and I got it to work on my Mac, and I am actully starting to understand`-`
I am so stoked a local way of checking the lastest blogs, and with flash forms WOW!! It is a beautiful application`-`
One question?
What happen to the link to buy you something? Am I blind, or did you take the amazon wish list off??
Thanks again!`-`
John
Lesley
I am getting the error Element COMPONENTPATH is undefined in REQUEST.
Here is the code that is in question:
Public function setUpRemoting(): Void{
<cfoutput>
var connection:mx.remoting.Connection = mx.remoting.NetServices.createGatewayConnection("http://#cgi.HTTP_HOST#/flashservices/gateway/");
var componentPath = MHC.services.ListingService";
var componentPath:String = "#request.componentPath#.services.ListingService";
</cfoutput>
Can anyone help me debugg this?
Laura
Remove this variable and replace it with your particular path, whatever it is.
var componentPath:String = "#request.componentPath#.services.ListingService";
to something like:
var componentPath:String = "THE.PATH.TO.YOUR.CFC";
Laura
Lesley
Here are the error messages:
5 Errors found.
Error /MHC/Test-.mxml:1147
';' expected
Error /MHC/Test-.mxml:1147
The statement 'Public' is incomplete.
Error /MHC/Test-.mxml:1221
Attribute used outside class.
Error /MHC/Test-.mxml:1235
Attribute used outside class.
Error /MHC/Test-.mxml:1273
Unexpected '>' encountered
Lesley
Tim
I have recently found an issue that i need some help understanding.
I have a CFForm that calls my CFC on load and fills a data grid.
Most of the time it works fine but once in a while i can see it fill the grid on load then simply disapear.
Any idea what can cause this?
Here is my function that calls my cfc and fills the grid:
<code>
function setAttendance(UID):Void{
<cfoutput>#conn#</cfoutput>
var vacgrid = vacgrid;
var pergrid = pergrid;
var sickgrid = sickgrid;
var uatService:mx.remoting.NetServiceProxy;
var uatHandler = {};uatHandler.onResult = function(uatresults:Object):Void {
vacgrid.dataProvider = uatresults.VAC; pergrid.dataProvider = uatresults.PER; sickgrid.dataProvider = uatresults.SIC;}
uatHandler.onStatus = function(stat:Object):Void {alert("Error while gettiing Attendance Values:" + stat.description);}
uatService = connection.getService("CFC.users", uatHandler);
uatService.HR_attendance(UID);
}
<cfgrid name="vacgrid" rowheaders="false" height="130">
<cfgridcolumn name="name" header=""/>
<cfgridcolumn name="days" header="Days"/>
<cfgridcolumn name="hours" header="Hours"/>
</cfgrid>
<code>
thanks in advance
tim
Laura
See this post:
http://www.asfusion.com/blog/entry/knowing-when-the-cfform-data-arrives
Tim
Thanks for the quick post, i can resolve this by the following:
remove the remoting and call the cfc through cfscript and assign the result the query tag of the grid.
I seem to have this issue anytime i try to load data in the onload of a form. in the past i just used a button to load the data.
I will read through the link you posted for some pointers though, thanks again
p.s. congrats on your cert!
was the test difficult?
tim
Jim
nsr
I'm getting following error:
Service threw an exception during method invocation: No service named fileexplorer.services.fileExplorer is known to Flash Remoting.
Note: I have enabled flash remoting by uncommenting <adapter>coldfusion.flash.adapter.CFWSAdapter</adapter>