Using Java Web Services with CFMX
By Pete Freitag
JWS files are nothing more than a Java class with a .jws extension. But when placed on a web server with Axis installed (such as ColdFusion MX), you can expose that class as a web service. This works just like CFC's do in ColdFusion. Here's an example JWS we will call CaseService.jws:
public class CaseService { public String toUpper(String str) { return str.toUpperCase(); } public String toLower(String str) { return str.toLowerCase(); } }
If we add a ?wsdl to the url, it displays the WSDL for the service just like in CFMX. Let's try to invoke it in CFML:
<cfset case = CreateObject("webservice", "http://localhost:8500/CaseService.jws?wsdl")> <cfset result = case.toUpper("Case Me uP!")> <cfoutput>#result#</cfoutput>
It should display CASE ME UP!
This may be a better way to go than CFC's if your exposing Java classes as web services in CFMX. JWS files appear to work on both Pro and Enterprise versions of CFMX.
Using Java Web Services with CFMX was first published on January 21, 2004.
If you like reading about coldfusion, jws, or web services then you might also like:
The FuseGuard Web Application Firewall for ColdFusion & CFML is a high performance, customizable engine that blocks various attacks against your ColdFusion applications.
CFBreak
The weekly newsletter for the CFML Community
Comments
How about returning more complex objects, such as custom classes?
http://www.cfide.org/getColumnLength.html