You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Wolf, Chris (IT)" <Ch...@morganstanley.com> on 2008/06/23 23:24:18 UTC

How to access HTTP request/responce from interceptor?

I read the docs, and only found this:

http://cwiki.apache.org/CXF20DOC/servlet-transport.html#ServletTransport
-AccessingtheMessageContextand%2ForHTTPRequestandResponse 


However, I would like to access the the HTTP request object from my
subclass of 
AbstractPhaseInterceptor - how would I do that?

I tried getting the destination via SoapMessage.getDestination(), but
it's of
type "ServletDestination"...  I also tried
SoapMessage.getExchange(message).getConduit(),
but that returned null.

Thanks and any help,

   -Chris W.
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.

RE: How to access HTTP request/responce from interceptor?

Posted by "Wolf, Chris (IT)" <Ch...@morganstanley.com>.
That's exactly what I needed, thanks for the help! 

  -Chris W.

-----Original Message-----
From: Willem Jiang [mailto:willem.jiang@gmail.com] 
Sent: Monday, June 23, 2008 7:00 PM
To: users@cxf.apache.org
Subject: Re: How to access HTTP request/responce from interceptor?

You can get the HttpServletRequest and HttpServletResponse objects with
below codes  in the interceptor
 
       HttpServletRequest request = (HttpServletRequest)
message.get(AbstractHTTPDestination.HTTP_REQUEST);
       HttpServletResponse response = (HttpServletResponse)
message.get(AbstractHTTPDestination.HTTP_REQUEST);
      
Willem

Wolf, Chris (IT) wrote:
> ...on second thought, having the request headers is only part of what 
> I need, so if anybody knows how I can access the HttpServletRequest 
> object from an intercetor, that would be awesome...
>
> thanks,
>
>   -Chris W.
>
> P.S. plus being able to add elements to the SOAP header of outbout 
> and/or inbound message would be helpful, I have not learned too much 
> yet reading the source of existing interceptors...
>
> -----Original Message-----
> From: Wolf, Chris (IT)
> Sent: Monday, June 23, 2008 5:57 PM
> To: users@cxf.apache.org
> Subject: RE: How to access HTTP request/responce from interceptor?
>
> I actually looked at the source code for LogginInInterceptor to get my
> answer:
>
>       	@SuppressWarnings("unchecked")
>         	Map<String, List<String> > headers = (Map<String, 
> List<String> >)
>                 message.get(Message.PROTOCOL_HEADERS);
>         	for (Map.Entry<String, List<String> > header :
> headers.entrySet())
>         		System.out.println(header.getKey() + " : " + 
> header.getValue().get(0));
>
>
> Thanks,
>
>   -Chris W.
>
> -----Original Message-----
> From: Wolf, Chris (IT)
> Sent: Monday, June 23, 2008 5:24 PM
> To: users@cxf.apache.org
> Subject: How to access HTTP request/responce from interceptor?
>
> I read the docs, and only found this:
>
> http://cwiki.apache.org/CXF20DOC/servlet-transport.html#ServletTranspo
> rt -AccessingtheMessageContextand%2ForHTTPRequestandResponse
>
>
> However, I would like to access the the HTTP request object from my 
> subclass of AbstractPhaseInterceptor - how would I do that?
>
> I tried getting the destination via SoapMessage.getDestination(), but 
> it's of type "ServletDestination"...  I also tried 
> SoapMessage.getExchange(message).getConduit(),
> but that returned null.
>
> Thanks and any help,
>
>    -Chris W.
> --------------------------------------------------------
>
> NOTICE: If received in error, please destroy and notify sender. Sender

> does not intend to waive confidentiality or privilege. Use of this 
> email is prohibited when received in error.
> --------------------------------------------------------
>
> NOTICE: If received in error, please destroy and notify sender. Sender

> does not intend to waive confidentiality or privilege. Use of this 
> email is prohibited when received in error.
> --------------------------------------------------------
>
> NOTICE: If received in error, please destroy and notify sender. Sender
does not intend to waive confidentiality or privilege. Use of this email
is prohibited when received in error.
>
>
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.

Re: How to access HTTP request/responce from interceptor?

Posted by Willem Jiang <wi...@gmail.com>.
You can get the HttpServletRequest and HttpServletResponse objects with 
below codes  in the interceptor
 
       HttpServletRequest request = (HttpServletRequest) 
message.get(AbstractHTTPDestination.HTTP_REQUEST);
       HttpServletResponse response = (HttpServletResponse) 
message.get(AbstractHTTPDestination.HTTP_REQUEST);
      
Willem

Wolf, Chris (IT) wrote:
> ...on second thought, having the request headers is only part of what I
> need,
> so if anybody knows how I can access the HttpServletRequest object from
> an
> intercetor, that would be awesome...
>
> thanks,
>
>   -Chris W.
>
> P.S. plus being able to add elements to the SOAP header of outbout
> and/or
> inbound message would be helpful,
> I have not learned too much yet reading the source of existing
> interceptors...
>
> -----Original Message-----
> From: Wolf, Chris (IT) 
> Sent: Monday, June 23, 2008 5:57 PM
> To: users@cxf.apache.org
> Subject: RE: How to access HTTP request/responce from interceptor?
>
> I actually looked at the source code for LogginInInterceptor to get my
> answer:
>
>       	@SuppressWarnings("unchecked")
>         	Map<String, List<String> > headers = (Map<String,
> List<String> >)
>                 message.get(Message.PROTOCOL_HEADERS);
>         	for (Map.Entry<String, List<String> > header :
> headers.entrySet())
>         		System.out.println(header.getKey() + " : " +
> header.getValue().get(0)); 
>
>
> Thanks,
>
>   -Chris W.
>
> -----Original Message-----
> From: Wolf, Chris (IT)
> Sent: Monday, June 23, 2008 5:24 PM
> To: users@cxf.apache.org
> Subject: How to access HTTP request/responce from interceptor?
>
> I read the docs, and only found this:
>
> http://cwiki.apache.org/CXF20DOC/servlet-transport.html#ServletTransport
> -AccessingtheMessageContextand%2ForHTTPRequestandResponse 
>
>
> However, I would like to access the the HTTP request object from my
> subclass of AbstractPhaseInterceptor - how would I do that?
>
> I tried getting the destination via SoapMessage.getDestination(), but
> it's of type "ServletDestination"...  I also tried
> SoapMessage.getExchange(message).getConduit(),
> but that returned null.
>
> Thanks and any help,
>
>    -Chris W.
> --------------------------------------------------------
>
> NOTICE: If received in error, please destroy and notify sender. Sender
> does not intend to waive confidentiality or privilege. Use of this email
> is prohibited when received in error.
> --------------------------------------------------------
>
> NOTICE: If received in error, please destroy and notify sender. Sender
> does not intend to waive confidentiality or privilege. Use of this email
> is prohibited when received in error.
> --------------------------------------------------------
>
> NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.
>
>   


RE: How to access HTTP request/responce from interceptor?

Posted by "Wolf, Chris (IT)" <Ch...@morganstanley.com>.
...on second thought, having the request headers is only part of what I
need,
so if anybody knows how I can access the HttpServletRequest object from
an
intercetor, that would be awesome...

thanks,

  -Chris W.

P.S. plus being able to add elements to the SOAP header of outbout
and/or
inbound message would be helpful,
I have not learned too much yet reading the source of existing
interceptors...

-----Original Message-----
From: Wolf, Chris (IT) 
Sent: Monday, June 23, 2008 5:57 PM
To: users@cxf.apache.org
Subject: RE: How to access HTTP request/responce from interceptor?

I actually looked at the source code for LogginInInterceptor to get my
answer:

      	@SuppressWarnings("unchecked")
        	Map<String, List<String> > headers = (Map<String,
List<String> >)
                message.get(Message.PROTOCOL_HEADERS);
        	for (Map.Entry<String, List<String> > header :
headers.entrySet())
        		System.out.println(header.getKey() + " : " +
header.getValue().get(0)); 


Thanks,

  -Chris W.

-----Original Message-----
From: Wolf, Chris (IT)
Sent: Monday, June 23, 2008 5:24 PM
To: users@cxf.apache.org
Subject: How to access HTTP request/responce from interceptor?

I read the docs, and only found this:

http://cwiki.apache.org/CXF20DOC/servlet-transport.html#ServletTransport
-AccessingtheMessageContextand%2ForHTTPRequestandResponse 


However, I would like to access the the HTTP request object from my
subclass of AbstractPhaseInterceptor - how would I do that?

I tried getting the destination via SoapMessage.getDestination(), but
it's of type "ServletDestination"...  I also tried
SoapMessage.getExchange(message).getConduit(),
but that returned null.

Thanks and any help,

   -Chris W.
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender
does not intend to waive confidentiality or privilege. Use of this email
is prohibited when received in error.
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender
does not intend to waive confidentiality or privilege. Use of this email
is prohibited when received in error.
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.

RE: How to access HTTP request/responce from interceptor?

Posted by "Wolf, Chris (IT)" <Ch...@morganstanley.com>.
I actually looked at the source code for LogginInInterceptor to get my
answer:

      	@SuppressWarnings("unchecked")
        	Map<String, List<String> > headers = (Map<String,
List<String> >)
                message.get(Message.PROTOCOL_HEADERS);
        	for (Map.Entry<String, List<String> > header :
headers.entrySet())
        		System.out.println(header.getKey() + " : " +
header.getValue().get(0)); 


Thanks,

  -Chris W.

-----Original Message-----
From: Wolf, Chris (IT) 
Sent: Monday, June 23, 2008 5:24 PM
To: users@cxf.apache.org
Subject: How to access HTTP request/responce from interceptor?

I read the docs, and only found this:

http://cwiki.apache.org/CXF20DOC/servlet-transport.html#ServletTransport
-AccessingtheMessageContextand%2ForHTTPRequestandResponse 


However, I would like to access the the HTTP request object from my
subclass of AbstractPhaseInterceptor - how would I do that?

I tried getting the destination via SoapMessage.getDestination(), but
it's of type "ServletDestination"...  I also tried
SoapMessage.getExchange(message).getConduit(),
but that returned null.

Thanks and any help,

   -Chris W.
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender
does not intend to waive confidentiality or privilege. Use of this email
is prohibited when received in error.
--------------------------------------------------------

NOTICE: If received in error, please destroy and notify sender. Sender does not intend to waive confidentiality or privilege. Use of this email is prohibited when received in error.