I'm trying to add a SOAPHeader to my request using a custom soap header
OutInterceptor. I don't want to use ((BindingProvider)
proxy).getRequestContext().put(Header.HEADER_LIST, headers);

The class is a such :

public class CustomSoapHeaderOutInterceptor extends AbstractSoapInterceptor
{
        
        public CustomSoapHeaderOutInterceptor() {
                super(Phase.WRITE);
                
        }

        @Override
        public void handleMessage(SoapMessage message) throws Fault{
        
                        
                        SoapMessage soapMessage = (SoapMessage) message;
                        List<Header> list = message.getHeaders();
                        
                        QName q = new QName("http://commons.cxf.learning.com/";, 
"HeaderService");
                        Person person = new Person();
                        person.setName("one person");
                        JAXBDataBinding dataBinding = null;
                                try {
                                        dataBinding = new 
JAXBDataBinding(person.getClass());
                                } catch (JAXBException e1) {
                                        e1.printStackTrace();
                                }
                                
                                SoapHeader header = new SoapHeader(q,person, 
dataBinding);
                        list.add(header);
                        
        }
}


This seems to work just fine. I just want to know if this is the correct way
of doing it or do we need to extend some other specific interceptor.
-- 
View this message in context: 
http://www.nabble.com/Adding-SOAPHeader-using-an-Interceptor-tp25818665p25818665.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to