From f94d1d103a9dbab18da9001a2d4591f05a7869b3 Mon Sep 17 00:00:00 2001 From: Tony Germano Date: Fri, 23 Oct 2026 10:11:10 -0400 Subject: [PATCH] Explain why LoggingSOAPHandler calls getMessage() LoggingSOAPHandler.handleMessage() calls smc.getMessage() and ignores the result, so the call looks safe to remove. It isn't. In the JAX-WS RI, getMessage() converts the message to an in-memory SAAJ copy, and once the handler chain finishes, that copy replaces the original message. Two behaviors depend on this. Converting to SAAJ parses the entire request. Without the call, JAX-WS reads only as far as it needs to bind the parameters, so a request with malformed XML after the payload element is processed and answered with 200 instead of being rejected with a fault. Comparing the call present and removed on JDK 17: - unclosed element after the payload: 500 / 200 - mismatched tags after the payload: 500 / 200 - markup after : 500 / 200 - truncated right after the payload: 500 / 500 - valid request: 200 / 200 Responses are serialized from the SAAJ copy. Without the call, every response would lose the empty SOAP-ENV:Header, the extra xmlns:SOAP-ENV declaration and the xmlns="" on the return element. The XML means the same thing, but clients that compare raw text would see a difference. The channel receives the same payload from a valid request either way, and mustUnderstand faults and faults raised by the service are unchanged, because handleFault() doesn't call getMessage(). Removing the call would save building a DOM for each request and response. But keeping the current strictness would need another full parse, which gives most of that saving back. Found while looking into #509. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Tony Germano --- .../com/mirth/connect/connectors/ws/LoggingSOAPHandler.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/src/main/java/com/mirth/connect/connectors/ws/LoggingSOAPHandler.java b/server/src/main/java/com/mirth/connect/connectors/ws/LoggingSOAPHandler.java index 2a0ce3f23e..d93ec6013a 100644 --- a/server/src/main/java/com/mirth/connect/connectors/ws/LoggingSOAPHandler.java +++ b/server/src/main/java/com/mirth/connect/connectors/ws/LoggingSOAPHandler.java @@ -60,6 +60,8 @@ public boolean handleMessage(SOAPMessageContext smc) { } else { logger.debug("Web Service returning response."); } + // The result is unused, but don't remove this: it parses the whole message, so + // requests with malformed XML after the payload are rejected instead of processed. smc.getMessage(); } catch (Exception e) { logger.error("Error handling SOAP message", e);