title: How to add custom header on spring soap client
body: <p>Hi I would like to add header to spring soap client and I have a ClientAppConfig class which is like below;</p>
  
  <pre><code>@Configuration
  public class ClientAppConfig {
  
      @Bean
      public Wss4jSecurityInterceptor wss4jSecurityInterceptor() {
          Wss4jSecurityInterceptor interceptor = new Wss4jSecurityInterceptor();
          interceptor.setSecurementActions("Timestamp");
          interceptor.setSecurementUsername("user");
          interceptor.setSecurementPassword("*******");
          return interceptor;
      }
  
      @Bean
      public Jaxb2Marshaller marshaller() {
          Jaxb2Marshaller marshaller = new Jaxb2Marshaller();
          marshaller.setPackagesToScan("com");
  
          return marshaller;
      }
  
      @Bean
      public SomeClient someClient(Jaxb2Marshaller marshaller) {
          SomeClient client = new SomeClient();
          client.setDefaultUri("http://test");
          client.setMarshaller(marshaller);
          client.setUnmarshaller(marshaller);
  
          return client;
      }
  }
  </code></pre>
  
  <p>Example Client: </p>
  
  <pre><code>@Component
  public class SomeClient extends WebServiceGatewaySupport {
  
      public SomeResponse someMethod(ArrayOfLong arrayOfLong) {
          SomeRequest request = new SomeRequest();
          request.setsomeId(arrayOfLong);
          SomeResponse response = (SomeResponse) getWebServiceTemplate()
                  .marshalSendAndReceive(request, new SoapActionCallback(
                          "http://soapaction"));
          return response;
      }
  }
  </code></pre>
  
  <p>And I have wsdl request like this;</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://envelope" xmlns:v1="http://Service"&gt;
     &lt;soapenv:Header xmlns:as="http://Schema"&gt;
          &lt;wsse:Security xmlns:wsse="http://wss-wssecurity-secext-1.0.xsd"&gt;
              &lt;wsse:UsernameToken&gt;
                  &lt;wsse:Username&gt;user&lt;/wsse:Username&gt;
                  &lt;wsse:Password&gt;********&lt;/wsse:Password&gt;
              &lt;/wsse:UsernameToken&gt;
          &lt;/wsse:Security&gt;
          &lt;as:consumerContext xsi:type="as:IntWebAppContextType" xmlns:as="http://Schema" xmlns:xsi="http://XMLSchema-instance"&gt;
  
              &lt;consumerCode&gt;someCode&lt;/consumerCode&gt;
          &lt;/as:consumerContext&gt;
      &lt;/soapenv:Header&gt;
     &lt;soapenv:Body&gt;
        &lt;v1:someReceived xmlns:ns3="http://Service" xmlns:ns2="http://Schema"&gt;
           &lt;v1:parameters&gt;
              &lt;!--Optional:--&gt;
              &lt;v1:someId&gt;
                 &lt;!--Zero or more repetitions:--&gt;
                 &lt;v1:long&gt;111111111&lt;/v1:long&gt;
              &lt;/v1:someId&gt;
           &lt;/v1:parameters&gt;
        &lt;/v1:someReceived&gt;
     &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>I have added username and password but I have to add <code>as:consumerContext</code> section, I need to get consumerCode for getting response other wise Im getting error. How Can I get consumerCode with spring ws</p>