1.5

VMware, Inc. 39
Chapter 3 Using vCenter Chargeback with a Billing System
* @throws JDOMException
*/
public static void sampleGetReportAsXml(int reportId, String baseURL) throws
HttpException, IOException, KeyManagementException, NoSuchAlgorithmException,
JDOMException {
GetMethod get = null;
HttpClient client = new HttpClient();
Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new
FakeSSLCertificateSocketFactory(), 443));
String uri = "https://" + baseURL + "/vCenter-CB/api/report/" + reportId + "/export";
NameValuePair[] parameters = {new NameValuePair("exportFormat", "XML")};
try {
get = new GetMethod(uri);
get.setQueryString(parameters);
client.executeMethod(get);
System.out.println(get.getResponseBodyAsString());
} finally {
if (get != null) {
get.releaseConnection();
}
}
}