2

I have a SOAP client created in spring boot and I'm logging all SOAP messages, but the new version of LoggingFeature (org.apache.cxf.ext.logging.LoggingFeature) shows payload on one line even though I'm using prettyLogging and deprecated version of this class (org.apache.cxf.feature.LoggingFeature) formats payload when used prettyLogging.

When used deprecated version of class - format I want (random example):

    Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Envelope xmlns="URL" xmlns:ns2="URL">
      <Service ID="SERVICE"/>
      <Inquirer ID="ID" CorrelationID="ID" Version="1.0" Timestamp="Timestamp"/>
      <Data Content="xml">
        <ns2:Request>
          <ns2:FILE>ID</ns2:FILE>
          <ns2:ACTION>ACTION</ns2:ACTION>
        </ns2:Request>
      </Data>
      <File>
        <FileDescription ID="ID"/>
      </File>
    </Envelope>
  </soap:Body>
</soap:Envelope>

When used new version:

Payload: <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><Envelope xmlns="URL" xmlns:ns2="URL"><Service ID="SERVICE"/><Inquirer ID="ID" CorrelationID="ID" Version="1.0" Timestamp="Timestamp"/><Data Content="xml"><ns2:Request><ns2:FILE>ID</ns2:FILE>     <ns2:ACTION>ACTION</ns2:ACTION></ns2:Request></Data><File><FileDescription ID="ID"/></File></Envelope></soap:Body></soap:Envelope>

My configuration class:

import javax.annotation.PostConstruct;
import org.apache.cxf.ext.logging.AbstractLoggingInterceptor;
import org.apache.cxf.ext.logging.LoggingFeature;
import org.apache.cxf.ext.logging.LoggingInInterceptor;
import org.apache.cxf.ext.logging.LoggingOutInterceptor;
import org.apache.cxf.bus.spring.SpringBus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CxfConfig {

    @Autowired
    private SpringBus springBus;

    @PostConstruct
    public void activateLoggingFeature() {
           springBus.getInInterceptors().add(logInInterceptor());
           springBus.getInFaultInterceptors().add(logInInterceptor());
           springBus.getOutInterceptors().add(logOutInterceptor());
           springBus.getOutFaultInterceptors().add(logOutInterceptor());
    }

    @Bean
    public LoggingFeature loggingFeature() {
           LoggingFeature logFeature = new LoggingFeature();
           logFeature.setPrettyLogging(true);
           logFeature.initialize(springBus);
           springBus.getFeatures().add(logFeature);
           return logFeature;
    }

    public AbstractLoggingInterceptor logInInterceptor() {
        LoggingInInterceptor logInInterceptor = new LoggingInInterceptor();
        logInInterceptor.setLimit(-1);
        logInInterceptor.setPrettyLogging(true);
        logInInterceptor.setLogBinary(true);
        logInInterceptor.setLogMultipart(true);
        return logInInterceptor;
    }

    public AbstractLoggingInterceptor logOutInterceptor() {
        LoggingOutInterceptor logOutInterceptor = new LoggingOutInterceptor();
        logOutInterceptor.setPrettyLogging(true);
        logOutInterceptor.setLimit(-1);
        logOutInterceptor.setLogBinary(true);
        logOutInterceptor.setLogMultipart(true);
        return logOutInterceptor;
    }

}
fenste
  • 21
  • 3

0 Answers0