aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pom.xml5
-rw-r--r--src/main/java/at/gv/egiz/moazs/client/ClientFactory.java15
-rw-r--r--src/main/java/at/gv/egiz/moazs/service/MsgService.java1
-rw-r--r--src/main/java/at/gv/egiz/moazs/service/MzsService.java1
-rw-r--r--src/test/resources/config/application.yaml16
5 files changed, 35 insertions, 3 deletions
diff --git a/pom.xml b/pom.xml
index a8191bf..5c0f324 100644
--- a/pom.xml
+++ b/pom.xml
@@ -103,6 +103,11 @@
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.cxf</groupId>
+ <artifactId>cxf-rt-features-logging</artifactId>
+ <version>${cxf.version}</version>
+ </dependency>
<!-- redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/src/main/java/at/gv/egiz/moazs/client/ClientFactory.java b/src/main/java/at/gv/egiz/moazs/client/ClientFactory.java
index 818c4c9..f173467 100644
--- a/src/main/java/at/gv/egiz/moazs/client/ClientFactory.java
+++ b/src/main/java/at/gv/egiz/moazs/client/ClientFactory.java
@@ -9,7 +9,10 @@ import at.gv.zustellung.app2mzs.xsd.KeyStoreType;
import at.gv.zustellung.app2mzs.xsd.SSLType;
import org.apache.cxf.configuration.jsse.TLSClientParameters;
import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.ext.logging.LoggingInInterceptor;
+import org.apache.cxf.ext.logging.LoggingOutInterceptor;
import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.interceptor.Interceptor;
import org.apache.cxf.jaxws.JaxWsClientFactoryBean;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.apache.cxf.message.Message;
@@ -37,6 +40,10 @@ public class ClientFactory {
private final FileUtils fileUtils;
private final ConfigUtil configUtil;
+ private static final Interceptor<Message> LOGGING_IN_INTERCEPTOR = new LoggingInInterceptor();
+ private static final Interceptor<Message> LOGGING_OUT_INTERCEPTOR = new LoggingOutInterceptor();
+
+
@Autowired
public ClientFactory(StoreSOAPBodyBinaryInRepositoryInterceptor storeResponseInterceptor,
SSLContextCreator creator,
@@ -62,6 +69,7 @@ public class ClientFactory {
factory.setServiceClass(clazz);
factory.setAddress(params.getURL());
factory.getInInterceptors().add(storeResponseInterceptor);
+ setupLoggingInterceptors(factory);
var proxy = new JaxWsProxyFactoryBean(factory).create();
Client client = ClientProxy.getClient(proxy);
@@ -88,6 +96,13 @@ public class ClientFactory {
return ((T)proxy);
}
+ private void setupLoggingInterceptors(JaxWsClientFactoryBean factory) {
+ factory.getInInterceptors().add(LOGGING_IN_INTERCEPTOR);
+ factory.getInFaultInterceptors().add(LOGGING_IN_INTERCEPTOR);
+ factory.getOutInterceptors().add(LOGGING_OUT_INTERCEPTOR);
+ factory.getOutFaultInterceptors().add(LOGGING_OUT_INTERCEPTOR);
+ }
+
private TLSClientParameters setupTLSParams(SSLType ssl) {
var tlsParams = new TLSClientParameters();
diff --git a/src/main/java/at/gv/egiz/moazs/service/MsgService.java b/src/main/java/at/gv/egiz/moazs/service/MsgService.java
index 9f94cb3..1144d17 100644
--- a/src/main/java/at/gv/egiz/moazs/service/MsgService.java
+++ b/src/main/java/at/gv/egiz/moazs/service/MsgService.java
@@ -18,6 +18,7 @@ import static java.util.concurrent.CompletableFuture.runAsync;
@Service
@SchemaValidation(type = SchemaValidation.SchemaValidationType.BOTH)
+@org.apache.cxf.feature.Features (features = "org.apache.cxf.ext.logging.LoggingFeature")
public class MsgService implements Zuse2AppPort {
private final DeliveryRepository repository;
diff --git a/src/main/java/at/gv/egiz/moazs/service/MzsService.java b/src/main/java/at/gv/egiz/moazs/service/MzsService.java
index 8b5d697..a0e6248 100644
--- a/src/main/java/at/gv/egiz/moazs/service/MzsService.java
+++ b/src/main/java/at/gv/egiz/moazs/service/MzsService.java
@@ -27,6 +27,7 @@ import static java.util.concurrent.CompletableFuture.supplyAsync;
@Service
@SchemaValidation(type = SchemaValidation.SchemaValidationType.BOTH)
+@org.apache.cxf.feature.Features (features = "org.apache.cxf.ext.logging.LoggingFeature")
public class MzsService implements App2MzsPortType {
private static final Logger log = LoggerFactory.getLogger(MzsService.class);
diff --git a/src/test/resources/config/application.yaml b/src/test/resources/config/application.yaml
index 110d9d8..bd864a2 100644
--- a/src/test/resources/config/application.yaml
+++ b/src/test/resources/config/application.yaml
@@ -13,8 +13,18 @@ logging:
SignatureVerifier: DEBUG
LogResponseSink: INFO
- at.gv.egiz.moazs.backend.SaveResponseToFileSink: TRACE
- at.gv.egiz.moazs.SaveResponseToFileSinkTest: TRACE
+ # Incoming and outgoing messages are logged to INFO.
+ # Log all Incoming / Outgoing Messages.
+ #org.apache.cxf.services : INFO
+
+ # Fine tune logging of messages per service / client:
+ # Format: <service namespace>.<ServiceName>.<type>
+ # Examples:
+ #org.apache.cxf.services.app2mzsPortType.REQ_IN : INFO
+ #org.apache.cxf.services.app2mzsPortType.RESP_OUT : INFO
+ #org.apache.cxf.services.App2ZusePort.REQ_OUT : INFO
+ #org.apache.cxf.services.App2ZusePort.RESP_IN: INFO
+ # More information: https://codenotfound.com/apache-cxf-logging-soap-request-response-fault-messages-example.html
# Mandatory
# Default type for java's ssl key/trust store. When in doubt, set to
@@ -105,7 +115,7 @@ delivery-request-configuration-profiles:
path: /msg-responses/
# Mandatory
- # Log response to the at.gv.egiz.moazs.backend.LogResponseSink Logger.
+ # Log response to the at.gv.egiz.moazs.backend.LogResponseSink Logger, level INFO
log-response: true
# Mandatory