package sample; import com.hp.ucmdb.api.*; import java.net.MalformedURLException; /** * This is a sample of how to establish a connection to the UCMDB server. * This sample is connecting to the server according to the constants below. */ public class CreateSDKConnectionSample { //Server Address public static final String HOST ="123.123.123.123"; //Server Protocol public static final String PROTOCOL ="http"; //Server Port public static final int PORT = 8080; //Credentials private static final String USER_NAME = "fitzwilliam"; private static final String PASSWORD = "darcy"; /** * Creates a UCMDB SDK connection. * * @return UcmdbService object with all of the available services * @throws java.net.MalformedURLException in case of a wrong host/protocol/port input */ public static UcmdbService createSDKConnection() throws MalformedURLException { //Creating a service provider for a given UCMDB server address UcmdbServiceProvider serviceProvider = UcmdbServiceFactory.getServiceProvider(PROTOCOL, HOST, PORT); //Creating a client context according to the name of this integration (for auditing) ClientContext clientContext = serviceProvider.createClientContext("MyAppName"); //Creating the credentials for authentication Credentials credentials = serviceProvider.createCredentials(USER_NAME, PASSWORD); // Creating the connection object return serviceProvider.connect(credentials,clientContext); } }