title: CXF: Add implicit headers to WSDL and WADL responses for a CXF SOAP/REST web service
body: <p>I am trying to add implicit headers to WSDL and WADL responses for a CXF SOAP/REST web service (which is managed by Camel).</p>
  
  <p>(These are not necessarily security headers....)</p>
  
  <p>By "implicit header" I mean that hitting the WSDL/WADL URL of the service will show that it's expected of the client to provide the header in the request.</p>
  
  <p>But I do not want to explicitly specify the header in the signature of the web service.</p>
  
  <p>I have a CXF interceptor that adds an implicit header to every SOAP/REST response.</p>
  
  <p>So since WSDL/WADL document are sent as a response to some GET request, I was thinking to somehow use a similar interceptor to add the header data to WSDL/WADL response. How could I carry out such a marvellous feat?</p>
  
  <p>Here is the CXF interceptor that adds an implicit header to every SOAP/REST response:</p>
  
  <pre><code>public class MyInterceptor extends AbstractPhaseInterceptor&lt;Message&gt; {
  
      public MyInterceptor()
      {
          super(Phase.RECEIVE);
      }
  
      @Override
      public void handleMessage(Message message)
      {   
          try
          {
              //soap
              if (message instanceof SoapMessage)
              {               
                  List&lt;Header&gt; headers = ((SoapMessage)message).getHeaders();
  
                  Header dummyHeader = new Header(new QName("uri:org.apache.cxf", "dummy"), "decapitated", new JAXBDataBinding(String.class));
  
                  headers.add(dummyHeader);
              }
              //rest
              else
              {
                  Map&lt;String, List&gt; headers = (Map&lt;String, List&gt;) message.get(Message.PROTOCOL_HEADERS);
  
                  String dummyHeader = "decapitated";
  
                  headers.put("dummy", Collections.singletonList(dummyHeader));
              }
  
          }
          catch (JAXBException e)
          {
              throw new Fault(e);
          }
      }
  
      @Override
      public void handleFault(Message messageParam)
      {
      }
  }
  </code></pre>