From b1168aed9b9fc1eac17a1173e5aedafdf5e653fb Mon Sep 17 00:00:00 2001 From: Isuru Wijesiri Date: Fri, 17 May 2024 18:32:15 +0530 Subject: [PATCH] Fix wsa message id issue Fix issue of messageID of the responserecognizing as the wsa:RelatesTo instead of the actual MessageIDual MessageID --- .../core/axis2/SynapseCallbackReceiver.java | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java b/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java index 77f234583a..69fbb3d212 100644 --- a/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java +++ b/modules/core/src/main/java/org/apache/synapse/core/axis2/SynapseCallbackReceiver.java @@ -67,6 +67,7 @@ import org.apache.synapse.util.ResponseAcceptEncodingProcessor; import java.util.Iterator; +import java.util.Objects; import java.util.Stack; import java.util.Timer; @@ -160,16 +161,9 @@ public void receive(MessageContext messageCtx) throws AxisFault { return; } - - if (messageCtx.getOptions() != null && messageCtx.getOptions().getRelatesTo() != null) { - // never take a chance with a NPE at this stage.. so check at each level :-) - Options options = messageCtx.getOptions(); - if (options != null) { - RelatesTo relatesTo = options.getRelatesTo(); - if (relatesTo != null) { - messageID = relatesTo.getValue(); - } - } + String relatesTo = extractRelatesToFromResponse(messageCtx); + if (relatesTo != null && !isRelatesToUnspecified(relatesTo)) { + messageID = relatesTo; } else if (messageCtx.getProperty(SynapseConstants.SANDESHA2_SEQUENCE_KEY) == null) { messageID = (String) messageCtx.getProperty(SynapseConstants.RELATES_TO_FOR_POX); } @@ -229,6 +223,26 @@ public void receive(MessageContext messageCtx) throws AxisFault { } } + private String extractRelatesToFromResponse(MessageContext messageCtx) { + if (messageCtx.getOptions() != null && messageCtx.getOptions().getRelatesTo() != null) { + // never take a chance with a NPE at this stage.. so check at each level :-) + Options options = messageCtx.getOptions(); + if (options != null) { + RelatesTo relatesTo = options.getRelatesTo(); + if (relatesTo != null) { + return relatesTo.getValue(); + } + } + } + return null; + } + + private boolean isRelatesToUnspecified(String relatesTo) { + + return relatesTo.equals("http://schemas.xmlsoap.org/ws/2004/08/addressing/id/unspecified") + || relatesTo.equals("http://www.w3.org/2005/08/addressing/unspecified"); + } + /** * Handle the response or error (during a failed send) message received for an outgoing request *