title: How do i modify HTTP headers for a JAX-WS response in CXF?
body: <p>I have been working on developing CXF web services that sit behind a security proxy which asks for HTTP basic authentication prior service invocation. These services communicate between each other and require authentication for both request and response. </p>
  
  <p>So far i have been able to set HTTP basic authentication via the HTTPConduit for the request like so:</p>
  
  <pre><code>    Client client = ClientProxy.getClient(port);
      HTTPConduit conduit = (HTTPConduit) client.getConduit();
      AuthorizationPolicy authorizationPolicy = new AuthorizationPolicy();
      authorizationPolicy.setUserName(username);
      authorizationPolicy.setPassword(password);
      authorizationPolicy.setAuthorizationType("Basic");
      conduit.setAuthorization(authorizationPolicy);
  </code></pre>
  
  <p>The method above is called on every service method invocation and i'm getting correct inbound messages in the form of</p>
  
  <pre><code>INFO: Inbound Message
  ----------------------------
  ID: 1
  Address: http://someURL/someService?wsdl
  Encoding: UTF-8
  Http-Method: POST
  Content-Type: text/xml; charset=UTF-8
  Headers: {Accept=[*/*], Authorization=[Basic {TOKEN}], 
                  cache-control=[no-cache], connection=[keep-alive], 
                  Content-Length=[735], content-type=[text/xml; charset=UTF-8], 
                  pragma=[no-cache], ...}
  Payload: &lt;soap:Envelope&gt;...&lt;/soap:Envelope&gt;
  --------------------------------------
  </code></pre>
  
  <p>The response, however, doesn't contain the required headers</p>
  
  <pre><code>INFO: Outbound Message
  ---------------------------
  ID: 2
  Encoding: UTF-8
  Content-Type: text/xml
  Headers: {}
  Payload: &lt;soap:Envelope/"&gt;...&lt;/soap:Envelope&gt;
  --------------------------------------
  </code></pre>
  
  <p>How can i modify response HTTP headers? I've tried </p>
  
  <pre><code>((BindingProvider)port).getResponseContext().put(
             MessageContext.HTTP_RESPONSE_HEADERS, 
             Collections.singletonMap("Authentication", 
             Collections.singletonList("Basic "+token)));
  </code></pre>
  
  <p>without getting the desired result.</p>