Skip to main content
Inspiring
January 28, 2010
Question

How to export a list of all Coldfusion web services/methods

  • January 28, 2010
  • 2 replies
  • 873 views

We are due for a security audit and we have been asked to give a list of all web services and method calls. We have approximately 250 methods spread across 50 cfcs.

I can see all of these in CF builder (beta 3) but I cannot see a way to copy or export the methods.

Is there a way to programically get all of the web services and methods on the server with "access=remote"? Basically, I would like to call the same API that the Services Browser in CF Builder is calling.

    This topic has been closed for replies.

    2 replies

    Inspiring
    January 28, 2010

    Take a look at topic "Using introspection to get information about components" in the documentation.  This may give you a starting point.

    http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec22c24-7dc5.html

    CoosAuthor
    Inspiring
    January 29, 2010

    Here's what I ended up using:

    <!--- get all cfcs --->


    <cfscript>
        myObj = createObject("component","cfide.componentutils.cfcexplorer");
        ws = myObj.getcfcs();
    </cfscript>

    <cfoutput>
    <cfloop from="1" to="#arrayLen(ws)#" index="s">

    <!--- my directory name to include  (Exclude all the built in CF cfcs) --->
    <cfif ws.name CONTAINS "private">
           
            <!--- get the properties of each cfc --->
           <cfset myCFC = createObject("component", "#ws.name#")>
           <cfset methodsObj = getMetaData(myCFC).functions>
          
           <cfset methods = "" />
           <cfloop from="1" to="#arrayLen(methodsObj)#" index="i">
                   <!--- boo! we have functions that have no 'access' property so check for its existance --->
                <cfif structkeyexists(methodsObj,"access") AND methodsObj.access EQ "remote">
                    <cfset methods = methods & "<li>" & methodsObj.name & "(" &")" & "</li>" >   
                </cfif>
           </cfloop>
           <!--- only display cfcs that have at least 1 remote method--->
           <cfif methods NEQ "">
           /#replace(ws.name,".","/","all")#.cfc<br>
          
           <ul>#methods#</ul><br>
           </cfif>
           
    </cfif>      

    </cfloop>
    </cfoutput>

    Message was edited by: Coos Code was not displaying (this has got to be the worst rich text editor I have ever used)

    Inspiring
    January 29, 2010

    Message was edited by: Coos Code was not displaying (this has got to be the worst rich text editor I have ever used)

    Yep. I don't know why Adobe aren't sufficiently embarrassed by this forums software as to ditch it.

    --

    Adam

    Inspiring
    January 28, 2010

    Hopefully they are all in the same directory, including subdirectories.  You can use cfdirectory plus query of queries to find your cfc files.  You can use cffile to open each one.

    If you are more clever than me, you might be able to use ReFind() to get your method names.