I am trying to add implicit headers to WSDL and WADL responses for a CXF SOAP/REST web service (which is managed by Camel).
(These are not necessarily security headers....)
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.
But I do not want to explicitly specify the header in the signature of the web service.
I have a CXF interceptor that adds an implicit header to every SOAP/REST response.
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?
Here is the CXF interceptor that adds an implicit header to every SOAP/REST response:
public class MyInterceptor extends AbstractPhaseInterceptor<Message> {
public MyInterceptor()
{
super(Phase.RECEIVE);
}
@Override
public void handleMessage(Message message)
{
try
{
//soap
if (message instanceof SoapMessage)
{
List<Header> 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<String, List> headers = (Map<String, List>) 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)
{
}
}