You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Bruno Cappoen <b....@gmail.com> on 2012/11/28 18:38:35 UTC

How to intercept only incoming messages ?

Hi everybody, my application exposes about 10 web services & calls also web
services.

I want to execute a traitment when someone calls a webservice in my
application.

I have created this class but i have a problem. This is also called when my
application calls an external application, after the receipt.

Has anyone an idea to perform my request ? Maybe, i must use another type
of interceptor ? Only receipt of request and not receipt of response.

Thanks.


public class MyInterceptor extends AbstractPhaseInterceptor<SoapMessage>
{

    public AuthorizationInterceptor() {
        super(Phase.RECEIVE);
    }

    public void handleMessage(SoapMessage message) throws Fault {
        // my operation ....
    }

}

<cxf:bus>
    <cxf:inInterceptors>
        <ref bean="logInbound"/>
        <ref bean="myInterceptor" />
    </cxf:inInterceptors>
    <cxf:outInterceptors>
        <ref bean="logOutbound"/>
    </cxf:outInterceptors>
    </cxf:bus>

Re: How to intercept only incoming messages ?

Posted by Bruno Cappoen <b....@gmail.com>.
Thanks. If someone has another solution, i also take.

2012/11/28 Jason Pell <jp...@apache.org>

> Hi,
>
> You could apply the interceptor to each of your jaxws:endpoints
> individually - or even better define a feature which includes all the
> interceptors and apply that to your endpoints.  This way it would not
> also be automatically applied to all your jaxws:client's as well
> (which I assume is what is happening in your case)
>
> Or alternatively I think that you can check for the presence of
> message.get(Message.REQUESTOR_ROLE) to indicate that the interceptor
> is being called as part of a jaxws:client chain.
>
> I would prefer the former myself, but the latter is probably easier
>
> On Thu, Nov 29, 2012 at 4:38 AM, Bruno Cappoen <b....@gmail.com>
> wrote:
> > Hi everybody, my application exposes about 10 web services & calls also
> web
> > services.
> >
> > I want to execute a traitment when someone calls a webservice in my
> > application.
> >
> > I have created this class but i have a problem. This is also called when
> my
> > application calls an external application, after the receipt.
> >
> > Has anyone an idea to perform my request ? Maybe, i must use another type
> > of interceptor ? Only receipt of request and not receipt of response.
> >
> > Thanks.
> >
> >
> > public class MyInterceptor extends AbstractPhaseInterceptor<SoapMessage>
> > {
> >
> >     public AuthorizationInterceptor() {
> >         super(Phase.RECEIVE);
> >     }
> >
> >     public void handleMessage(SoapMessage message) throws Fault {
> >         // my operation ....
> >     }
> >
> > }
> >
> > <cxf:bus>
> >     <cxf:inInterceptors>
> >         <ref bean="logInbound"/>
> >         <ref bean="myInterceptor" />
> >     </cxf:inInterceptors>
> >     <cxf:outInterceptors>
> >         <ref bean="logOutbound"/>
> >     </cxf:outInterceptors>
> >     </cxf:bus>
>

Re: How to intercept only incoming messages ?

Posted by Jason Pell <jp...@apache.org>.
Hi,

You could apply the interceptor to each of your jaxws:endpoints
individually - or even better define a feature which includes all the
interceptors and apply that to your endpoints.  This way it would not
also be automatically applied to all your jaxws:client's as well
(which I assume is what is happening in your case)

Or alternatively I think that you can check for the presence of
message.get(Message.REQUESTOR_ROLE) to indicate that the interceptor
is being called as part of a jaxws:client chain.

I would prefer the former myself, but the latter is probably easier

On Thu, Nov 29, 2012 at 4:38 AM, Bruno Cappoen <b....@gmail.com> wrote:
> Hi everybody, my application exposes about 10 web services & calls also web
> services.
>
> I want to execute a traitment when someone calls a webservice in my
> application.
>
> I have created this class but i have a problem. This is also called when my
> application calls an external application, after the receipt.
>
> Has anyone an idea to perform my request ? Maybe, i must use another type
> of interceptor ? Only receipt of request and not receipt of response.
>
> Thanks.
>
>
> public class MyInterceptor extends AbstractPhaseInterceptor<SoapMessage>
> {
>
>     public AuthorizationInterceptor() {
>         super(Phase.RECEIVE);
>     }
>
>     public void handleMessage(SoapMessage message) throws Fault {
>         // my operation ....
>     }
>
> }
>
> <cxf:bus>
>     <cxf:inInterceptors>
>         <ref bean="logInbound"/>
>         <ref bean="myInterceptor" />
>     </cxf:inInterceptors>
>     <cxf:outInterceptors>
>         <ref bean="logOutbound"/>
>     </cxf:outInterceptors>
>     </cxf:bus>