VMware vSphere Web Services SDK: JAX-WS Samples Readme

VMware logo

This document describes how to build and run the VMware sample code that uses the JAX-WS bindings for the vSphere API. The samples have been developed to work with the JAX-WS bundled with the JDK 1.6. They are located in sub-directories contained in the following vSphere Management SDK directory:

    SDK/vsphere-ws/java/JAXWS/samples/com/vmware/

The following sections contain information about building and running the JAX-WS vSphere API samples.

JAVAHOME Environment Variable

You must set the JAVAHOME environment variable to the base directory of a JDK 1.6, preferably b22.

Converting Shell Scripts for Linux

The vSphere Web Services SDK includes the following shell scripts in the SDK/vsphere-ws/java/JAX-WS/ directory.

  • build.sh - Generates stubs from the vSphere API WSDL and compiles the samples.
  • run.sh - Runs a sample.
  • clean.sh - Deletes sample .jar files.

The shell files in the distribution kit have DOS-style line endings. These do not work when running these scripts on Linux. Use the Linux command dos2unix to convert these files before you use them.

To run these scripts, set the Execute permission on the files:

    chmod u+awx *.sh

Building Sample Programs

The build scripts (build.sh and build.bat) generate vSphere API Java stubs from the vSphere API WSDL, compile the generated stubs, and compile the sample programs. You can specify the following command line options to control stub generation and compilation.

  • build -w  - Compiles sample programs but does not generate or compile stubs.
  • build -c   - Compiles stubs and sample programs; does not generate stubs.
WSDL File Dependency

JAX-WS requires a WSDL file for stub generation and compilation. To manage this dependency, the build script performs the following operations:

  • Uses the JDK tool wsimport to generate the vSphere Web services Java stubs from the vSphere API WSDL file (vimService.wsdl).
  • Specifies the -wsdlLocation command line option to wsimport to identify the WSDL file location.
  • Copies the WSDL file and related schema files into the vim25.jar file.

To compile Java code that imports the generated stubs and uses the vim25.jar built by the build script, the WSDL file must be in the same location that was specified in the -wsdlLocation command line option. To establish this location, the build script modifies the VimService class to reference the WSDL location inside the JAR file. You only need to add the vim25.jar file to your class path.

Samples usage

All samples print a usage summary if you do not specify any options or if you specify --help on the command line.

You can also find information about the samples in the JAX-WS Samples Reference Documentation. Each package has a class summary that describes one or more samples.


Copyright © 2012 VMware, Inc. All rights not expressly granted herein are reserved.

Last updated: 10Sep2012 |  VMware vSphere Web Services SDK