Skip to content

Commit

Permalink
[feature] adding service call endpoint n log handler.
Browse files Browse the repository at this point in the history
  • Loading branch information
ebrahimiar committed Dec 1, 2024
1 parent 16d6741 commit 9e95dbf
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
public class LogHandler implements SOAPHandler<SOAPMessageContext> {
private static final Logger logger = LoggerFactory.getLogger(LogHandler.class);
private static final ObjectMapper mapper = new ObjectMapper();
public static final String ENDPOINT_KEY = "jakarta.xml.ws.service.endpoint.address";
private Set<String> securedParameterNames;
ThreadLocal<Long> startTimeMillis = new ThreadLocal<>();

Expand All @@ -34,6 +35,7 @@ public class LogHandler implements SOAPHandler<SOAPMessageContext> {
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}

public LogHandler() {
}

Expand All @@ -49,10 +51,11 @@ public boolean handleMessage(SOAPMessageContext messageContext) {
try {
msg.writeTo(logStream);
if (request) {
logParams.put("soap-request", getBody(logStream));
logParams.put("endPoint", messageContext.get(ENDPOINT_KEY).toString());
logParams.put("soapRequest", getBody(logStream));
startTimeMillis.set(System.currentTimeMillis());
} else {
logParams.put("soap-response", getBody(logStream));
logParams.put("soapResponse", getBody(logStream));
logParams.put("duration", getDurationLogMessage());
}
logger.info(mapper.writeValueAsString(logParams));
Expand Down

0 comments on commit 9e95dbf

Please sign in to comment.