Source:
private SOAPMessage readSoapResponse(String soapActionHeader, SOAPMessage request, String serviceUrl) { SOAPMessage response = null; HttpPost postSoap = new HttpPost(serviceUrl); postSoap.addHeader("SOAPAction", soapActionHeader); HttpEntity entBody = null; HttpResponse resp = null; boolean exceptionOccurred = false; try { entBody = new StringEntity(soapToString(request), ContentType.create("text/xml", "UTF-8")); postSoap.setEntity(entBody); resp = _httpClient.execute(postSoap, _httpClientContext); StatusLine slResponse = resp.getStatusLine(); HttpEntity heResponse = resp.getEntity(); if (slResponse.getStatusCode() == 401) { logger.error( "Could not read response from FritzBox. Unauthorized! Check User/PW in config. " + "Verify configured user for tr064 requests. Reason from Fritzbox was: {}", slResponse.getReasonPhrase()); postSoap.releaseConnection(); resetHttpClient(); return null; } response = MessageFactory.newInstance().createMessage(null, heResponse.getContent()); } catch (UnsupportedEncodingException e) { logger.error("Encoding not supported: {}", e.getMessage().toString()); response = null; exceptionOccurred = true; } catch (ClientProtocolException e) { logger.error("Client Protocol not supported: {}", e.getMessage().toString()); response = null; exceptionOccurred = true; } catch (IOException e) { logger.error("Cannot send/receive: {}", e.getMessage().toString()); response = null; exceptionOccurred = true; } catch (UnsupportedOperationException e) { logger.error("Operation unsupported: {}", e.getMessage().toString()); response = null; exceptionOccurred = true; } catch (SOAPException e) { logger.error("SOAP Error: {}", e.getMessage().toString()); response = null; exceptionOccurred = true; } finally { if (exceptionOccurred) { logger.error("Releasing connection to FritzBox because of error!"); resetHttpClient(); } else { logger.debug("Releasing connection"); } postSoap.releaseConnection(); } return response; }

Target:
private SOAPMessage readSoapResponse(String soapActionHeader, SOAPMessage request, String serviceUrl) { SOAPMessage response = null; HttpPost postSoap = new HttpPost(serviceUrl); postSoap.addHeader("SOAPAction", soapActionHeader); HttpEntity entBody = null; HttpResponse resp = null; boolean exceptionOccurred = false; try { entBody = new StringEntity(soapToString(request), ContentType.create("text/xml", "UTF-8")); postSoap.setEntity(entBody); resp = _httpClient.execute(postSoap, _httpClientContext); StatusLine slResponse = resp.getStatusLine(); HttpEntity heResponse = resp.getEntity(); if (slResponse.getStatusCode() == 401) { logger.warn( "Could not read response from FritzBox. Unauthorized! Check user and password in config. " + "Verify configured user for tr064 requests. Reason from Fritzbox was: {}", slResponse.getReasonPhrase()); postSoap.releaseConnection(); resetHttpClient(); return null; } response = MessageFactory.newInstance().createMessage(null, heResponse.getContent()); } catch (UnsupportedEncodingException e) { logger.error("Encoding not supported: {}", e.getMessage().toString()); response = null; exceptionOccurred = true; } catch (ClientProtocolException e) { logger.error("Client Protocol not supported: {}", e.getMessage().toString()); response = null; exceptionOccurred = true; } catch (IOException e) { logger.error("Cannot send/receive: {}", e.getMessage().toString()); response = null; exceptionOccurred = true; } catch (UnsupportedOperationException e) { logger.error("Operation unsupported: {}", e.getMessage().toString()); response = null; exceptionOccurred = true; } catch (SOAPException e) { logger.error("SOAP Error: {}", e.getMessage().toString()); response = null; exceptionOccurred = true; } finally { if (exceptionOccurred) { logger.warn("Releasing connection to FritzBox because of error."); resetHttpClient(); } else { logger.debug("Releasing connection"); } postSoap.releaseConnection(); } return response; }