Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / July 2007



Tip: Looking for answers? Try searching our database.

Remotely Accessing CFC

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ian Skinner - 26 Jul 2007 17:51 GMT
I have a cfc currently in the CustomTag folder so that is available to
any Colfsuion application on the server with the following path:
createObject("component","Security.ITB_User").  This has worked nicely
to date.

How would I access this CFC remotely for use with a new Flex
application?  To use my CFC's in this application I have had to very
accurately map the CFC from the webroot.  With this security cfc being
in the Custom tag folder it is not in the webroot.  Is it possible to
somehow map to this cfc directly?  If not, I presume I would need some
kind of facade cfc?  What exactly are the characteristics of a facade?

TIA
Ian Skinner
jmmorgan - 26 Jul 2007 18:32 GMT
You could create a proxy CFC under your webroot.

<cfcomponent displayname="Romote Proxy For Security.ITB_User"
extends="Security.ITB_User">
   
    <cffunction name="MyFunctionIWantToExpose" access="remote" returntype="void"
hint="Remote Proxy For MyFunctionIWantToExpose">

        <cfargument name="AnArgument" default="" type="string">

        <cfset super.MyFunctionIWantToExpose(argumentCollection = arguments) />

    </cffunction>
   
    <cffunction name="MyOtherFunctionIWantToExpose" access="remote"
returntype="query" hint="Remote Proxy For MyOtherFunctionIWantToExpose">
       
        <cfargument name="AnArgument" default="" type="string">
       
        <cfreturn super.MyOtherFunctionIWantToExpose(argumentCollection = arguments)
/>

    </cffunction>   
   
</cfcomponent>
Prabhu S - 27 Jul 2007 12:47 GMT
You can easily invoke the CFC remotely as a webservice. It could be very easy
to achieve.

<cfinvoke
   webservice = "http://localhost/cfcomponent/coldcomponent.cfc?wsdl"
   method = "method_name"
   returnVariable = "foo">
ssawka - 27 Jul 2007 16:27 GMT
Yes, it is possible to map to the CFC directly, by setting the access attribute
to "remote".  However there is a catch.  For this to work through a mapping,
you must edit the services-config.xml file that is located in the
cfusion.ear\cfusion.war\WEB-INF\flex directory of your CF server instance.  
Somewhere around line 22 of that file you should see:

     <use-mappings>false</use-mappings>

change that to:

   <use-mappings>true</use-mappings>

I'm not sure if you need to restart the CF instance or not.

However, from a security standpoint I would recommend using a remote facade
similar to what  jmmorgan suggested.  In fact, if you use ColdSpring, you can
get ColdSpring to generate this for you.

Hope this helps,
Sean
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.