You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Morgan Rachell <mr...@potomacfusion.com> on 2009/03/30 19:02:19 UTC

Interceptors

I have two questions about interceptors:

 

1)      What is the difference between when an inFaultInterceptor and an
outFaultInterceptor get called? For example, if I receive a message on a
jaxws:endpoint, a business object does some processing as a result, then
that throws some exception based on business rules (e.g. data integrity
issue, user not authorized, etc. ) how does CXF know which
faultInterceptor to call?

2)      Is there a "catch-all" interceptor that acts like a "finally"
block? I want to execute some code after every message completes
processing, regardless of whether a fault occurred or not. Right now it
looks like I need to include my interceptor in the outInterceptor and
outFaultInterceptor chains like this:

 

      <jaxws:endpoint id="myEndpoint" implementor="#endpointService"
address="/soap/endpoint">

            <jaxws:features>

                  <bean class="org.apache.cxf.feature.LoggingFeature"/>

            </jaxws:features>

            <jaxws:inInterceptors>

                     <ref bean="myInInterceptor"/>

            </jaxws:inInterceptors>

            <jaxws:outInterceptors>

                  <ref bean="myCatchAllInterceptor" /> 

            </jaxws:outInterceptors>

            <jaxws:outFaultInterceptors>

                  <ref bean=" myCatchAllInterceptor" /> 

            </jaxws:outFaultInterceptors>

      </jaxws:endpoint>

 

Thanks,
Morgan

 


RE: Interceptors

Posted by Morgan Rachell <mr...@potomacfusion.com>.
Thanks Dan. That helps. 

-----Original Message-----
From: Daniel Kulp [mailto:dkulp@apache.org] 
Sent: Monday, March 30, 2009 3:12 PM
To: users@cxf.apache.org
Cc: Morgan Rachell
Subject: Re: Interceptors

On Mon March 30 2009 1:02:19 pm Morgan Rachell wrote:
> I have two questions about interceptors:
>
>
>
> 1)      What is the difference between when an inFaultInterceptor and
an
> outFaultInterceptor get called? For example, if I receive a message on
a
> jaxws:endpoint, a business object does some processing as a result,
then
> that throws some exception based on business rules (e.g. data
integrity
> issue, user not authorized, etc. ) how does CXF know which
> faultInterceptor to call?

The inFaults are the interceptors on the client side for fault handling
(when 
the fault comes "in" from the server).    The outFaults are for the
outgoing 
faults on the server side.  


> 2)      Is there a "catch-all" interceptor that acts like a "finally"
> block? 

No.   You would need to put it on both the chains.  (and on both the
"in" 
chains on the client side).

Dan


> I want to execute some code after every message completes
> processing, regardless of whether a fault occurred or not. Right now
it
> looks like I need to include my interceptor in the outInterceptor and
> outFaultInterceptor chains like this:
>
>
>
>       <jaxws:endpoint id="myEndpoint" implementor="#endpointService"
> address="/soap/endpoint">
>
>             <jaxws:features>
>
>                   <bean
class="org.apache.cxf.feature.LoggingFeature"/>
>
>             </jaxws:features>
>
>             <jaxws:inInterceptors>
>
>                      <ref bean="myInInterceptor"/>
>
>             </jaxws:inInterceptors>
>
>             <jaxws:outInterceptors>
>
>                   <ref bean="myCatchAllInterceptor" />
>
>             </jaxws:outInterceptors>
>
>             <jaxws:outFaultInterceptors>
>
>                   <ref bean=" myCatchAllInterceptor" />
>
>             </jaxws:outFaultInterceptors>
>
>       </jaxws:endpoint>
>
>
>
> Thanks,
> Morgan

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog

Re: Interceptors

Posted by Daniel Kulp <dk...@apache.org>.
On Mon March 30 2009 1:02:19 pm Morgan Rachell wrote:
> I have two questions about interceptors:
>
>
>
> 1)      What is the difference between when an inFaultInterceptor and an
> outFaultInterceptor get called? For example, if I receive a message on a
> jaxws:endpoint, a business object does some processing as a result, then
> that throws some exception based on business rules (e.g. data integrity
> issue, user not authorized, etc. ) how does CXF know which
> faultInterceptor to call?

The inFaults are the interceptors on the client side for fault handling (when 
the fault comes "in" from the server).    The outFaults are for the outgoing 
faults on the server side.  


> 2)      Is there a "catch-all" interceptor that acts like a "finally"
> block? 

No.   You would need to put it on both the chains.  (and on both the "in" 
chains on the client side).

Dan


> I want to execute some code after every message completes
> processing, regardless of whether a fault occurred or not. Right now it
> looks like I need to include my interceptor in the outInterceptor and
> outFaultInterceptor chains like this:
>
>
>
>       <jaxws:endpoint id="myEndpoint" implementor="#endpointService"
> address="/soap/endpoint">
>
>             <jaxws:features>
>
>                   <bean class="org.apache.cxf.feature.LoggingFeature"/>
>
>             </jaxws:features>
>
>             <jaxws:inInterceptors>
>
>                      <ref bean="myInInterceptor"/>
>
>             </jaxws:inInterceptors>
>
>             <jaxws:outInterceptors>
>
>                   <ref bean="myCatchAllInterceptor" />
>
>             </jaxws:outInterceptors>
>
>             <jaxws:outFaultInterceptors>
>
>                   <ref bean=" myCatchAllInterceptor" />
>
>             </jaxws:outFaultInterceptors>
>
>       </jaxws:endpoint>
>
>
>
> Thanks,
> Morgan

-- 
Daniel Kulp
dkulp@apache.org
http://www.dankulp.com/blog