title: How can HTTP headers be added to JAX-WS requests in WebSphere 8.5?
body: <p>I am attempting to set a custom header on an outbound SOAP request using JAX-WS on WebSphere 8.5.5.2. The BindingProvider in the method below is obtained via JNDI for a service declared with a @ServiceRef annotation.</p>
  
  <pre><code>void setHeader(BindingProvider provider, String name, String value) {
      Map&lt;String, Object&gt; context = provider.getRequestContext();
      Map&lt;String, List&lt;String&gt;&gt; headers = null;
  
      if (context.containsKey(MessageContext.HTTP_REQUEST_HEADERS)) {
          headers = (Map&lt;String, List&lt;String&gt;&gt;)
                     context.get(MessageContext.HTTP_REQUEST_HEADERS);
      }
  
      if (headers == null) {
          headers = new HashMap&lt;String, List&lt;String&gt;&gt;();
          context.put(MessageContext.HTTP_REQUEST_HEADERS, headers);
      }
  
      headers.put(name, Arrays.asList(value));
  }
  </code></pre>
  
  <p>They key here, I think, is related to WebSphere. If I instead put the HTTP headers into an IBM-specific entry of the context:</p>
  
  <p><code>com.ibm.websphere.webservices.Constants.REQUEST_TRANSPORT_PROPERTIES</code></p>
  
  <p>the headers are properly placed into the SOAP HTTP request. Note that in case, the value is not wrapped inside a List instance. </p>
  
  <p>Has anyone successfully implemented this solution on WebSphere using <code>MessageContext.HTTP_REQUEST_HEADERS</code>?</p>