You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by "Duncan Keysell (dkeysell)" <dk...@cisco.com> on 2014/10/17 14:40:04 UTC

Configure resource selection to ignore HTTP Method

Hi,
I'm migrating CXF version used in my application from 2.2.12 to later version. I've found that one set of clients of the REST resources has been using POST requests to a resource that has @DELETE annotation and this was working in 2.2.12 but isn't when I migrate to later version.

Is there some configuration I can apply that will tell the CXF selection algorithm to ignore the HTTP Method type?

Thanks
Duncan

Re: Configure resource selection to ignore HTTP Method

Posted by Sergey Beryozkin <sb...@gmail.com>.
By the way,
On 17/10/14 17:20, Sergey Beryozkin wrote:
> Hi
> On 17/10/14 15:28, Duncan Keysell (dkeysell) wrote:
>> Hi Sergey,
>> Thanks you were correct. It is not the HTTP method that is causing the
>> issue. I looked again and I find its a mismatch on the @Produces and the
>> Accept header of the request. The resource has:
>>
>> @Produces("application/json")
>>
>> Whereas the request has header Accept:
>> text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
>>

This should match @Produces("application/json") too.
Are you saying the method annotated with @Produces("application/json") 
is not selected or is it the case that you have multiple methods 
selected due to a wild-card available in Accept ?

Cheers, Sergey

>> Using curl I changed the Accept header to Accept:
>> application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;
>>
>> q=0.8
>>
>> And it started working again.
>>
>> So I think in CXF 2.2.12 the Accept header from the request was not being
>> used in the matching algorithm and now it is.
>>
>> Is there any configuration I can apply to tell CXF to ignore matching on
>> the Accept header?
>>
> No, not really. You can adapt the Accept header from a PreMatch filter.
> CXF-specific ResourceComparator extension (needs to be registered as a
> provider) can be used to re-order the list of candidates if you have
> several matching candidates....
>
> Thanks, Sergey
>
>> Thanks
>> Duncan
>>
>> On 17/10/2014 13:53, "Sergey Beryozkin" <sb...@gmail.com> wrote:
>>
>>> Hi
>>> On 17/10/14 13:40, Duncan Keysell (dkeysell) wrote:
>>>> Hi,
>>>> I'm migrating CXF version used in my application from 2.2.12 to later
>>>> version. I've found that one set of clients of the REST resources has
>>>> been using POST requests to a resource that has @DELETE annotation and
>>>> this was working in 2.2.12 but isn't when I migrate to later version.
>>>>
>>> That must've been a pretty bad error, if a POST request was matched to
>>> DELETE methods; CXF 2.2.12 is probably JAX-RS 0.8, right ? That said it
>>> is strange it ever worked...
>>>> Is there some configuration I can apply that will tell the CXF
>>>> selection algorithm to ignore the HTTP Method type?
>>>>
>>> No, not really, you can change HTTP verb though, most portable way is to
>>> use a @PreMatch-annotated ContainerRequestFilter
>>>
>>> Cheers, Sergey
>>>> Thanks
>>>> Duncan
>>>>
>>>
>>
>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: Configure resource selection to ignore HTTP Method

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 17/10/14 15:28, Duncan Keysell (dkeysell) wrote:
> Hi Sergey,
> Thanks you were correct. It is not the HTTP method that is causing the
> issue. I looked again and I find its a mismatch on the @Produces and the
> Accept header of the request. The resource has:
>
> @Produces("application/json")
>
> Whereas the request has header Accept:
> text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
>
> Using curl I changed the Accept header to Accept:
> application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;
> q=0.8
>
> And it started working again.
>
> So I think in CXF 2.2.12 the Accept header from the request was not being
> used in the matching algorithm and now it is.
>
> Is there any configuration I can apply to tell CXF to ignore matching on
> the Accept header?
>
No, not really. You can adapt the Accept header from a PreMatch filter.
CXF-specific ResourceComparator extension (needs to be registered as a 
provider) can be used to re-order the list of candidates if you have 
several matching candidates....

Thanks, Sergey

> Thanks
> Duncan
>
> On 17/10/2014 13:53, "Sergey Beryozkin" <sb...@gmail.com> wrote:
>
>> Hi
>> On 17/10/14 13:40, Duncan Keysell (dkeysell) wrote:
>>> Hi,
>>> I'm migrating CXF version used in my application from 2.2.12 to later
>>> version. I've found that one set of clients of the REST resources has
>>> been using POST requests to a resource that has @DELETE annotation and
>>> this was working in 2.2.12 but isn't when I migrate to later version.
>>>
>> That must've been a pretty bad error, if a POST request was matched to
>> DELETE methods; CXF 2.2.12 is probably JAX-RS 0.8, right ? That said it
>> is strange it ever worked...
>>> Is there some configuration I can apply that will tell the CXF
>>> selection algorithm to ignore the HTTP Method type?
>>>
>> No, not really, you can change HTTP verb though, most portable way is to
>> use a @PreMatch-annotated ContainerRequestFilter
>>
>> Cheers, Sergey
>>> Thanks
>>> Duncan
>>>
>>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: Configure resource selection to ignore HTTP Method

Posted by "Duncan Keysell (dkeysell)" <dk...@cisco.com>.
Hi Sergey,
Thanks you were correct. It is not the HTTP method that is causing the
issue. I looked again and I find its a mismatch on the @Produces and the
Accept header of the request. The resource has:

@Produces("application/json")

Whereas the request has header Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Using curl I changed the Accept header to Accept:
application/json,text/html,application/xhtml+xml,application/xml;q=0.9,*/*;
q=0.8

And it started working again.

So I think in CXF 2.2.12 the Accept header from the request was not being
used in the matching algorithm and now it is.

Is there any configuration I can apply to tell CXF to ignore matching on
the Accept header?

Thanks
Duncan

On 17/10/2014 13:53, "Sergey Beryozkin" <sb...@gmail.com> wrote:

>Hi
>On 17/10/14 13:40, Duncan Keysell (dkeysell) wrote:
>> Hi,
>> I'm migrating CXF version used in my application from 2.2.12 to later
>>version. I've found that one set of clients of the REST resources has
>>been using POST requests to a resource that has @DELETE annotation and
>>this was working in 2.2.12 but isn't when I migrate to later version.
>>
>That must've been a pretty bad error, if a POST request was matched to
>DELETE methods; CXF 2.2.12 is probably JAX-RS 0.8, right ? That said it
>is strange it ever worked...
>> Is there some configuration I can apply that will tell the CXF
>>selection algorithm to ignore the HTTP Method type?
>>
>No, not really, you can change HTTP verb though, most portable way is to
>use a @PreMatch-annotated ContainerRequestFilter
>
>Cheers, Sergey
>> Thanks
>> Duncan
>>
>


Re: Configure resource selection to ignore HTTP Method

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 17/10/14 13:40, Duncan Keysell (dkeysell) wrote:
> Hi,
> I'm migrating CXF version used in my application from 2.2.12 to later version. I've found that one set of clients of the REST resources has been using POST requests to a resource that has @DELETE annotation and this was working in 2.2.12 but isn't when I migrate to later version.
>
That must've been a pretty bad error, if a POST request was matched to 
DELETE methods; CXF 2.2.12 is probably JAX-RS 0.8, right ? That said it 
is strange it ever worked...
> Is there some configuration I can apply that will tell the CXF selection algorithm to ignore the HTTP Method type?
>
No, not really, you can change HTTP verb though, most portable way is to 
use a @PreMatch-annotated ContainerRequestFilter

Cheers, Sergey
> Thanks
> Duncan
>