importPackage(java.io);
importPackage(java.security);
importPackage(org.apache.http);
importPackage(org.apache.http.client.methods);
importPackage(org.apache.http.conn.scheme);
importPackage(org.apache.http.conn.ssl);
importPackage(org.apache.http.entity);
importPackage(org.apache.http.impl.client);
importPackage(org.apache.http.impl.conn);
importPackage(org.apache.http.params);
importPackage( org.apache.http.util);
importPackage(java.lang);
importPackage(java.util);


importPackage(java.security.cert);


function httpClietExecute() {
	
	//var KEY_STORE_PATH = "/opt/infra/cert.pem";//set the certificate file path
	var KEY_STORE_PATH = "/opt/infra/win2012r2.pem"; 
	//var KEY_STORE_PASSWORD = new java.lang.String("dunesdunes");//set the keystore password for ex., keystorePass="dunesdunes"	
	//For reference, https://pubs.vmware.com/vsphere-51/topic/com.vmware.ICbase/PDF/using-vcenter-orchestrator-51-appliance-guide.pdf	
	//Load Keystores
	//var keystore = KeyStore.getInstance("PKCS12");
	
	var keystoreInput = new FileInputStream(KEY_STORE_PATH);
	var keystore = getTrustStore(keystoreInput);
	//keystore.load(keystoreInput, KEY_STORE_PASSWORD.toCharArray());
	//keystore.load(keystoreInput, null);
	logger.addInfo("Keystore has " + keystore.size() + " keys");
	
	// load the truststore, leave it null to rely on cacerts distributed with the JVM
	/*KeyStore truststore = KeyStore.getInstance(KeyStore.getDefaultType());
	InputStream truststoreInput = new FileInputStream(TRUST_STORE_PATH);
	truststore.load(truststoreInput, TRUST_STORE_PASSWORD.toCharArray());
	logger.addInfo("Truststore has " + truststore.size() + " keys");
	 */
	var truststore = null;
	
	// Create Scheme Registry
	var schemeRegistry = new SchemeRegistry();
	var lSchemeSocketFactory = new SSLSocketFactory(keystore);
	schemeRegistry.register(new Scheme("https", 443, lSchemeSocketFactory));
	
	//Create HTTP Client
	
	var httpParams = new BasicHttpParams();
	var lHttpClient = new DefaultHttpClient(new SingleClientConnManager(schemeRegistry), httpParams);

	//String lUrl = "https://secure.address.soapservice.net/Service.asmx";
	var wfaUri = "https://192.168.8.97:443/vco/api/workflows/a3ff1202-d746-476c-862f-59809b11d6e5/executions/";
	
	//Create the XML to send. 	
	var strEntity = new StringEntity(""
			+ ""
			+ "tails");
	
	//Perform POST
	//Post to the URL with the XML as a parameter. The contents of the SOAPAction header are defined in the WSDL (look for )
	var lMethod = new HttpPost(wfaUri);
	//HttpEntity lEntity = new StringEntity(lXml, "text/xml", "UTF-8");
	lMethod.setEntity(strEntity);
	//lMethod.setHeader("SOAPAction", "http://www.secure.com/ABC/");
	
	//Process Response
	var lHttpResponse = lHttpClient.execute(lMethod);
	
	logger.addInfo("Response status code: " + lHttpResponse.getStatusLine().getStatusCode());
	logger.addInfo("Response body: ");
	logger.addInfo(EntityUtils.toString(lHttpResponse.getEntity()));
}

function getTrustStore(pathToPemFile) {
	var ks = KeyStore.getInstance(KeyStore.getDefaultType());
	ks.load(null);

	var cert = CertificateFactory.getInstance("X509").generateCertificate(pathToPemFile);
	var alias = cert.getSubjectX500Principal().getName();
	ks.setCertificateEntry(alias, cert);

	return ks;
}
httpClietExecute();


Additional Links: