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); }