in src/main/java/com/vmware/vim25/ws/XmlGenDom.java [101:160]
public Object fromXML(String returnType, InputStream is) throws RemoteException {
if (log.isDebugEnabled()) {
log.debug("Parsing XML payload from server. " + returnType);
}
Element root = null;
try {
Document doc = parseDocument(is);
if (log.isTraceEnabled()) {
log.trace("XML Document: " + doc.asXML());
}
root = doc.getRootElement();
}
catch (DocumentException e){
Throwable throwThis = e.getNestedException() != null ? e.getNestedException() : e;
throw new RemoteException("An error occurred parsing XML with return type: " + returnType, throwThis);
} catch (Exception e1) {
throw new RemoteException("VI SDK invoke exception:" + e1);
}
finally {
if (is != null) {
try {
is.close();
}
catch (IOException ignore) {
}
}
}
Element body = (Element) root.elements().get(0);
Element resp = (Element) body.elements().get(0);
if (resp.getName().contains("Fault")) {
SoapFaultException sfe;
try {
sfe = parseSoapFault(resp);
}
catch (Exception e) {
throw new RemoteException("Exception in SoapClient.invoke:", e);
}
if (sfe != null && sfe.detail != null) {
throw (RemoteException) sfe.detail;
}
else {
throw sfe;
}
}
else {
if (returnType != null) {
try {
return fromXML(returnType, resp);
}
catch (Exception e) {
throw new RemoteException("Exception in SoapClient.invoke:", e);
}
}
else {
return null;
}
}
}