method = methodFactory.getMethod(payloadStr, "application/x-java-serialized-object", Charset.defaultCharset().toString());
} else {
method = methodFactory.getMethod(payload.toString(), "text/xml", "UTF-8");
}
} catch (ParserConfigurationException e) {
throw new ActionProcessingException(e);
}
}
try {
setRequestHeaders(method, message);
int responseCode = httpclient.executeMethod(method);
if(responseCode != HttpStatus.SC_OK) {
logger.warn("Received status code '" + responseCode + "' on HTTP " + method + " request to '" + endpointUrl + "'.");
}
attachResponseDetails(message, method, responseCode);
InputStream resultStream = method.getResponseBodyAsStream();
try {
byte[] bytes = readStream(resultStream);
if(responseType == ResponseType.STRING) {
getPayloadProxy().setPayload(message, new String(bytes, method.getResponseCharSet()));
} else {
getPayloadProxy().setPayload(message, bytes);
}
} catch (MessageDeliverException e) {
throw new ActionProcessingException("problem setting message payload: " + e.getMessage(), e);
} finally {
closeStream(resultStream);
}
} finally {
method.releaseConnection();
}
} catch (IOException e) {
throw new ActionProcessingException("problem processing HTTP I/O: " + e.getMessage(), e);
}
return message;
}