{
path = getHeaderValue(headers, "path") ;
}
final SOAPProcessorHttpServletRequest servletRequest = new SOAPProcessorHttpServletRequest(path, soapMessage, headers) ;
final SOAPProcessorHttpServletResponse servletResponse = new SOAPProcessorHttpServletResponse() ;
final ServletContext servletContext = SOAPProcessorFactory.getFactory().createServletContext(endpoint) ;
EndpointAssociation.setEndpoint(endpoint);
final ClassLoader old = Thread.currentThread().getContextClassLoader();
try
{
initialiseContextClassLoader(endpoint);
requestHandler.handleHttpRequest(endpoint, servletRequest, servletResponse, servletContext) ;
}
finally
{
Thread.currentThread().setContextClassLoader(old);
EndpointAssociation.removeEndpoint();
}
// This may have been changed, make sure we get the current version.
message = messageTL.get();
final Properties responseProperties = message.getProperties() ;
final String contentType = servletResponse.getContentType() ;
final Map<String, List<String>> responseHeaders = servletResponse.getHeaders() ;
// We deal with Content-Type below
// HTTP Headers *should* be case-insensitive but not with JBR
responseHeaders.remove("content-type") ;
for(Map.Entry<String, List<String>> header: responseHeaders.entrySet())
{
// We can only deal with the first value in the list.
// JBESB-2511
new ResponseHeader(header.getKey(), header.getValue().get(0)).setPropertyNameThis(properties);
}
// JBESB-2761
if (httpResponseStatusEnabled) {
ResponseStatus.setHttpProperties(properties, servletResponse.getStatus(), servletResponse.getStatusMessage());
}
final byte[] responseData = servletResponse.getContent() ;
if(contentType != null) {
responseProperties.setProperty("Content-Type", new ResponseHeader("Content-Type", contentType));
} else {
responseProperties.setProperty("Content-Type", new ResponseHeader("Content-Type", "text/xml"));
}
if ((contentType != null) && contentType.startsWith("multipart/")) {
payloadProxy.setPayload(message, responseData) ;
} else {
final String charset = servletResponse.getCharset() ;
if (charset == null) {
payloadProxy.setPayload(message, new String(responseData)) ;
} else {
payloadProxy.setPayload(message, new String(responseData, charset)) ;
}