HP CloudSystem Matrix/Matrix Operating Environment 7.2 Integration Interfaces API and CLI Operations Reference Guide

7 Sample Java Client
The Web Service Interfaces may be accessed from a Java client program by using one of the
generally available tools to create Java language bindings from the WSDL. This sample uses the
wsdl2java utility provided with Apache CXF (cxf.apache.org). A sample environment can be
created as follows:
Create a development environment with Java 5 or later and Apache Ant
Install Apache CXF in C:\apache-cxf
Set the CXF_HOME environment variable: set CXF_HOME=C:\apache-cxf
Create a C:\hp-io-wsdl-client directory to use for the Java client program
Save the IO WSDL to the file C:\hp-io-wsdl-client\hp-io-v6.wsdl (see Accessing
WSDL (page 23))
Run C:\apache-cxf\bin\wsdl2java -ant -client -d c:\hp-io-wsdl-client
c:\hp-io-wsdl-client\hp-io-v6.wsdl
Create the files IOClientPasswordHandler.java and
TrustAllX509TrustManager.java in C:\hp-io-wsdl-client\com\hp\io\soap\
v6 with the contents shown in the sample code below
Replace the file C:\hp-io-wsdl-client\com\hp\io\soap\v6\
IO_IOSoapServicePort_Client.java with the contents shown below
Customize IO_IOSoapServicePort_Client.java as necessary, including user and
password information, template name, and service name
Build and run the Java client program from the C:\hp-io-wsdl-client directory with the
command ant IOClient
The sample program lists templates, creates a service, deactivates the service, and activates the
service. It includes logic to wait for processing of asynchronous requests to complete.
Please note that this sample is provided only to demonstrate one method of accessing the Web
Service Interfaces. It is not intended to be used as production code.
IO_IOSoapServicePort_Client.java must be customized to operate correctly in a particular
environment. Using parameterized input rather than literal values is encouraged, particularly for
the user/password information.
Sample Code
IO_IOSoapServicePort_Client.java:
Sample Code 87