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

      SDK/samples/drconfig/JAXWS/com/vmware

   The following sections contain information about building and running the JAX-WS Site Recovery Manager Appliance Management API samples.

      Building Sample Programs
      Sample Applications

2. Building Sample Programs

   The build scripts (build.bat or build.sh) generate Site Recovery Manager Appliance Management API Java stubs from the Site Recovery Manager Appliance Management API WSDL, compile the generated stubs, and compile the sample programs.

   JAVAHOME Environment Variable:
   You must set the JAVAHOME environment variable to the base directory of a JDK 1.8.0_202.
   Example: JAVAHOME -> "C:\Program Files\Java\jdk1.8.0_202"

   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 client stubs from the Site Recovery Manager Appliance Management API WSDL file (drconfig-service.wsdl).
      Specifies the -wsdlLocation command line option to wsimport to identify the WSDL file location.
      Copies the the WSDL file and related schema files into the drconfig.jar file.

   To compile Java code that imports the generated stubs and uses the drconfig.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 DrConfigService class to reference the WSDL location inside the JAR file. You only need to add the drconfig.jar file to your class path.

3. Sample Applications

   The SDK package includes generated Reference Guide for the available sample applications and helper classes, in this path:

      SDK/doc/drconfig/ReferenceGuide

   If the relative link above does not work, manually navigate to the sub-directory.

   Sample            |  Usage and Description
           |   Configure the Site Recovery Manager using the ConfigSpec
           |   Command line syntax:
   ConfigureSrm      |  run.bat com.vmware.samples.drconfig.ConfigureAppliance configure --drconfigaddr https://FQDN_or_IP_Address:5480/configureserver/sdk --drconfiguser admin --pscuri pscfqdn:443 --pscuser Administrator@vsphere.local

           |  Usage and Description
           |  Clear Site Recovery Manager configuration
           |  Command line syntax:
   ClearSrmConfiguration   | run.bat com.vmware.samples.drconfig.ConfigureAppliance clear --drconfigaddr https://FQDN_or_IP_Address:5480/configureserver/sdk --drconfiguser admin --pscuser Administrator@vsphere.local

            | Usage and Description
            | Read and print the current Site Recovery Manager Configuration parameters
            | Command line syntax:
   ReadCurrentConfig  | run.bat com.vmware.samples.drconfig.ConfigureAppliance get-config --drconfigaddr https://FQDN_or_IP_Address:5480/configureserver/sdk --drconfiguser admin

4. Build and Execute alternatively:
   You can create a Eclipse java project and add the .java classes from the SDK/samples/drconfig/JAXWS/com/vmware/drconfig generated folder and the .java classes from SDK/samples/drconfig/JAXWS/com/vmware/vim25 generated folder to the eclipse project as packages. Then add SDK/samples/drconfig/JAXWS/com/vmware/samples/... connection and drconfig .java classes to that project. To run the samples use JDK 1.8.0_202 to build the project, after that you need to configure the arguments for the program... Right-Click ConfigureAppliance.java -> Run As -> Run Configurations -> Java Application -> ConfigureAppliance -> Arguments:
      1. Program arguments enter command that you want to execute on the appliance:
         Program Arguments example:
           Example1: --clear ... Example2: --configure ... Example3: --get-config ..., or use --help for more information
      2. If you are going to use your own certificate on the appliance you need to setup the Eclipse keystore:
         VM arguments:
            -Djavax.net.ssl.trustStore="my_java_keysrore_location" (This is the "VMKEYSTORE" environment variable that is set to your java keystore location, this is the same path as the environment variable
                                                                    Example: "C:\Program Files\Java\jdk1.8.0_202\jre\lib\security\cacerts")
            -Djavax.net.ssl.trustStorePassword="changeit" (This is the default java keystore password, use your own if you have changed it)
      3. You have the option to ignore the certificate, which will result in no checks whatsoever (meaning Step 2 is ignored, no need to enter anything in the VM arguments):
         Program Arguments (Adding "--ignorecerts" will ignore certificate checks):
           Example: --clear ...  --ignorecerts


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