Hi

HttpHeaders.getRequestHeader(key) returns List<String> and indeed, internal Message keeps a Map<String, List<String>> to represent headers which have been parsed earlier as the raw header value might have multiple parameters seperated by';'.

If you have a single value header and you'd like to avoid explicitly dealing 
with Lists you might want to consider using
MultivaluedMap :

//creates a header
HttpHeaders.getRequestHeaders().putFirst(key)

// retrieves its single value
HttpHeaders.getRequestHeaders().getFirst(key)

Cheers, Sergey

----- Original Message ----- From: "Gabo Manuel" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, November 06, 2008 9:52 AM
Subject: Re: [JAX-RS][Exchange] Accessing the in/out message in service 
implementation


Hi All,

Just some work-around I did. I used the http header as an "all-purpose"
map. The only quirk I find here is that the header should be a List,
otherwise HttpHeaders.getHeader(key) causes a ClassCastException. Why
does it do so?

Gabo

Gabo Manuel wrote:
Hi All,

I was hoping to have some things set in the handlers, e.g. username
passed in the Authorization token; and have that username (or a java
bean) available when the method is finally invoked.

I've read somewhere that the class org.apache.cxf.message.Exchange
would have the in and out Message available for JAX-RS services,
however, I am not sure how to get the said object. I have tried having
the following as method parameter or as class variable to no avail:

@Context
Exchange ex

As a parameter, the handlers are able to finish, but when it comes to
invocation of the actual method/endpoint I get this exception:
<ns1:faultstring
xmlns:ns1="http://cxf.apache.org/bindings/xformat";>java.lang.IllegalArgumentException:
wrong number of arguments</ns1:faultstring>

As a class variable, the said object is always null.

Again, my thanks.

Gabo
------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.175 / Virus Database: 270.9.0/1770 - Release Date: 11/5/2008 5:36 
PM




Reply via email to