Yes, I have declared the SOAP header as parameter in my WSDL(using
@WebParam(header
= true, name = "system"))

I am trying to retrieve the value from Header on basis of name of
header(here it is system). Header name can be anything that I am
configuring in service signature. Getting list of values using
message.getContent(List.class)
will not resolve my purpose as I am unable to identify which value is there
for header param.

Can you please let me know if I change my configuration from
Phase.PRE_INVOKE to Phase.UNMARSHAL, will there be any side effects of
this??

Thanks, Puneet.

On Thu, Sep 18, 2014 at 3:59 PM, Andrei Shakirin <[email protected]>
wrote:

> Hi,
>
> Ok, I guess you have declared this SOAP header as parameter in your wsdl.
> In this case header will be removed from message soap headers, but added
> to the message content.
> You can get this header value using message.getContent(List.class) after
> SoapHeaderInterceptor.
>
> I don't know exactly the reason why we delete the parameter from message
> headers, will look on this.
>
> Regards,
> Andrei.
>
> > -----Original Message-----
> > From: Puneet Gupta [mailto:[email protected]]
> > Sent: Donnerstag, 18. September 2014 11:58
> > To: [email protected]
> > Subject: Re: Unable to retrieve <soapenv:Header> elements in
> interceptors.
> >
> > Line No 130 in SoapHeaderInterceptor is removing the header. Can you help
> > understand why its been like this??
> >
> > On Thu, Sep 18, 2014 at 3:13 PM, Andrei Shakirin <[email protected]>
> > wrote:
> >
> > > Try to call System.out.println(message.getInterceptorChain()) from
> > > your interceptor; You will see which interceptors are activated on
> > > which phases.
> > >
> > > Regards,
> > > Andrei.
> > >
> > > > -----Original Message-----
> > > > From: Puneet Gupta [mailto:[email protected]]
> > > > Sent: Donnerstag, 18. September 2014 11:40
> > > > To: [email protected]
> > > > Subject: Re: Unable to retrieve <soapenv:Header> elements in
> > > interceptors.
> > > >
> > > > Yes my interceptor is getting called when configured for
> > > > Phase.PRE_INVOKE and I am not able to retrieve the header in there.
> > > >
> > > > To identify the problem point, I am trying configuring different
> phases.
> > > > Upto Phase.UNMARSHAL I am able to retrieve the header values but
> > > > when I
> > > am
> > > > configuring it to be PRE_LOGICAL(which is supposed to be next
> > > interceptor in
> > > > chain), I am not able to get the headers. So I believe that
> > > > Unmarshal
> > > phase is
> > > > causing the issue here.
> > > >
> > > > Can you guide me identifying classes there for different
> > > > interceptors. I
> > > am not
> > > > able to find the interceptor that is been called by CXF for
> > > unmarshalling. Sorry
> > > > for keep on bothering you. :)
> > > >
> > > > Thanks, Puneet.
> > > >
> > > > On Thu, Sep 18, 2014 at 2:58 PM, Andrei Shakirin
> > > > <[email protected]>
> > > > wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > SOAP header must be available on Phase.PRE_INVOKE as well: just
> > > > > checked that.
> > > > >
> > > > > Could the header be removed by other custom interceptor?
> > > > > Are you sure that your interceptor on Phase.PRE_INVOKE is called
> > > > > at
> > > all?
> > > > > (If some faults occur, interceptor chain can be broken early).
> > > > >
> > > > > If not, can you set breakpoint on interceptor by different phases
> > > > > and inspect the message to determine where header is removed?
> > > > >
> > > > > Regards,
> > > > > Andrei.
> > > > >
> > > > > > -----Original Message-----
> > > > > > From: Puneet Gupta [mailto:[email protected]]
> > > > > > Sent: Donnerstag, 18. September 2014 10:43
> > > > > > To: [email protected]
> > > > > > Subject: Re: Unable to retrieve <soapenv:Header> elements in
> > > > > interceptors.
> > > > > >
> > > > > > 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.
> > > > > > > > >>
> > > > > > > > >
> > > > > > > > >
> > > > > > >
> > > > >
> > >
>

Reply via email to