Skip to content

Commit

Permalink
Fix wsa message id issue
Browse files Browse the repository at this point in the history
Fix issue of messageID of the responserecognizing as the wsa:RelatesTo instead of the actual MessageIDual MessageID
  • Loading branch information
IsuruMaduranga committed May 17, 2024
1 parent 98a8a8f commit b1168ae
Showing 1 changed file with 24 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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
*
Expand Down

0 comments on commit b1168ae

Please sign in to comment.