title: CXF: add SOAP header to request
body: <p>I tried to add SOAP header to my request via <code>BindingProvider.getRequestContext().put(Header.HEADER_LIST, headers)</code> but the SOAP Header is missing. My code is like the following:</p>
  
  <p>Standard WebService class generated by CXF:</p>
  
  <pre><code>@WebService(targetNamespace = "...", name = "...")
  @XmlSeeAlso({...ObjectFactory.class})
  @SOAPBinding(parameterStyle = SOAPBinding.ParameterStyle.BARE)
  public interface MyService {
      ... 
      @WebMethod(operationName = "...")
      public Future&lt;?&gt; sendAsync(
          @WebParam(partName = "parameters", name = "...", targetNamespace = "...")
          MyRequestMessageType parameters,
          @WebParam(name = "asyncHandler", targetNamespace = "")
          AsyncHandler&lt;MyResponseMessageType&gt; asyncHandler
      );
  }
  </code></pre>
  
  <p>Standard WebServiceClient class generated by CXF</p>
  
  <pre><code>@WebServiceClient(name = "...", wsdlLocation = "...", targetNamespace = "...") 
  public class MyService_Service extends Service {
      ...
      @WebEndpoint(name = "...")
      public MyService getVendorManagementService() {
          return super.getPort(MY_SERVICE, MyService.class);
      }
  }
  </code></pre>
  
  <p>Class which sends my request:</p>
  
  <pre><code>@Inject
  private MyService_Service myService;
  
  public void send() {        
      BindingProvider port = (BindingProvider) myService.getWebEndpointPort(); 
      port.getRequestContext().put("thread.local.request.context", "true");
  
      List&lt;Header&gt; headers = getHeaders(port.getRequestContext());
      Header messageIDHeader = new Header(new QName("http://www.w3.org/2005/08/addressing", "MessageID", "wsa"), "some_id", new JAXBDataBinding(String.class));
      headers.add(messageIDHeader);
      port.getRequestContext().put(Header.HEADER_LIST, headers);        
  
      MyRequestMessageType message = messageCreator.createMyRequestMessage();
      MyAsyncHandler asyncHandler = new MyAsyncHandler();
      ((MyService) port).sendAsync(message, asyncHandler);
  }
  
  private static List&lt;Header&gt; getHeaders(Map&lt;String, Object&gt; messageContext) {
      if (messageContext == null) {
          return null;
      }
      List&lt;Header&gt; headers = CastUtils.cast((List&lt;?&gt;) messageContext.get(Header.HEADER_LIST));
      if (headers == null){
          return new ArrayList&lt;Header&gt;();
      }
      return headers;
  }
  </code></pre>
  
  <p>It generates correct request but SOAP Header is missing. The request contains only SOAP Body:</p>
  
  <pre><code>&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;soap:Body&gt;
    ... the message is OK
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>I have no idea what is wrong.
  Thanks for any advice.</p>