When you may need to refreshwsdl for calls to web services
Have you ever found that calls to web services from CF suddenly fail? when nothing has changed on your end? (No change of your CF version, no change of CF admin settings, nor any change regarding SSL/TLS on the host–all of which can cause their own problems.)
What may have happened is that the owner of the web service may have changed something about their definition of that web service (in terms of methods or properties or return types). And as such, you need to REFRESH CF’s caching of that web service definition.
This blog post explains the why’s and hows.
How CF caches the web service definition as Java “stubs”
Though many may not realize it, CF caches the call to the web service to obtain its WSDL (web services definition language), and CF then converts that into some java code (called “stubs”), which represent the web service definition in terms of those available methods, properties, return types, and so on.
And this conversion to Java stubs is saved in CF the first time a CFML call is made to that web service (saving them in the cfusion/stubs folder–or the stubs under some other CF instance’s folder, when you have multiple instances). Note that CF creates a separate folder for each called web service (each web service wsdl url, not for each method, nor for different calls to the same wsdl url).
And those stubs are reused on any subsequent calls from CFML to that web service.
When and how you may need to refresh that web service definition that CF has cached
Normally, such WSDL (for the web service you call) does not change, and this caching is a performance benefit. But when it does, then you may find you get an error because CF’s cached stubs don’t match the web service definition.
In that case, it’s up to you (on the CF side) to refresh that wsdl and re-generate those stubs. There are a few ways to do it.
(Technically, you COULD delete that folder (for the web service that has changed) within the stubs folder, but that’s not the most elegant way. You could delete the wrong one, or you may find that CF is trying to access the files while you re trying to delete the folder.)
Instead, CF offers a few ways to “refresh that wsdl”, two of which are most common.
Refreshing it in the CF Admin, if it’s listed there
CF used to keep a list in the CF Admin of all called web services, but somewhere along the line (CF10?), that changed and now it only lists web services in the Admin if you specifically define them there (one reason would be to give the web service an “alias” to refer to when invoking it, rather than the full wsdl url). Anyway, if you DO have a web service defined there, you can “refresh” it there.
Go to the CF Admin “Data & Services” menu option on the left (the section where Datasources are), and then choose “Web Services”, and then at the bottom of that page, see “Active ColdFusion Web Services”.
If the one you want is there, note there are buttons to the left, and one is a “refresh”, which will regenerate its web service stubs. Try your failing code and see if that solved your problem.
But if the one in question is NOT listed there, then the next simplest solution is to do the refresh in code, on the invocation of the web service itself.
Refreshing it via CFML code
Back in CF8, a new a refreshwsdl attribute was added for cfinvoke or cfobject, which if you set to true and then call the web service (as normal) will “refresh” it (and regenerate teh stubs for that web service). (There is also a way to do it on a createobject. See below.)
If your call now “works”, you’re done. (And you can go view the stubs folder to see that the folder for the service in question was updated)
Note that you do NOT want to LEAVE that refreshwsdl on the cfinvoke, though, as that would then refresh it on EVERY call. That would be bad for performance. So just remove or comment out that refreshwsdl to remind you should you ever need to do it again.
I have more on this topic (including if you use createobject, as well as using the AdminAPI or old “serviefactory” to refresh wsdl). The posts which follow, while old, still apply:
Hope that helps.