Fixed WSMAN parsing.
Ylian Saint-Hilaire committed
Oct 14, 2020 at 23:54 UTC
3c3d5c1687db13d76ecaba59e07ce52dbfd5ddbb
1 file changed
+12
-3
amt/amt-wsman.js
+12
-3
@@ -38,9 +38,18 @@ function WsmanStackCreateService(comm)
38
obj.PerformAjax = function PerformAjax(postdata, callback, tag, pri, namespaces) {
39
if (namespaces == null) namespaces = '';
40
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) {
41
- if (status != 200) { callback(obj, null, { Header: { HttpError: status } }, status, tag); return; }
42
- var wsresponse = obj.xmlParser.ParseWsman(data);
43
- if (!wsresponse || wsresponse == null) { callback(obj, null, { Header: { HttpError: status } }, 601, tag); } else { callback(obj, wsresponse.Header["ResourceURI"], wsresponse, 200, tag); }
41
+ var wsresponse = null;
42
+ if (data != null) { try { wsresponse = obj.xmlParser.ParseWsman(data); } catch (ex) { } }
43
+ if ((data != null) && (!wsresponse || wsresponse == null) && (status == 200)) {
44
+ callback(obj, null, { Header: { HttpError: status } }, 601, tag);
45
+ } else {
46
+ if (status != 200) {
47
+ if (wsresponse == null) { wsresponse = { Header: {} }; }
48
+ wsresponse.Header.HttpError = status;
49
+ try { wsresponse.Header.WsmanError = wsresponse.Body['Reason']['Text']['Value']; } catch (ex) { }
50
+ }
51
+ callback(obj, wsresponse.Header['ResourceURI'], wsresponse, status, tag);
52
+ }
53
}, tag, pri);
54
}
55