Hi, Try this code to extract SOAP Headers:
import org.apache.cxf.headers.Header; ... List<Header> headers = (List<Header>) message.get(Header.HEADER_LIST); Additional note: the OASIS specifies standard way to send UsernameToken in SOAP messages, supported by CXF: https://www.oasis-open.org/committees/download.php/16782/wss-v1.1-spec-os-UsernameTokenProfile.pdf https://web-gmazza.rhcloud.com/blog/entry/cxf-usernametoken-profile . Do you have a good reasons to use proprietary headers to transfer username and password? Regards, Andrei. > -----Original Message----- > From: Puneet Gupta [mailto:[email protected]] > Sent: Montag, 15. September 2014 06:48 > To: [email protected] > Subject: Unable to retrieve <soapenv:Header> elements in interceptors. > > Hi All, > > Below is the SOAP request which I am sending: > > <soapenv:Envelope > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" > xmlns:web="http://webservice.test.com"> > <soapenv:Header> > <web:system>valueHeader</web:system> > </soapenv:Header> > <soapenv:Body> > <web:authenticateUser> > <!--Optional:--> > <web:username>valueUsername</web:username> > <!--Optional:--> > <web:password>valuePassword</web:password> > </web:authenticateUser> > </soapenv:Body> > </soapenv:Envelope> > > In In-Interceptor configured for input request, I am trying to retrieve header > value from SoapMessage but always getting blank list. Following code > used: > > protected List<Header> getHeader(SoapMessage message){ return > message.getHeaders(); } > > I am not able to retrieve the value from <soapenv:Header>. > > My interceptor is working on Phase.PRE_INVOKE. > > How can I retrieve the header value in In-Interceptor? > > Note: I have tried using WebServiceContext and always getting null for it. > Also its been suggested not to use WebServiceContext in interceptors: > https://issues.apache.org/jira/browse/CXF-2674 > > Please help. > > Thanks, Puneet.
