cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Conrad O'Dea" <conrad.o...@iona.com>
Subject Re: setting HTTP response headers
Date Thu, 02 Nov 2006 08:53:21 GMT
Cool thanks. 

Is there anything I can do to help?

thanks
Conrad 

On Thu, 2006-11-02 at 16:16 +0800, Freeman Fang wrote:
> Hi Conrad,
> 
> I donot think we can get outMessage from EndpointImpl so far.
> And Willem give more reasonable explaination for it
> ======================
> Hi Conrad,
> 
> I had done some work of the context mapping in CXF,  I can give you some
> explanations.
> 
> First, CXF has a jax-ws front end to wrap all the things about the
> jax-ws, so I implemented an mapper which get the connection between
> jax-ws context and rt-core message context.
> Current CXF jax-ws front end mapper just implement a limited mapping of
> BindingProvider and MessageContext's defined properties to rt-core, that
> is why you can't use
> javax.xml.ws.handler.MessageContext.HTTP_REQUEST_HEADERS to get the
> request headers.
> 
> Second, I went though the code and found the http header which you want
> to pass to the response wouldn't take any effect because you just set on
> the context ( which we get from  inMessage's context)and it would not
> effect to outMessage's context in current code.
> =================================
> 
> A jira task https://issues.apache.org/jira/browse/CXF-197 already 
> created to track this issue and Willem will fix it very soon
> 
> Thanks very much
> 
> Freeman
>  
> Conrad O'Dea wrote:
> 
> >Hi Freeman, 
> >
> >On Thu, 2006-11-02 at 11:04 +0800, Freeman Fang wrote:
> >
> >  
> >
> >>I guess you need set headers into  outMessage which is  instance of 
> >>org.apache.cxf.message.Message
> >>
> >>outMessage.put(Message.PROTOCOL_HEADERS, hdrs);
> >>
> >>I just paste some code from AbstractHTTPDestination.java  and 
> >>JettyHTTPDestination.java where do setHeaders work
> >>
> >>protected void setHeaders(Message message) {
> >>    Map<String, List<String>> requestHeaders = new HashMap<String,

> >>List<String>>();
> >>    copyRequestHeaders(message, requestHeaders);
> >>    message.put(Message.PROTOCOL_HEADERS, requestHeaders);
> >>    ....
> >>}
> >>    
> >>
> >
> >thanks for that.  The code I'm writing is basically JAX-WS (although
> >becoming more cxf specific).  Is it possible to get from the
> >EndpointImpl to the outMessage?
> >
> >
> >  
> >
> >> 
> >>    protected void copyRequestHeaders(Message message, Map<String, 
> >>List<String>> headers) {
> >>        HttpRequest req = (HttpRequest)message.get(HTTP_REQUEST);
> >>        for (Enumeration e = req.getFieldNames(); e.hasMoreElements();) {
> >>            String fname = (String)e.nextElement();
> >>            List<String> values;
> >>            if (headers.containsKey(fname)) {
> >>                values = headers.get(fname);
> >>            } else {
> >>                values = new ArrayList<String>();
> >>                headers.put(fname, values);
> >>            }
> >>            for (Enumeration e2 = req.getFieldValues(fname); 
> >>e2.hasMoreElements();) {
> >>                String val = (String)e2.nextElement();
> >>                values.add(val);
> >>            }
> >>        }
> >>    }
> >>Thanks very much
> >>
> >>Freeman
> >>
> >>
> >>Conrad O'Dea wrote:
> >>
> >>    
> >>
> >>>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