У меня есть клиент SOAP, созданный при весенней загрузке, и я регистрирую все сообщения SOAP, но новая версия LoggingFeature (org. apache .cxf.ext.logging.LoggingFeature) показывает полезную нагрузку на одном строка, хотя я использую prettyLogging и устаревшую версию этого класса (org. apache .cxf.feature.LoggingFeature) форматирует полезную нагрузку при использовании prettyLogging .
Когда используется устаревшая версия класса - формат, который я хочу (случайный пример):
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>
Когда используется новая версия:
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>
Мой класс конфигурации:
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;
}
}