protected HttpServletRequest getHttpServletRequest() { TransportContext ctx = TransportContextHolder.getTransportContext(); return ( null != ctx ) ? ((HttpServletConnection ) ctx.getConnection()).getHttpServletRequest() : null; } protected String getHttpHeaderValue( final String headerName ) { HttpServletRequest httpServletRequest = getHttpServletRequest(); return ( null != httpServletRequest ) ? httpServletRequest.getHeader( headerName ) : null; }
@Override public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException { TransportContext tc = TransportContextHolder.getTransportContext(); if (tc != null) { try { this.lastUri = tc.getConnection().getUri(); } catch (URISyntaxException e) { throw new IllegalStateException(e); } } else { throw new IllegalStateException("expected WebServiceConnection in the TransportContext"); } return true; }
@Override public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException { TransportContext tc = TransportContextHolder.getTransportContext(); WebServiceConnection webServiceConnection = tc.getConnection(); if (webServiceConnection instanceof MailSenderConnection) { this.webServiceConnection = webServiceConnection; } else { throw new IllegalStateException("expected MailSenderConnection in the TransportContext"); } super.handleRequest(messageContext); throw new WebServiceIOException("intentional"); }
@Component public class RequesEndpointURLExtractor { public String getCurrentURL() { TransportContext ctx = TransportContextHolder.getTransportContext(); HttpServletRequest httpServletRequest = ((HttpServletConnection) ctx.getConnection()).getHttpServletRequest(); String pathInfo = httpServletRequest.getPathInfo(); String queryString = httpServletRequest.getQueryString(); return pathInfo + "?" + queryString; } }
TransportContext transportContext = TransportContextHolder.getTransportContext(); HttpServletRequest servletRequest = ((HttpServletConnection) transportContext.getConnection()).getHttpServletRequest(); String authorizationHeader = servletRequest.getHeader("authorization"); String userAndPasswordBase64 = authorizationHeader.substring("Basic ".length()); String userAndPassword = new String(Base64.decodeBase64(userAndPasswordBase64)); int colonIndex = userAndPassword.indexOf(':'); String user = userAndPassword.substring(0, colonIndex); String password = userAndPassword.substring(colonIndex + 1);
private WebServiceConnection getWeServiceConnection() { TransportContext transportContext = TransportContextHolder.getTransportContext(); if (transportContext != null) { WebServiceConnection webServiceConnection = transportContext.getConnection(); if (webServiceConnection != null) { return webServiceConnection; } } return null; }
TransportContext ctx = TransportContextHolder.getTransportContext(); HttpServletConnection conn = (HttpServletConnection )ctx.getConnection(); HttpServletRequest request = conn.getHttpServletRequest();
private String getIpRequest(){ String result = "none"; TransportContext context = TransportContextHolder.getTransportContext(); if(context != null){ HttpServletConnection connection = (HttpServletConnection)context.getConnection(); if(connection != null){ HttpServletRequest request = connection.getHttpServletRequest(); if(request != null){ result = request.getRemoteAddr(); } } } return result; }
private final ThreadLocal<MyHolder> holder = new ThreadLocal<MyHolder>(); @Override public boolean handleRequest(MessageContext messageContext) throws WebServiceClientException { TransportContext context = TransportContextHolder.getTransportContext(); HttpUrlConnection connection = (HttpUrlConnection) context.getConnection(); HttpURLConnection connection1= connection.getConnection(); MyHolder holder = this.holder.remove(); connection1.addRequestProperty("user-email", holder.getEmail()); connection1.addRequestProperty("user-name", holder.getUser()); return true; } public Message<?> setUserInfo(Message<?> message, String user, String email) { this.holder.set(new MyHolder(user, email)); return message; }
/** * Returns the {@code Destination} for outgoing messages. * * <p>Defaults to the {@link org.springframework.ws.transport.WebServiceConnection#getUri() connection URI} if no * destination was set. */ protected URI getTo() { if (to == null) { TransportContext transportContext = TransportContextHolder.getTransportContext(); if (transportContext != null && transportContext.getConnection() != null) { try { return transportContext.getConnection().getUri(); } catch (URISyntaxException ex) { // ignore } } throw new IllegalStateException("Could not obtain connection URI from Transport Context"); } else { return to; } }
/** * Returns the <code>Destination</code> for outgoing messages. * <p/> * Defaults to the {@link org.springframework.ws.transport.WebServiceConnection#getUri() connection URI} if no * destination was set. */ protected URI getTo() { if (to == null) { TransportContext transportContext = TransportContextHolder.getTransportContext(); if (transportContext != null && transportContext.getConnection() != null) { try { return transportContext.getConnection().getUri(); } catch (URISyntaxException ex) { // ignore } } throw new IllegalStateException("Could not obtain connection URI from Transport Context"); } else { return to; } }
/** * Returns the {@code Destination} for outgoing messages. * * <p>Defaults to the {@link org.springframework.ws.transport.WebServiceConnection#getUri() connection URI} if no * destination was set. */ protected URI getTo() { if (to == null) { TransportContext transportContext = TransportContextHolder.getTransportContext(); if (transportContext != null && transportContext.getConnection() != null) { try { return transportContext.getConnection().getUri(); } catch (URISyntaxException ex) { // ignore } } throw new IllegalStateException("Could not obtain connection URI from Transport Context"); } else { return to; } }
@Override protected String getLookupKeyForMessage(MessageContext messageContext) throws Exception { TransportContext transportContext = TransportContextHolder.getTransportContext(); if (transportContext != null) { WebServiceConnection connection = transportContext.getConnection(); if (connection != null) { return connection.getUri().toString(); } } return null; } }
/** * Returns the {@code Destination} for outgoing messages. * * <p>Defaults to the {@link org.springframework.ws.transport.WebServiceConnection#getUri() connection URI} if no * destination was set. */ protected URI getTo() { if (to == null) { TransportContext transportContext = TransportContextHolder.getTransportContext(); if (transportContext != null && transportContext.getConnection() != null) { try { return transportContext.getConnection().getUri(); } catch (URISyntaxException ex) { // ignore } } throw new IllegalStateException("Could not obtain connection URI from Transport Context"); } else { return to; } }
@Override protected String getLookupKeyForMessage(MessageContext messageContext) throws Exception { TransportContext transportContext = TransportContextHolder.getTransportContext(); if (transportContext != null) { WebServiceConnection connection = transportContext.getConnection(); if (connection != null) { URI connectionUri = connection.getUri(); if (usePath) { return connectionUri.getPath(); } else { return connectionUri.toString(); } } } return null; } }
TransportContext transport = TransportContextHolder.getTransportContext(); if(transport!=null && transport.getConnection() instanceof HttpServletConnection){ HttpServletConnection httpCon = (HttpServletConnection)(transport.getConnection()); if(getSwitchOn().equals(httpCon.getHttpServletRequest().getHeader("soapAction"))){ return alternateMessageFactory;
@Override protected String getLookupKeyForMessage(MessageContext messageContext) throws Exception { TransportContext transportContext = TransportContextHolder.getTransportContext(); if (transportContext != null) { WebServiceConnection connection = transportContext.getConnection(); if (connection != null) { URI connectionUri = connection.getUri(); if (usePath) { return connectionUri.getPath(); } else { return connectionUri.toString(); } } } return null; } }
@Override protected String getLookupKeyForMessage(MessageContext messageContext) throws Exception { TransportContext transportContext = TransportContextHolder.getTransportContext(); if (transportContext != null) { WebServiceConnection connection = transportContext.getConnection(); if (connection != null) { URI connectionUri = connection.getUri(); if (usePath) { return connectionUri.getPath(); } else { return connectionUri.toString(); } } } return null; } }
/** * If Http status code is set on reply message headers simulate Http error with status code. * No SOAP response is sent back in this case. * @param replyMessage * @return * @throws IOException */ private boolean simulateHttpStatusCode(Message replyMessage) throws IOException { if (replyMessage == null || CollectionUtils.isEmpty(replyMessage.getHeaders())) { return false; } for (Entry<String, Object> headerEntry : replyMessage.getHeaders().entrySet()) { if (headerEntry.getKey().equalsIgnoreCase(SoapMessageHeaders.HTTP_STATUS_CODE)) { WebServiceConnection connection = TransportContextHolder.getTransportContext().getConnection(); int statusCode = Integer.valueOf(headerEntry.getValue().toString()); if (connection instanceof HttpServletConnection) { ((HttpServletConnection)connection).setFault(false); ((HttpServletConnection)connection).getHttpServletResponse().setStatus(statusCode); return true; } else { log.warn("Unable to set custom Http status code on connection other than HttpServletConnection (" + connection.getClass().getName() + ")"); } } } return false; }
public void doWithMessage(WebServiceMessage message) { TransportContext context = TransportContextHolder.getTransportContext(); HttpUrlConnection connection = (HttpUrlConnection) context.getConnection(); connection.getConnection().addRequestProperty("Authorization", BasicAuthenticationUtil.generateBasicAutenticationHeader(clientConfig.getUserName(), clientConfig.getUserPassword())); } });