Refreshing Cached ColdFusion Webservices Through the Back Door
When developing CF webservices on a server that you don't have admin access to, it can be very frustrating (until you figure out the root cause) when you are making changes to your service and yet when you call it, the change doesn't seem to show up. Well, this is because ColdFusion caches its definition of the webservice, so subsequent changes can only be seen if that cached version is purged first.
This can be done via the CF administrator, but since many of us don't have access to the administrator, I share with you another solution...a backdoor to refresh these cached services.
Deleting a cached service will totally remove it from the cache (it'll be re-cached next time somebody calls it), while refreshing it will delete and then call the webservice again to grab a fresh copy of it. If running this on a shared server, you will see EVERYBODY's cached web services. Deleting or refreshing all services will do no harm, so no need to be concerned about touching someone else's stuff.
The code below should be copied into a single cf template. It's self calling in a generic way (using cgi.script_name), so no need to modify it in any way.
********************** The Code ************************************************************
This can be done via the CF administrator, but since many of us don't have access to the administrator, I share with you another solution...a backdoor to refresh these cached services.
Deleting a cached service will totally remove it from the cache (it'll be re-cached next time somebody calls it), while refreshing it will delete and then call the webservice again to grab a fresh copy of it. If running this on a shared server, you will see EVERYBODY's cached web services. Deleting or refreshing all services will do no harm, so no need to be concerned about touching someone else's stuff.
The code below should be copied into a single cf template. It's self calling in a generic way (using cgi.script_name), so no need to modify it in any way.
********************** The Code ************************************************************
<H2>Webservices in cache:</H2>
<cfobject action="CREATE" type="JAVA" class="coldfusion.server.ServiceFactory" name="factory">
<cfset xmlRpc = factory.getXMLRPCService()>
<cfset webServices = xmlRpc.mappings>
<cfparam name="url.del" default="false">
<cfparam name="url.refresh" default="false">
<cfoutput>
<cfif url.del>
<cfloop item="webService" collection="#webServices#">
<cfset xmlRpc.unregisterWebService(webService)>
</cfloop>
<cflocation url="#cgi.script_name#">
</cfif>
<cfif url.refresh>
<cfloop item="webService" collection="#webServices#">
<cfset xmlRpc.refreshWebService(webService)>
</cfloop>
<cflocation url="#cgi.script_name#">
</cfif>
<cfloop item="webService" collection="#webServices#">
- #webService#<BR>
<cfflush>
</cfloop>
<BR>
[<A HREF="#cgi.script_name#?del=1">KILL ALL</A>]
<BR>
[<A HREF="#cgi.script_name#?refresh=1">REFRESH ALL</A>]
</cfoutput>
<HR>
<cfobject action="CREATE" type="JAVA" class="coldfusion.server.ServiceFactory" name="factory">
<cfset xmlRpc = factory.getXMLRPCService()>
<cfset webServices = xmlRpc.mappings>
<cfparam name="url.del" default="false">
<cfparam name="url.refresh" default="false">
<cfoutput>
<cfif url.del>
<cfloop item="webService" collection="#webServices#">
<cfset xmlRpc.unregisterWebService(webService)>
</cfloop>
<cflocation url="#cgi.script_name#">
</cfif>
<cfif url.refresh>
<cfloop item="webService" collection="#webServices#">
<cfset xmlRpc.refreshWebService(webService)>
</cfloop>
<cflocation url="#cgi.script_name#">
</cfif>
<cfloop item="webService" collection="#webServices#">
- #webService#<BR>
<cfflush>
</cfloop>
<BR>
[<A HREF="#cgi.script_name#?del=1">KILL ALL</A>]
<BR>
[<A HREF="#cgi.script_name#?refresh=1">REFRESH ALL</A>]
</cfoutput>
<HR>
Subscription Options
You are not logged in, so your subscription status for this entry is unknown. You can login or register here.
Re: Refreshing Cached ColdFusion Webservices Through the Back Door
Thanks for the info...didn't realize they needed to be refreshed. Man, talk about hitting my head against a wall trying to figure out why my changes wouldn't fix the errors. Great info for those of us on shared servers (which i think is A LOT).
-Michael
-Michael
Posted by Michael on December 19, 2008 at 12:36 PM
Re: Refreshing Cached ColdFusion Webservices Through the Back Door
Thanks you very much exactly what I was looking for..
Posted by Jongr67 on June 17, 2011 at 12:55 PM


