# VMware VSLM SDK: JAX-WS Samples Readme |
This document describes the VMware VSLM SDK samples that use the JAX-WS bindings for the vSphere API. The examples have been developed to work with the JAXWS bundled in libs/JAXWS-RI 3.0.2. The following sections describe how to build and run the vSphere Web Services SDK JAX-WS samples. Sample Directories Sample Program Structure Building the Sample Programs Running the Sample Programs Sample Documentation ## Sample Directories The VMware VSLM SDK samples are located in the following vSphere Management SDK directory: `.../SDK/vslm/java/JAXWS/samples/` The following table contains a brief description of the samples.
Sample | Description
--- | ---
FcdControlFlagsOperations.java | This sample sets and clears control flags on VStorageObject from vslm.
FcdCreateFromVslm.java | This sample creates a virtual storage object(FCD) from vslm endpoint
FcdLegacyDiskAndAssociationOperations.java | This sample registers a given legacy disk as FCD, attach FCD to VM and retrieve FCD associations.
FcdMetadataOperations.java | This sample creates FCD with metadata retrieves metadata, retrieves metadata value and update metadata from vslm.
FcdMigrationOperations.java | This sample clones and relocates a virtual storage object from vslm.
FcdReconcileDatastoreInventoryOperations.java | This sample reconcile the datastore inventory info of virtual storage objects and schedules reconcile of the inventory info of virtual storage objects on one of the hosts that is connected with the datastore from vslm.
FcdRenameExtendInflateDeleteOperations.java | This sample renames an FCD extends capacity of FCD, inflates a sparse or thin-provisioned FCD up to the full size and deletes FCD
FcdRetrieveOperations.java | This sample retrieves a virtual storage object, retrieves virtual storage object state and lists all virtual storage object from vslm.
FcdSnapshotOperations.java | This sample executes snapshot related operation on a snapshot of a given VStorageObject.
FcdTagOperations.java | This sample attaches tag to FCD, lists tags attached to FCD, list FCDs attached to tag and detaches tags from FCD.
FcdUpdateAndRetrieveInfrastructurePolicyOperations.java | This sample updates vStorageObject policy, updates and retrieves virtual storage infrastructure object SBPM policy on given datastore.
## Sample Program Structure The samples use custom Java annotations to organize them. These annotations are `@Before`, `@Action`, and `@After`. The SDK sample code includes a samples framework that runs the samples and executes the sample code. Each sample extends the class `ConnectedVimServiceBase` (`.../SDK/vsphere-ws/java/JAXWS/samples/com/vmware/connection/ConnectedVimServiceBase.java`). This class contains the `@Before` and `@After` declarations. The `@Before` code connects to the vCenter Server, and obtains access to the vSphere methods. The `@After` code disconnects from the Server. Each sample file contains the `@Action` declaration, which contains the code that performs the capability of the particular sample. ## Building the Sample Programs To build the sample programs, you must define the `JAVA_HOME environment variable and execute the build script to generate client stubs and compile the samples.` ### JAVA_HOME Environment Variable You must set the JAVA_HOME environment variable to the base directory of a JDK 8 and above ### Build Scripts The following table shows the build files located in the `SDK/vslm/java/JAXWS/` directory.
Build Task | Files
--- | ---
Generate JAX-WS client stubs and compile samples. | build.bat build.sh
Run a sample. | run.bat run.sh
#### Converting Shell Scripts for Linux The shell script (run.sh) has DOS-style line endings. These do not work when running these scripts on Linux. Use the Linux command `dos2unix` to convert this file before you use it. To run these scripts, set the Execute permission on the files: `chmod a+x *.sh` ## Building Sample Programs Go to the SDK/vslm/java/JAXWS directory of the SDK and execute build.bat or build.sh depending on OS is windows or linux based. The build script (build.bat and build.sh) generates VSLM API Java stubs from the VSLM API WSDL, compiles the generated stubs and sample programs. The build needs various libraries such as vim25.jar, ssoclient.jar which are referenced from SDK/vsphere-ws/java/JAXWS/lib by adding it to the classpath. You can specify the following command line options to control stub generation and compilation. These are valid for only build.bat. For build.sh, both stubs and samples are compiled by default. `build.bat -w` - Compiles sample programs but does not generate or compile stubs. `build.bat -s` - Compiles stubs but does not compile samples. `build.bat -b` - Compiles both Stubs and Samples (Default in case none of -s or -w or -b is specified) #### 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 `wsimport` inside JAXWS-RI in libs folder to generate the VSLM services Java stubs from the VSLM API WSDL file (`vslmService.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 `vslm.jar` file. To compile Java code that imports the generated stubs and uses the `vslm.jar` built by the build script, the WSDL file must be in the same location that was specified in the `-wsdlLocation` command line option. The SDK stubs and samples are compiled using JDK 11 with target and source set to 1.8, therefore, making the SDK compatible with JDK 8. ## Running a Sample Go to the SDK/vslm/java/JAXWS directory of the SDK and execute run.bat or run.sh with options. JAXWS>run.bat [Sample class name] [options] For example: JAXWS>run.bat FcdCreateFromVslm --url [URL] --username [USERNAME] --password [PASSWORD] --argument [Argument] URL = https://VcenterIP/sdk/vimService Example: JAXWS>run.bat FcdCreateFromVslm --url https://VC_IP/sdk/vimService --username USERNAME --password PASSWD --datastoreinmb 1000 --datastorename local-0 --vstorageobjectname fcd-lin-1 --vstorageobjectsizeinmb 1000 Run JAXWS>run.bat [sample class name] --help to know more about the sample and arguments needed to run it. The samples framework is designed to execute any of the samples provided in the kit. To run a sample, you must specify authentication parameters and server URLs. Username and password for authentication with the VMware SSO Server. URLs for the VMware SSO Server and vCenter Server. You can specify the vCenter Server URL, username and password on the command line when you execute a sample program. These properties are declared as input options, using the `@Option` declarations and implemented in the following files: `/SDK/vsphere-ws/java/JAXWS/samples/com/vmware/connection/Connection.java /SDK/vsphere-ws/java/JAXWS/samples/com/vmware/connection/SsoConnection.java` When you execute a sample, the samples framework will resolve the input values from the appropriate source. ## Samples Documentation To print help about a sample, 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 © 2019, 2021, 2023 VMware, Inc. All rights not expressly granted herein are reserved. | Last updated: 27 June 2023 | VMware VSLM SDK