1.2 Using the Oracle VM Web Services Client Library and Sample Code

Since Oracle VM Manager provides generic SOAP and REST APIs, you are able to use this documentation to develop your own code to directly interact with your chosen API based on your understanding of the API mechanism that you choose to use and the methods that are supported by the exposed API. However, the Oracle VM Web Services SDK includes a Java client library and example Java source code that can dramatically reduce the amount of work that you need to do in order to code an application that uses either of the APIs. The example code also includes a number of utilities that are useful when working with an API, but which are not part of the API itself. For this reason, it is recommended that you take advantage of the provided code and library when programming a Java application that interfaces with Oracle VM Manager.

In this guide, we take a closer look at the Oracle VM Web Services Client Library and how it is commonly used. Full coverage of the methods supported by the library can be found in the documentation included with the SDK.

To get started using the SDK, you can import the source code provided into a new Java project within your preferred IDE. The SDK requires that you use the Oracle JDK 7 for your project. JDK 6 is not supported.

You must add the provided client library, OvmWsClient.jar, to your project in order to compile the source code. Additionally, the example source code makes use of some external libraries, such as the Jersey Bundle to handle calls to the REST API. While you are free to choose any other tools to create your own application, the example source code requires this library to compile as the example code is capable of being configured to use either the REST API or the SOAP API when it runs. Information on downloading and installing the Jersey Bundle is provided in Notes on the Java samples provided in these examples.

The sample code includes a properties file called WsDevClient.properties. This file contains the default values used for different variables defined in the code. In most cases, many of these variable values must be overridden for your own environment. For values that you wish to override, create a file in the same directory, named WsDevClient_username.properties, where username matches your the username that you use to log into the environment where you intend to compile the code. Note that this properties file is only required for the sample client and is not required when building your own application using the provided libraries.

Once the code has been compiled, you can run it easily from the command line using:

java -cp wsclient.jar com.oracle.ovm.mgr.ws.sample.WsDevClient
Tip

The sample client code has already been compiled into the wsclient.jar library file. This means that it can be used directly without requiring you to recompile it. You still need to edit the WsDevClient.properties file to override variables. To do this, edit samples/com/oracle/ovm/mgr/ws/sample/WsDevClient.properties so that the variables match your own environment. Unzip the lib/OvmWsClient.jar Java archive file and copy your new version of WsDevClient.properties into com/oracle/ovm/mgr/ws/sample/ from the extracted archive. Finally recreate the archive file and run it using the instruction provided above.

If the value for wsimpl variable is set to SOAP and debugHttpTraffic is set to true, the output from the sample code includes all of the SOAP interactions that the sample client application performs, including the HTTP headers and the SOAP messages exchanged within the body of each request.

If the value for wsimpl variable is set to REST and debugHttpTraffic is set to true, the output from the sample code includes all of the REST interactions that the sample client application performs, including the XML or JSON body content and the HTTP headers.