diff --git a/src/main/java/com/xebialabs/overthere/winrm/WinRmClient.java b/src/main/java/com/xebialabs/overthere/winrm/WinRmClient.java index 512678c1..d28b1140 100644 --- a/src/main/java/com/xebialabs/overthere/winrm/WinRmClient.java +++ b/src/main/java/com/xebialabs/overthere/winrm/WinRmClient.java @@ -415,16 +415,22 @@ private Document doSendRequest(final Document requestDocument, final SoapAction logResponseHeaders(response); + Document responseDocument = null; + try { + final String responseBody = handleResponse(response, context); + responseDocument = DocumentHelper.parseText(responseBody); + logDocument("Response body:", responseDocument); + } catch(WinRmRuntimeIOException e) { + if (response.getStatusLine().getStatusCode() == 200) { + throw e; + } + } + if (response.getStatusLine().getStatusCode() != 200) { throw new WinRmRuntimeIOException(String.format("Unexpected HTTP response on %s: %s (%s)", targetURL, response.getStatusLine().getReasonPhrase(), response.getStatusLine().getStatusCode())); } - final String responseBody = handleResponse(response, context); - Document responseDocument = DocumentHelper.parseText(responseBody); - - logDocument("Response body:", responseDocument); - return responseDocument; } finally { connectionManager.shutdown();