Accessibility

TechNote (Archived)

Creating webservice stubs with wsdl2java in ColdFusion MX 6.1

Issue


ColdFusion MX automatically creates webservices stubs when usingcfinvoke, cfobject, orcreateObject() to call webservices and when registering webservices in the ColdFusion Administrator. Webservice stubs are Java classes that ColdFusion uses to communicate with the webservice. ColdFusion uses the wsdl2java utility included as part of Apache Axis to create these stubs. Once created, these stubs are stored under the cf_root/stubs directory.

There are times when it is useful to run the wsdl2java utility manually. For example, you may need to examine the stub source code in order to understand what is needed to successfully invoke a complex webservice. Furthermore, you may need to instantiate Java objects within the stub classes in order to populate the input arguments required by a webservice method.

Solution


While it is possible to use the wsdl2java.exe that is included as part of JRun, this is not recommended because it will use the version of Axis that ships with JRun. If you are troubleshooting a ColdFusion problem, it is better to call wsdl2java.jar directly and use the Axis classes that are included with ColdFusion MX. You must include webservices.jar in your classpath as shown in the following examples.

Standalone CFMX:

set CLASSPATH=C:/CFusionMX/lib/webservices.jar

c:\j2sdk1.4.2_10\bin\java -cp %CLASSPATH% org.apache.axis.wsdl.WSDL2Java -o c:\path\to\output\directory -v http://path/to/wsdl/file.wsdl

J2EE configuration on JRun:

set CLASSPATH=C:/JRun4/servers/CFMX61/cfusion-ear/cfusion-war/WEB-INF/cfusion/lib/webservices.jar

c:\j2sdk1.4.2_10\bin\java -cp %CLASSPATH% org.apache.axis.wsdl.WSDL2Java -o c:\path\to\output\directory -v http://path/to/wsdl/file.wsdl

J2EE configuration on Websphere:

set CFlib="C:\Program Files\WebSphere\AppServer\installedApps\dstanten-D380\Macromedia ColdFusion MX.ear\cfusion.war\WEB-INF\cfusion\lib"

set CLASSPATH=%CFlib%/webservices.jar

c:\j2sdk1.4.2_10\bin\java -cp %CLASSPATH% org.apache.axis.wsdl.WSDL2Java -o c:\path\to\output\directory -v http://path/to/wsdl/file.wsdl

The -o switch is used to specify the directory where you want the stubs saved. The -v switch can be used to provide verbose output. You provide the path to a WSDL file as the final argument. This can either be in the form of a URL, or you can specify the path to a WSDL file on disk.

Compiling:

To compile the stubs created by wsdl2java, you also need to include webservices.jarin the classpath. For example:

C:\j2sdk1.4.2_10\bin\javac -classpath C:/CFusionMX/lib/webservices.jar path/to/stub/source/*.java -verbose

Additional Information


Jrun livedocs on wsdl2java

Axis user's guide

Creating webservice stubs with wsdl2java in ColdFusion MX 7 (TechNote eaf0396)

AlertThis content requires Flash

To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Download the free Flash Player now!

Get Adobe Flash Player

Creative Commons License

Search Support


Document Details

ID:ea87b65

Products Affected:

coldfusion