title: How to get SOAP headers
body: <p>Here is the request</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:soap="http://soap.ws.server.wst.fit.cvut.cz/"&gt;
      &lt;soapenv:Header&gt;
          &lt;userId&gt;someId&lt;/userId&gt;
      &lt;/soapenv:Header&gt;
      &lt;soapenv:Body&gt;
      ...
      &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>and I want to get that <code>userId</code>.</p>
  
  <p>I tried this</p>
  
  <pre><code>private List&lt;Header&gt; getHeaders() {
      MessageContext messageContext = context.getMessageContext();
      if (messageContext == null || !(messageContext instanceof WrappedMessageContext)) {
          return null;
      }
      Message message = ((WrappedMessageContext) messageContext).getWrappedMessage();
      return CastUtils.cast((List&lt;?&gt;) message.get(Header.HEADER_LIST));
  }
  
  private String getHeader(String name) {
      List&lt;Header&gt; headers = getHeaders();
      if (headers != null) {
          for (Header header : headers) {
              logger.debug(header.getObject());
              // return header by the given name                   
          }
      }
      return null;
  }
  </code></pre>
  
  <p>And it logs <code>[userId : null]</code>. How can I get the value and why is <code>null</code> there?</p>