cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conrad O'Dea" <co...@iona.com>
Subject setting HTTP response headers
Date Wed, 01 Nov 2006 20:54:33 GMT
Hi,

I'm porting a RESTy service from Celtix 1.something to CXF and have  
noticed some differences in the way the HTTP protocol headers are  
handled.

For example, in a service implemented using a Provider, I've tried  
getting the headers from the MessageContext like this:

	ctx.get(javax.xml.ws.handler.MessageContext.HTTP_REQUEST_HEADERS);

This returns null though.  Calling:

	Map<String, List<String>>hdrs = ctx.get 
(org.apache.cxf.message.Message.PROTOCOL_HEADERS);

works though and I can get the headers ok.

I also need to set the response headers and should be able to set a  
header like this:

       Map<String, List<String>>hdrs = ctx.get 
(javax.xml.ws.handler.MessageContext.HTTP_RESPONSE_HEADERS);
       hdrs.put(headerName, headerValue);

and have it added to the outgoing response.  However, as above using  
the MessageContext property does not return anything.  I've tried  
using the org.apache.cxf.message.Message property like this

       Map<String, List<String>>hdrs = ctx.get 
(org.apache.cxf.message.Message.PROTOCOL_HEADERS);
       hdrs.put(headerName, headerValue);

but there's no sign that the header has been correctly added.  Is  
there some other way to set a HTTP header on the response?

thanks
Conrad



Mime
View raw message