You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using CommonsHttpMessageSender in the WebServiceTemplate to support Basic Authentication (with setCredentials()), it should also delegate the Method getParams().setAuthenticationPreemptive(true) from the underlaying HttpClient to avoid a roundtrip and to always use the actual username/password if it changes during the requests.
Currently you can do that with this code:
WebServiceTemplate template = new WebServiceTemplate();
CommonsHttpMessageSender sender = new CommonsHttpMessageSender();
sender.setCredentials(new MyCredentials());
sender.getHttpClient().getParams().setAuthenticationPreemptive(true);
sender.afterPropertiesSet();
template.setMessageSender(sender);