Spring CXF

Enabling Logging of in/out messages

 1@Bean
 2public AbstractLoggingInterceptor logOutInterceptor() {
 3    LoggingOutInterceptor logOutInterceptor = new LoggingOutInterceptor();
 4    logOutInterceptor.setPrettyLogging(true);
 5    return logOutInterceptor;
 6}
 7
 8@Bean
 9public AbstractLoggingInterceptor logInInterceptor() {
10    LoggingInInterceptor logOutInterceptor = new LoggingInInterceptor();
11    logOutInterceptor.setPrettyLogging(true);
12    return logOutInterceptor;
13}
14
15@Bean(name = Bus.DEFAULT_BUS_ID)
16public SpringBus springBus() {
17    SpringBus springBus = new SpringBus();
18    springBus.getInFaultInterceptors().add(logOutInterceptor());
19    springBus.getInInterceptors().add(logInInterceptor());
20    springBus.getOutInterceptors().add(logOutInterceptor());
21    springBus.getOutFaultInterceptors().add(logOutInterceptor());
22    return springBus;
23}

Maven plugin

 1<plugin>
 2    <groupId>org.apache.cxf</groupId>
 3    <artifactId>cxf-codegen-plugin</artifactId>
 4    <version>3.3.7</version>
 5    <executions>
 6        <execution>
 7            <id>generate-sources</id>
 8            <phase>generate-sources</phase>
 9            <configuration>
10                <sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
11                <wsdlOptions>
12                    <wsdlOption>
13                        <wsdl>${basedir}/src/main/resources/myService.wsdl</wsdl>
14                        <wsdlLocation>classpath:myService.wsdl</wsdlLocation>
15                    </wsdlOption>
16                </wsdlOptions>
17            </configuration>
18            <goals>
19                <goal>wsdl2java</goal>
20            </goals>
21        </execution>
22    </executions>
23</plugin>

Maven dependencies

Minimal tested set.

 1 <dependency>
 2    <groupId>org.apache.cxf</groupId>
 3    <artifactId>cxf-rt-frontend-jaxws</artifactId>
 4    <version>3.3.7</version>
 5</dependency>
 6
 7<dependency>
 8    <groupId>org.apache.cxf</groupId>
 9    <artifactId>cxf-rt-transports-http</artifactId>
10    <version>3.3.7</version>
11</dependency>
12<dependency>
13    <groupId>org.springframework.boot</groupId>
14    <artifactId>spring-boot-starter-web-services</artifactId>
15</dependency>
comments powered by Disqus