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 />
<cftry>    
<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>    
</cftry>
    
<cfreturn _return />    
</cffunction>

And here's a handy usage example:

<cfscript>
remoteWebPublisher = "http://www.remoteDomain.com/path/to/myRemote.cfc?wsdl";
refreshStatus = refreshRemoteService(remoteWebPublisher);

ws = Createobject("
webservice",remoteWebPublisher);
myResult = ws.myRemoteMethod();
</cfscript>

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!

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