Fixed WSMAN parsing.

This commit is contained in:
Ylian Saint-Hilaire 2020-10-14 23:54:30 -07:00
parent 5ca8525795
commit 75acc04e7c

View File

@ -38,9 +38,18 @@ function WsmanStackCreateService(comm)
obj.PerformAjax = function PerformAjax(postdata, callback, tag, pri, namespaces) {
if (namespaces == null) namespaces = '';
obj.comm.PerformAjax('<?xml version=\"1.0\" encoding=\"utf-8\"?><Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:a="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:w="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd" xmlns=\"http://www.w3.org/2003/05/soap-envelope\" ' + namespaces + '><Header><a:Action>' + postdata, function (data, status, tag) {
if (status != 200) { callback(obj, null, { Header: { HttpError: status } }, status, tag); return; }
var wsresponse = obj.xmlParser.ParseWsman(data);
if (!wsresponse || wsresponse == null) { callback(obj, null, { Header: { HttpError: status } }, 601, tag); } else { callback(obj, wsresponse.Header["ResourceURI"], wsresponse, 200, tag); }
var wsresponse = null;
if (data != null) { try { wsresponse = obj.xmlParser.ParseWsman(data); } catch (ex) { } }
if ((data != null) && (!wsresponse || wsresponse == null) && (status == 200)) {
callback(obj, null, { Header: { HttpError: status } }, 601, tag);
} else {
if (status != 200) {
if (wsresponse == null) { wsresponse = { Header: {} }; }
wsresponse.Header.HttpError = status;
try { wsresponse.Header.WsmanError = wsresponse.Body['Reason']['Text']['Value']; } catch (ex) { }
}
callback(obj, wsresponse.Header['ResourceURI'], wsresponse, status, tag);
}
}, tag, pri);
}