Flushing a cached web service

When you use WebServices with ColdFusion, the WSDL ’stub’ is cached in CF Administrator (presumably for performance reasons).

This can be a pain when you need to change the WSDL and you don’t have access to CF Admin to flush the service which is the scenario I found myself in today.

Luckily for me I sit near some ColdFusion peeps who sorted me out with a little Java method (courtesy of the ServiceFactory) to flush a WSDL from a ColdFusion template.

Basically all you need to do is:

<cfset wsdl = "yourwsdlpath.wsdl">
<cfobject type="java" action="Create" name="factory" class="coldfusion.server.ServiceFactory">
<cfset RpcService = factory.XmlRpcService>
<cfset RpcService.refreshWebService(wsdl)>

I also wrapped it up in a little function:

<cffunction name="flushWebService" access="public" output="false" returnType="void" hint="Flush a cached WebService in ColdFusion Administrator">
	<cfargument name="wsdlURL" type="string" required="false" default="#getWSDLURL()#" hint="URL of the WSDL to flush" />

	<cfscript>

		var oFactory = createObject("java", "coldfusion.server.ServiceFactory");

		oFactory.XmlRpcService.refreshWebService(arguments.wsdlURL);
		return;

	</cfscript>

</cffunction>

Thanks Marko (and Mark)

After the fact I did some googling and found a great read from Doug Boude on Refreshing Cached ColdFusion Webservices Through the Back Door in case you’re interested.

Post a Comment or Leave a Trackback

2 Comments

  1. April 7, 2008 at 11:14 am | Permalink

    Of course, you could just use the _supported_ method. In CF8, both cfinvoke and cfobject have a refreshWSDL argument that lets you refresh the wsdl (obviously).

  2. April 7, 2008 at 11:24 am | Permalink

    @Ray – Ah another CF8 gem! Thanks for the info, unfortunately I’m on CF7 in production for a little while longer. But good to know for when we upgrade, thanks

One Trackback

  1. [...] Michael Sharman shows how to dynamically flush a cached web service in CF 7 (and Raymond Camden points out in the comments that there’s now a supported method for doing the same thing in CF8) [...]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*