in src/main/java/com/vmware/vim25/mo/util/VerUtil.java [82:117]
public static String getTargetNameSpace(String target) throws IOException {
String version = "";
String urlStr = "https://" + target + "/sdk/vimService?wsdl";
try {
trustAllHttpsCertificates();
}
catch (Exception e) {
throw new RuntimeException(e);
}
HttpsURLConnection.setDefaultHostnameVerifier(
new HostnameVerifier() {
public boolean verify(String urlHostName, SSLSession session) {
return true;
}
});
URL url = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.connect();
BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String xmlWSDL = "";
String line;
while ((line = in.readLine()) != null) {
xmlWSDL = xmlWSDL + line;
}
int start = xmlWSDL.indexOf("targetNamespace") + "targetNamespace".length();
start = xmlWSDL.indexOf("\"", start);
int end = xmlWSDL.indexOf("\"", start + 1);
version = xmlWSDL.substring(start + 1, end);
return version;
}