}
// Execute the HTTP method
int response = getClient().executeMethod(getHostConfiguration(locationURI), method);
if (response != HttpStatus.SC_OK && response != HttpStatus.SC_ACCEPTED) {
if (exchange instanceof InOnly == false) {
SoapReader reader = soapHelper.getSoapMarshaler().createReader();
Header contentType = method.getResponseHeader(Constants.HEADER_CONTENT_TYPE);
soapMessage = reader.read(method.getResponseBodyAsStream(),
contentType != null ? contentType.getValue() : null);
context.setFaultMessage(soapMessage);
soapHelper.onAnswer(context);
Fault fault = exchange.createFault();
fault.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(method));
soapHelper.getJBIMarshaler().toNMS(fault, soapMessage);
exchange.setFault(fault);
if (txSync) {
channel.sendSync(exchange);
} else {
methods.put(exchange.getExchangeId(), method);
channel.send(exchange);
close = false;
}
return;
} else {
throw new Exception("Invalid status response: " + response);
}
}
if (exchange instanceof InOut) {
NormalizedMessage msg = exchange.createMessage();
SoapReader reader = soapHelper.getSoapMarshaler().createReader();
Header contentType = method.getResponseHeader(Constants.HEADER_CONTENT_TYPE);
soapMessage = reader.read(method.getResponseBodyAsStream(),
contentType != null ? contentType.getValue() : null);
context.setOutMessage(soapMessage);
soapHelper.onAnswer(context);
if (getConfiguration().isWantHeadersFromHttpIntoExchange()) {
msg.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(method));
}
soapHelper.getJBIMarshaler().toNMS(msg, soapMessage);
((InOut) exchange).setOutMessage(msg);
if (txSync) {
channel.sendSync(exchange);
} else {
methods.put(exchange.getExchangeId(), method);
channel.send(exchange);
close = false;
}
} else if (exchange instanceof InOptionalOut) {
if (method.getResponseContentLength() == 0) {
exchange.setStatus(ExchangeStatus.DONE);
channel.send(exchange);
} else {
NormalizedMessage msg = exchange.createMessage();
SoapReader reader = soapHelper.getSoapMarshaler().createReader();
soapMessage = reader.read(method.getResponseBodyAsStream(),
method.getResponseHeader(Constants.HEADER_CONTENT_TYPE).getValue());
context.setOutMessage(soapMessage);
soapHelper.onAnswer(context);
if (getConfiguration().isWantHeadersFromHttpIntoExchange()) {
msg.setProperty(JbiConstants.PROTOCOL_HEADERS, getHeaders(method));