title: Camel Spring-WS. Setting custom SOAP header
body: <p>I have configured Camel SOAP proxy service using Spring DSL. Everything was working nice untill I found that I need to set a custom header inside  for SOAP response message.</p>
  
  <p>I am using spring-ws component and latest Camel 2.10.0.</p>
  
  <p>Here is an example of my spring route (I skipped some irrelevant transformations):</p>
  
  <pre><code>&lt;bean id="ahc_binding" class="ru.fabit.ExampleAHCBinding"/&gt;
  
  &lt;bean id="response_assembler" class="ru.fabit.ExampleResponseAssembler"/&gt;
  
  &lt;camel:camelContext id="get_regions"&gt;
  
      &lt;camel:dataFormats&gt;
          &lt;camel:jaxb id="main_jaxb" prettyPrint="true"
                      contextPath="ru.fabit.rosstelecom.webservice.models.smev" /&gt;
      &lt;/camel:dataFormats&gt;
  
      &lt;camel:route&gt;
          &lt;camel:from uri="spring-ws:rootqname:{http://fabit.ru/service}getRegionsRequest?endpointMapping=#endpointMapping"/&gt;
  
          &lt;camel:unmarshal ref="main_jaxb"/&gt;
  
          &lt;camel:to uri="ahc:http://localhost:9001/service/regions"/&gt;
  
          &lt;camel:unmarshal ref="main_jaxb"/&gt;
  
          &lt;camel:process ref="response_assembler"/&gt;
  
      &lt;/camel:route&gt;
  &lt;/camel:camelContext&gt;
  </code></pre>
  
  <p>And here is the code for ExampleResponseAssembler.java ("response_assembler" bean). It is the last element in the route. And it's responsibility to get unmarshalled response object from some external service (from AHC component, actually) and assemble the proper SOAP response for overall route.</p>
  
  <pre><code>public class ExampleResponseAssembler implements Processor {
  
      @Override
      public void process(final Exchange exchange) throws Exception {
  
          final Object responseMessage = exchange.getIn().getBody();
          final GetRegionsResponse regionsResponse = new GetRegionsResponse();
          final MessageDataType messageData = new MessageDataType();
          final AppDataType appData = new AppDataType();
  
          appData.setAny(responseMessage);
          messageData.setAppData(appData);
          regionsResponse.setMessageData(messageData);
  
          exchange.getOut().setBody(regionsResponse);
  
          final HeaderType header = exchange.getProperty("exampleHeader", HeaderType.class);
          exchange.getOut().setHeader("CamelSpringWebServiceSoapHeader", header);
      }
  }
  </code></pre>
  
  <p>When I set the Body that way it is parsed correctly. I can see it in SaopUI. But header is not there. That was a naive approach to set the SOAP header I guess.
  And I can't find any relevant info about this.</p>
  
  <p>Although I was able to find some JIRA tickets regarding this problem - <a href="https://issues.apache.org/jira/browse/CAMEL-4515" rel="nofollow">link</a>, it is still unclear how to handle with setting some custom SOAP headers. And ticket is marked as "unresolved".
  Maybe I need some override voodoo magick here (override MessageFactory, MessageSender or something else). Seems like a minor issue, but...</p>