From 3c3d5c1687db13d76ecaba59e07ce52dbfd5ddbb Mon Sep 17 00:00:00 2001 From: Ylian Saint-Hilaire Date: Wed, 14 Oct 2020 23:54:30 -0700 Subject: [PATCH] Fixed WSMAN parsing. --- amt/amt-wsman.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/amt/amt-wsman.js b/amt/amt-wsman.js index e99c661e..34eb87f8 100644 --- a/amt/amt-wsman.js +++ b/amt/amt-wsman.js @@ -38,9 +38,18 @@ function WsmanStackCreateService(comm) obj.PerformAjax = function PerformAjax(postdata, callback, tag, pri, namespaces) { if (namespaces == null) namespaces = ''; obj.comm.PerformAjax('
' + 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); }