...
The following examples show the what the Spring configuration would look like if you wanted to enable the logging of inbound and outbound messages and faults.
Enabling message logging using plain Spring bean elements:
Code Block | ||||
---|---|---|---|---|
| ||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/> <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/> <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl"> <property name="inInterceptors"> <list> <ref bean="logInbound"/> </list> </property> <property name="outInterceptors"> <list> <ref bean="logOutbound"/> </list> </property> <property name="outFaultInterceptors"> <list> <ref bean="logOutbound"/> </list> </property> </bean> </beans> |
In this example, you specify that the CXF bus is implemented by class org.apache.cxf.bus.CXFBusImpl, and that it's id is "cxf". This is the default, but you have to re-iterate the fact if you want the bus to contribute the logging interceptors to the outbound and inbound interceptor chain for all client and server endpoints. You can avoid this duplication by using the next form of configuration.
Enabling message logging using custom CXF bean elements:
Code Block | ||||
---|---|---|---|---|
| ||||
beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation=" http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <bean id="logInbound" class="org.apache.cxf.interceptor.LoggingInInterceptor"/> <bean id="logOutbound" class="org.apache.cxf.interceptor.LoggingOutInterceptor"/> <cxf:bus> <cxf:inInterceptors> <ref bean="logInbound"/> </cxf:inInterceptors> <cxf:outInterceptors> <ref bean="logOutbound"/> </cxf:outInterceptors> <cxf:inFaultInterceptors> <ref bean="logOutbound"/> </cxf:inFaultInterceptors> </cxf:bus> </beans> |
There is no need to specify the implementation class of the bus - nor the fact that the inInterceptors, outInterceptors and inFautlInterceptors child elements are of type list - all of this is embedded in the bean definition parser that's invoked for a cxf:bus element and the underlying schema. Note that you to specify the location of this schema so that Spring can validate the configuration file. But it gets even simpler in the next example.
Enabling message logging using the Logging feature:
Code Block | ||||
---|---|---|---|---|
| ||||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation=" http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> <cxf:bus> <cxf:features> <cxf:logging/> </cxf:features> </cxf:bus> </beans> |
The following sections explain how which of the above mechanisms you can use to enable and/or configure the various components in CXF, and what your configuration options are:
- Bus
- JAX-WS Configuration
- HTTP Client and Server
- JMS Transport
- Soap Binding
- XML Binding
- WS-Addressing
- WS-Reliability
- WS-Policy Framework
...