REST CustomOutInterceptor.java actually working?

View: New views
5 Messages — Rating Filter:   Alert me  

REST CustomOutInterceptor.java actually working?

by Andreas Sahlbach :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi!

I am trying to add an Interceptor to my REST service to add a custom header field. I found in v.2.2.3 a systest called apache-cxf-2.2.3/systests/src/test/java/org/apache/cxf/systest/jaxrs/CustomOutInterceptor.java.

I don't think that this systest is actually working, is it? My code is never called. I don't think that an interceptor with Phase.MARSHAL is ever called for a REST service.

Is this a planned feature or should it actually be working right now?

Thanks for a short answer,

Andreas

Re: REST CustomOutInterceptor.java actually working?

by Sergey Beryozkin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

this interceptor is registered as an out interceptor in

http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java

and a number of tests in

http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

verify that a BookId header is available in the response

How are you registering it ? By the way, another option is to register a custom ResponseHandler and override a Response with a new
header being added

cheers, Sergey

>
> Hi!
>
> I am trying to add an Interceptor to my REST service to add a custom header
> field. I found in v.2.2.3 a systest called
> apache-cxf-2.2.3/systests/src/test/java/org/apache/cxf/systest/jaxrs/CustomOutInterceptor.java.
>
> I don't think that this systest is actually working, is it? My code is never
> called. I don't think that an interceptor with Phase.MARSHAL is ever called
> for a REST service.
>
> Is this a planned feature or should it actually be working right now?
>
> Thanks for a short answer,
>
> Andreas
> --
> View this message in context: http://old.nabble.com/REST-CustomOutInterceptor.java-actually-working--tp26216585p26216585.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


Re: REST CustomOutInterceptor.java actually working?

by Andreas Sahlbach :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ok, forget it. Sometimes it's good to stop working and take a rest for a while. I injected the Interceptor into the wrong place (inInterceptors). Couldn't work this way I guess

Andreas Sahlbach wrote:
Hi!

I am trying to add an Interceptor to my REST service to add a custom header field. I found in v.2.2.3 a systest called apache-cxf-2.2.3/systests/src/test/java/org/apache/cxf/systest/jaxrs/CustomOutInterceptor.java.

I don't think that this systest is actually working, is it? My code is never called. I don't think that an interceptor with Phase.MARSHAL is ever called for a REST service.

Is this a planned feature or should it actually be working right now?

Thanks for a short answer,

Andreas

Re: REST CustomOutInterceptor.java actually working?

by Andreas Sahlbach :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks for the answer Sergey. I already found out my mistake. Just added my new interceptor to an existing interceptor and didn't noticed that it is an "inInterceptor" and not just "interceptor". And because of the Phase parameter it never came to my mind that there is a second list of interceptors.

I will check again tomorrow at work but I am sure it will work as expected. :-)

Thanks for the help!

Sergey Beryozkin-2 wrote:
Hi

this interceptor is registered as an out interceptor in

http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java

and a number of tests in

http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java

verify that a BookId header is available in the response

How are you registering it ? By the way, another option is to register a custom ResponseHandler and override a Response with a new
header being added

cheers, Sergey

>
> Hi!
>
> I am trying to add an Interceptor to my REST service to add a custom header
> field. I found in v.2.2.3 a systest called
> apache-cxf-2.2.3/systests/src/test/java/org/apache/cxf/systest/jaxrs/CustomOutInterceptor.java.
>
> I don't think that this systest is actually working, is it? My code is never
> called. I don't think that an interceptor with Phase.MARSHAL is ever called
> for a REST service.
>
> Is this a planned feature or should it actually be working right now?
>
> Thanks for a short answer,
>
> Andreas
> --
> View this message in context: http://old.nabble.com/REST-CustomOutInterceptor.java-actually-working--tp26216585p26216585.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>

Re: REST CustomOutInterceptor.java actually working?

by Sergey Beryozkin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,


>
> Thanks for the answer Sergey. I already found out my mistake. Just added my
> new interceptor to an existing interceptor and didn't noticed that it is an
> "inInterceptor" and not just "interceptor". And because of the Phase
> parameter it never came to my mind that there is a second list of
> interceptors.

I should've documented some examples showing how custom in/out or in/out fault CXF interceptors can be registered.

>
> I will check again tomorrow at work but I am sure it will work as expected.
> :-)

Hopefully it will :-)

>
> Thanks for the help!

you're welcome,

Sergey

>
>
> Sergey Beryozkin-2 wrote:
>>
>> Hi
>>
>> this interceptor is registered as an out interceptor in
>>
>> http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookServer.java
>>
>> and a number of tests in
>>
>> http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSClientServerBookTest.java
>>
>> verify that a BookId header is available in the response
>>
>> How are you registering it ? By the way, another option is to register a
>> custom ResponseHandler and override a Response with a new
>> header being added
>>
>> cheers, Sergey
>>
>>>
>>> Hi!
>>>
>>> I am trying to add an Interceptor to my REST service to add a custom
>>> header
>>> field. I found in v.2.2.3 a systest called
>>> apache-cxf-2.2.3/systests/src/test/java/org/apache/cxf/systest/jaxrs/CustomOutInterceptor.java.
>>>
>>> I don't think that this systest is actually working, is it? My code is
>>> never
>>> called. I don't think that an interceptor with Phase.MARSHAL is ever
>>> called
>>> for a REST service.
>>>
>>> Is this a planned feature or should it actually be working right now?
>>>
>>> Thanks for a short answer,
>>>
>>> Andreas
>>> --
>>> View this message in context:
>>> http://old.nabble.com/REST-CustomOutInterceptor.java-actually-working--tp26216585p26216585.html
>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>>
>>
>>
>>
>
> --
> View this message in context: http://old.nabble.com/REST-CustomOutInterceptor.java-actually-working--tp26216585p26220874.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>