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-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. >> > >
