1 package de.spring.webservices.endpoints;
3 import javax.servlet.http.HttpServletRequest;
5 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory;
7 import org.springframework.util.StringUtils;
8 import org.springframework.ws.context.MessageContext;
9 import org.springframework.ws.server.EndpointInterceptor;
10 import org.springframework.ws.transport.context.TransportContext;
11 import org.springframework.ws.transport.context.TransportContextHolder;
12 import org.springframework.ws.transport.http.HttpServletConnection;
14 public class CustomHeaderInterceptor implements EndpointInterceptor {
15 private static final Logger LOGGER = LoggerFactory.getLogger(CustomHeaderInterceptor.class);
16 private static final String MY_CUSTOM_HEADER = "MY_CUSTOM_HEADER";
19 public boolean handleRequest(MessageContext messageContext, Object endpoint) throws Exception {
20 TransportContext transport = TransportContextHolder.getTransportContext();
22 if (transport != null) {
23 HttpServletConnection connection = (HttpServletConnection) transport.getConnection();
24 HttpServletRequest headers = connection.getHttpServletRequest();
25 String headerValue = headers.getHeader(MY_CUSTOM_HEADER);
27 if (!StringUtils.isEmpty(headerValue)) {
28 LOGGER.info("Custom header value: " + headerValue);
36 public boolean handleResponse(MessageContext messageContext, Object endpoint) throws Exception {
41 public boolean handleFault(MessageContext messageContext, Object endpoint) throws Exception {
46 public void afterCompletion(MessageContext messageContext, Object endpoint, Exception ex) throws Exception {