Refresh Coldfusion Web Service WSDL definition stub programmatically

Working on a project that requires two coldfusion servers to chat with each other through web services; something I haven't had to do for many years now. Anyway, as soon as I made a change to my publishing CFC, my consuming CFC started complaining. Seems that the server caches the WSDL signature of the remote cfc. That is great for production, but not so much for development. So, practically crawling into the wayback machine, I quickly found Brandon Purcell's nearly 6 year old solution to Refreshing Web Service Stubs in ColdFusion MX. With two moments worth of added abstraction:

<cffunction name="refreshRemoteService" access="public" output="false" returntype="boolean">
<cfargument name="service" type="string" required="true" />
<cfset var _return = true />
<cfobject type="JAVA" action="Create" name="factory" class="coldfusion.server.ServiceFactory" />     
<cfset RpcService = factory.XmlRpcService />    
<cfset RpcService.refreshWebService(arguments.service) />    
<cfcatch type="any"><cfset _return = false /></cfcatch>    
<cfreturn _return />    

And here's a handy usage example:

remoteWebPublisher = "";
refreshStatus = refreshRemoteService(remoteWebPublisher);

ws = Createobject("
myResult = ws.myRemoteMethod();

Something worth remembering.

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Robert Rawlins's Gravatar Yeah we deal fairly extensively with web services here between CF and a bunch of different client platforms and this caching issues always grinds my gears in a development situation.

However, if you're using CF8 both createObject() and cfinvoke have a 'refreshWSDL' argument you can pass to them in order to have it refresh the docs for you!

# Posted By Robert Rawlins | 8/14/09 11:14 AM
BlogCFC was created by Raymond Camden. This blog is running version Contact Blog Owner