You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by DanielTempleUK <da...@googlemail.com> on 2013/11/06 18:25:35 UTC

Configuring Interceptors in Multiple Spring Config Files

Hello,

We're having some problems adding all of the custom CXF interceptors to our
webservice.

We have the following interceptors:
 - MdcClearInterceptor
 - MdcSetupInterceptor
 - OutboundRequestHeaderInterceptor

In one Spring Configuration file we have the
OutboundRequestHeaderInterceptor defined as a bean and have it configured in
a bus like this:

	<bean id="headerInterceptor" class="OutboundRequestHeaderInterceptor" />
	
	<cxf:bus>
		<cxf:outInterceptors>
			<ref bean="headerInterceptor" />
		</cxf:outInterceptors>
	</cxf:bus>


In a SEPARATE SPRING CONFIGURATION FILE we have the other 2 Interceptors
configured in the bus as follows:

	<bean id="mdcSetup"
class="com.williamhill.cxf.interceptor.MdcSetupInterceptor" />
	<bean id="mdcClear"
class="com.williamhill.cxf.interceptor.MdcClearInterceptor" />

	<cxf:bus>
		<cxf:inInterceptors>
			<ref bean="mdcSetup" />
		</cxf:inInterceptors>
		<cxf:outInterceptors>
			<ref bean="mdcClear" />
		</cxf:outInterceptors>
		<cxf:outFaultInterceptors>
			<ref bean="mdcClear" />
		</cxf:outFaultInterceptors>
	</cxf:bus>


The problem we're having is that we only end up with the
OutboundRequestHeaderInterceptor actually added to the bus when our web
service starts up.
Turning the CXF logging up to DEBUG confirms that only the
OutboundRequestHeaderInterceptor is added to the CXF interceptors.

The reason we have separate config files is that it keeps the config
separate for different aspects of the web service. It unfortunately supports
a lot of different functions.
We have moved the configuration into a single Spring configuration file and
it works fine. All of the interceptors are added as expected and are all
called where they should be.

Any help would be much appreciated.

Thanks,
Dan



--
View this message in context: http://cxf.547215.n5.nabble.com/Configuring-Interceptors-in-Multiple-Spring-Config-Files-tp5736041.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Configuring Interceptors in Multiple Spring Config Files

Posted by DanielTempleUK <da...@googlemail.com>.
The above configuration does work.

Thanks Sergey for the advice to make the Interceptor service specific.



--
View this message in context: http://cxf.547215.n5.nabble.com/Configuring-Interceptors-in-Multiple-Spring-Config-Files-tp5736041p5736068.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Configuring Interceptors in Multiple Spring Config Files

Posted by Sergey Beryozkin <sb...@gmail.com>.
Yes exactly, this should work

Cheers. Sergey
On 07/11/13 09:21, DanielTempleUK wrote:
> Hi Sergey,
>
> That sounds potentially doable, but I'm not sure of how I'd go about it.
>
> Our web service isn't defined within configuration, but we do define a
> client to make calls out to another service (which is where the
> headerInterceptor needs to execute) which we define as follows:
> (The roundRobinAddresses is just a bean within the config file, I don't
> think it should cause us problems)
>
> 	<jaxws:client id="bonusServiceClient" serviceClass="BonusServicePortType"
> address="...">
> 		<jaxws:features>
> 			<clustering:failover>
> 				<clustering:strategy>		
> 					<ref bean="roundRobinAddresses" />
> 				</clustering:strategy>
> 			</clustering:failover>
> 		</jaxws:features>
> 	</jaxws:client>
>
> Should I be able to add some outInterceptors into this client definition and
> it all just work fine? So something like the following:
>
> 	<jaxws:client id="bonusServiceClient" serviceClass="BonusServicePortType"
> address="...">
> 		<jaxws:features>
> 			<clustering:failover>
> 				<clustering:strategy>		
> 					<ref bean="roundRobinAddresses" />
> 				</clustering:strategy>
> 			</clustering:failover>
> 		</jaxws:features>
> 		<jaxws:outInterceptors>
> 			<ref bean="headerInterceptor" />
> 		</jaxws:outInterceptors>
> 	</jaxws:client>
>
> I'm trying this out now, but our test mechanism is a bit slow on the turn
> around.
>
> Cheers,
> Dan
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Configuring-Interceptors-in-Multiple-Spring-Config-Files-tp5736041p5736066.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


Re: Configuring Interceptors in Multiple Spring Config Files

Posted by DanielTempleUK <da...@googlemail.com>.
Hi Sergey,

That sounds potentially doable, but I'm not sure of how I'd go about it.

Our web service isn't defined within configuration, but we do define a
client to make calls out to another service (which is where the
headerInterceptor needs to execute) which we define as follows:
(The roundRobinAddresses is just a bean within the config file, I don't
think it should cause us problems)

	<jaxws:client id="bonusServiceClient" serviceClass="BonusServicePortType"
address="...">
		<jaxws:features>
			<clustering:failover>  
				<clustering:strategy>		
					<ref bean="roundRobinAddresses" />
				</clustering:strategy>
			</clustering:failover>
		</jaxws:features>
	</jaxws:client>

Should I be able to add some outInterceptors into this client definition and
it all just work fine? So something like the following:

	<jaxws:client id="bonusServiceClient" serviceClass="BonusServicePortType"
address="...">
		<jaxws:features>
			<clustering:failover>  
				<clustering:strategy>		
					<ref bean="roundRobinAddresses" />
				</clustering:strategy>
			</clustering:failover>
		</jaxws:features>
		<jaxws:outInterceptors>
			<ref bean="headerInterceptor" />
		</jaxws:outInterceptors>
	</jaxws:client>

I'm trying this out now, but our test mechanism is a bit slow on the turn
around.

Cheers,
Dan



--
View this message in context: http://cxf.547215.n5.nabble.com/Configuring-Interceptors-in-Multiple-Spring-Config-Files-tp5736041p5736066.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Configuring Interceptors in Multiple Spring Config Files

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi, you should probably add 'headerInterceptor' to individual endpoints 
which need it, which won't block the shared bus interceptors also added 
to those endpoints

Cheers, Sergey
On 06/11/13 17:25, DanielTempleUK wrote:
> Hello,
>
> We're having some problems adding all of the custom CXF interceptors to our
> webservice.
>
> We have the following interceptors:
>   - MdcClearInterceptor
>   - MdcSetupInterceptor
>   - OutboundRequestHeaderInterceptor
>
> In one Spring Configuration file we have the
> OutboundRequestHeaderInterceptor defined as a bean and have it configured in
> a bus like this:
>
> 	<bean id="headerInterceptor" class="OutboundRequestHeaderInterceptor" />
> 	
> 	<cxf:bus>
> 		<cxf:outInterceptors>
> 			<ref bean="headerInterceptor" />
> 		</cxf:outInterceptors>
> 	</cxf:bus>
>
>
> In a SEPARATE SPRING CONFIGURATION FILE we have the other 2 Interceptors
> configured in the bus as follows:
>
> 	<bean id="mdcSetup"
> class="com.williamhill.cxf.interceptor.MdcSetupInterceptor" />
> 	<bean id="mdcClear"
> class="com.williamhill.cxf.interceptor.MdcClearInterceptor" />
>
> 	<cxf:bus>
> 		<cxf:inInterceptors>
> 			<ref bean="mdcSetup" />
> 		</cxf:inInterceptors>
> 		<cxf:outInterceptors>
> 			<ref bean="mdcClear" />
> 		</cxf:outInterceptors>
> 		<cxf:outFaultInterceptors>
> 			<ref bean="mdcClear" />
> 		</cxf:outFaultInterceptors>
> 	</cxf:bus>
>
>
> The problem we're having is that we only end up with the
> OutboundRequestHeaderInterceptor actually added to the bus when our web
> service starts up.
> Turning the CXF logging up to DEBUG confirms that only the
> OutboundRequestHeaderInterceptor is added to the CXF interceptors.
>
> The reason we have separate config files is that it keeps the config
> separate for different aspects of the web service. It unfortunately supports
> a lot of different functions.
> We have moved the configuration into a single Spring configuration file and
> it works fine. All of the interceptors are added as expected and are all
> called where they should be.
>
> Any help would be much appreciated.
>
> Thanks,
> Dan
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/Configuring-Interceptors-in-Multiple-Spring-Config-Files-tp5736041.html
> Sent from the cxf-user mailing list archive at Nabble.com.
>


-- 
Sergey Beryozkin

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

Blog: http://sberyozkin.blogspot.com