Hi Andrei, CXF version is 2.7.11. My interceptor is working on Phase.PRE_INVOKE and it is configured as jaxws:inInterceptors. Does that make any difference.
I tried with Phase.POST_PROTOCOL and it worked for me. I was also debugging ReadHeadersInterceptor and there in I found that SOAP header is do getting included in SoapMessage. Is it possible that header is getting removed in between other phases before invoking PRE_INVOKE interceptor?? Thanks, Puneet. On Thu, Sep 18, 2014 at 1:05 PM, Andrei Shakirin <[email protected]> wrote: > Hi, > > I am able to get SOAP Headers from your request using following code: > > public class SOAPHeaderInterceptor extends > AbstractPhaseInterceptor<SoapMessage> { > > public SOAPHeaderInterceptor() { > super(Phase.POST_PROTOCOL); > } > > @Override > public void handleMessage(SoapMessage message) throws Fault { > List<Header> headers = (List<Header>) > message.get(Header.HEADER_LIST); > > for (Header header : headers) { > System.out.println(header.getName()); > } > } > } > > SOAPHeaderInterceptor is configured as inbound service interceptor. > > Are you sure that your interceptor is correctly configured and invoked? > What version of CXF are you using? > > Regards, > Andrei. > > > -----Original Message----- > > From: Puneet Gupta [mailto:[email protected]] > > Sent: Donnerstag, 18. September 2014 07:34 > > To: [email protected] > > Subject: Re: Unable to retrieve <soapenv:Header> elements in > interceptors. > > > > Hi Andrei, > > > > I am not able to extract SOAP header using suggested approach. I am > sending > > the same soap request and unable to retrieve any header from request. > > Request send as as below: > > > > <soapenv:Envelope > > xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" > > xmlns:web="http://webservice.test.com"> > > <soapenv:Header> > > <web:system>valueSystem</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> > > > > Can you suggest if I am missing anything. > > > > Thanks, Puneet. > > > > > > On Tue, Sep 16, 2014 at 9:28 AM, Puneet Gupta > > <[email protected]> > > wrote: > > > > > Thanks Andrei for the solution. I have been looking for it for a while. > > > > > > With respect to your second point I am not getting username and > > > password from SOAP header. Instead they are part of SOAP body. Purpose > > > of doing this it so is because we have migrated from Axis2 to Apache > > > CXF and we don't want our client to change their authentication > > > process. Hence sticking with our old approach. > > > > > > Thanks again for your help. > > > > > > On Mon, Sep 15, 2014 at 5:57 PM, Andrei Shakirin > > > <[email protected]> > > > wrote: > > > > > >> 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-spe > > >> c-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. > > >> > > > > > > >
