this.policies = policies;
}
public MessageExchange createExchange(HttpServletRequest request, ComponentContext context) throws Exception {
String method = request.getMethod();
Message msg = binding.createMessage();
msg.put(ComponentContext.class, context);
msg.put(JbiConstants.USE_JBI_WRAPPER, useJbiWrapper);
msg.put(Message.CONTENT_TYPE, request.getContentType());
Map<String, String> headers = msg.getTransportHeaders();
for (Enumeration<?> e = request.getHeaderNames(); e.hasMoreElements();) {
String name = (String) e.nextElement();
String value = request.getHeader(name);
headers.put(name, value);
}
headers.put(HttpConstants.REQUEST_URI, request.getRequestURL().toString());
headers.put(HttpConstants.CONTENT_TYPE, request.getContentType());
headers.put(HttpConstants.REQUEST_METHOD, method);
if (HttpConstants.METHOD_POST.equals(method) || HttpConstants.METHOD_PUT.equals(method)) {
msg.setContent(InputStream.class, request.getInputStream());
}
request.setAttribute(Message.class.getName(), msg);
InterceptorChain phase = getChain(Phase.ServerIn);
phase.doIntercept(msg);
return msg.getContent(MessageExchange.class);
}