Note: This blog post is from 2007. Some content may be outdated--though not necessarily. Same with links and subsequent comments from myself or others. Corrections are welcome, in the comments. And I may revise the content as necessary.Have you ever wanted to see the Java source code for the proxy/stub that's created when you invoke a web service from Coldfusion? Well, here's a hidden gem in CF8 (one of dozens I discuss in my "hidden gems in cf8" talk) that does just this.
Curiously, it's only available when you invoke a web service using createObject(), not CFOBJECT or CFINVOKE.
It's enabled using the new ArgStruct argument that I discussed last month.
wsargs = structnew();
You may wonder why you have to put it in this argStruct when it's the only key being put in the structure. That's just the way it is. Of course, I could have created the structure using the new implicit array creation syntax, as in:
which replaces 2 lines with 1.
For those who don't care for CFSCRIPT
Of course, you don't need to use CFSCRIPT to use createObject, for those not comfortable with it. I could just as well have done it all in tags, as:
Where the Java source is placedSo where is the Java placed? In the same directory where the java proxy stubs have been placed since CF6: [coldfusion]/stubs/. In the case of the standalone version of CF8, that might be c:\coldfusion8\stubs.
Each invocation of a web service in CF (whether you use the saveJava option or not) will create a directory there, typically in a form like WS729914123 (one for each separate web service invoked by any CFML requests), and within the subdirectories of that directory you'll find class files reflecting the name of the called web service.
If you don't use the saveJava option, you'll see only class files. If you'll see corresponding .java source files for each.
Finally, note that the Java source files will be removed automatically if the web service is refreshed (manually or in the CF Admin) and you call it without the SaveJava option (which also means if you invoke it using CFOBJECT or CFINVOKE).
(*Update*: In the original entry, I said the source would be removed if you called the web service without the SaveJava option, but I should clarify that it's if you do that and you cause the web service to be refreshed, not just any call, since that would use the compiled result of the earlier call unless you told it to do otherwise.)
Still, for those who have long wished to better understand these Java proxy stubs, it's nice that we have the option to see the source if we want to.
Still more to comeThere's still more power in CF8 for those that like to tinker with the java proxy/stub generation. More on that in a later entry.
For more content like this:
Need more help with problems?
- Signup to get my blog posts by email:
- Follow my blog RSS feed
- View the rest of my blog posts
- View my blog posts on the Adobe CF portal
- If you may prefer direct help, rather than digging around here/elsewhere or via comments, I can help via my consulting services
- See that for more on how I can help a) over the web, safely and securely, b) usually very quickly, c) teaching you as we go, and d) with satisfaction guaranteed