Hi

I've added a test verifying it works

http://svn.apache.org/viewvc?view=revision&revision=1053402 (see the
Modified links)

Here's the relevant parts :

@Test
    public void testGetBook123UserModelAuthorize() throws Exception {
        JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
        bean.setAddress("http://localhost:"; + PORT +
"/usermodel/bookstore/books");
        bean.setUsername("Barry");
        bean.setPassword("password");

bean.setModelRef("classpath:org/apache/cxf/systest/jaxrs/resources/resources.xml");
        WebClient proxy = bean.createWebClient();
        proxy.path("{id}/authorize", 123);

        Book book = proxy.get(Book.class);
        assertEquals(123L, book.getId());
    }

Model :

<operation name="getBookWithAuthorization" verb="GET"
path="/books/{id}/authorize">
        <param name="id" type="PATH"/>
        <param name="authorization" type="HEADER"/>
    </operation>

Note that you really do not need to use JAX-RS annotations such as
HeaderParam if you chose to go with the user model approach.

Can you please confirm this header  is actually available on the wire ?
Additionally - please have

@Context HttpHeaders headers;

in a field and confirm the header is available by querying it inside the
method body.

hope it helps, Sergey

On Tue, Dec 28, 2010 at 12:42 PM, Ivan Vitoria Sanchez <
[email protected]> wrote:

> Hi guys,
>
>
>
> I can't get the Authorization header param in a JAX-RS server.  Is
> @HeaderParam the way?
>
>
>
> I've configured CXF 2.3.1 with Spring 3. My applicationContext.xml has the
> following jax-rs server bean:
>
>
>
> <jaxrs:server id="userServer"
> modelRef="classpath:/WEB-INF/model/UserModel.xml" address="/users">
>
> ... (logging feature, service bean...)
>
> </jaxrs:server>
>
>
>
> UserModel.xml config:
>
>
>
> <model xmlns="http://cxf.apache.org/jaxrs";>
>
>    <resource name=" UserRestService" path="/"
> consumesType="application/xml" producesType="application/xml">
>
>        <operation name="getUserByLogin" verb="GET" path="/login">
>
>            <param name="authorization" type="HEADER" />
>
>        </operation>
>
>    </resource>
>
> </model>
>
>
>
> Finally, the service implementation:
>
>
>
> public class UserRestService implements IRestService
>
> {
>
>    public ElementWrapper<MobilityUser>
> getUserByLogin(@HeaderParam(HttpHeaders.AUTHORIZATION) String
> authorization)
>
>   {
>
>                // authorization is empty at this point...
>
>   }
>
> }
>
>
>
>
>
> I'm sure the Authorization header is sent because i'm also using Spring
> Security, which allows the request via Basic Authentication. It doesn't
> work
> if i disable Spring Security.
>
>
>
> Thanks in advance,
>
>
>
> Ivan
>
>
>
>

Reply via email to