diff --git a/modules/core/src/main/java/org/apache/synapse/config/xml/CallMediatorFactory.java b/modules/core/src/main/java/org/apache/synapse/config/xml/CallMediatorFactory.java index 6b444e750d..a01b2f94eb 100644 --- a/modules/core/src/main/java/org/apache/synapse/config/xml/CallMediatorFactory.java +++ b/modules/core/src/main/java/org/apache/synapse/config/xml/CallMediatorFactory.java @@ -237,8 +237,15 @@ private void populateTarget(CallMediator callMediator, Target target, OMElement } } else if (target.getTargetType() == EnrichMediator.BODY) { callMediator.setTargetAvailable(false); + } else if (target.getTargetType() == EnrichMediator.VARIABLE) { + // check if variable is surrounded by curly braces + if (StringUtils.isNotEmpty(sourceEle.getText())) { + callMediator.setTargetAvailable(true); + target.setVariable(new ValueFactory().createTextValue(sourceEle)); + } else { + handleException("Variable name is required for VARIABLE type"); + } } - } public QName getTagQName() { diff --git a/modules/core/src/main/java/org/apache/synapse/config/xml/CallMediatorSerializer.java b/modules/core/src/main/java/org/apache/synapse/config/xml/CallMediatorSerializer.java index b7fc869f8c..7cf0ac0887 100644 --- a/modules/core/src/main/java/org/apache/synapse/config/xml/CallMediatorSerializer.java +++ b/modules/core/src/main/java/org/apache/synapse/config/xml/CallMediatorSerializer.java @@ -108,6 +108,8 @@ private OMElement serializeTarget(Target target) { targetEle.addAttribute(fac.createOMAttribute("type", nullNS, intTypeToString(target.getTargetType()))); if (target.getTargetType() == EnrichMediator.PROPERTY) { targetEle.setText(target.getProperty()); + } else if (target.getTargetType() == EnrichMediator.VARIABLE) { + targetEle.setText(target.getVariable().getKeyValue()); } return targetEle; diff --git a/modules/core/src/main/java/org/apache/synapse/config/xml/ValueFactory.java b/modules/core/src/main/java/org/apache/synapse/config/xml/ValueFactory.java index 6466c8da4b..e7fa91352c 100644 --- a/modules/core/src/main/java/org/apache/synapse/config/xml/ValueFactory.java +++ b/modules/core/src/main/java/org/apache/synapse/config/xml/ValueFactory.java @@ -111,6 +111,10 @@ public Value createTextValue(OMElement elem) { textValue = textValue.substring(1, textValue.length() - 1); SynapseJsonPath synJsonPath = createSynJsonPath(textValue); key = new Value(synJsonPath); + } else if (textValue.startsWith("{${") && textValue.endsWith("}}")) { + textValue = textValue.substring(1, textValue.length() - 1); + SynapseExpression synapseExpression = createSynapseExpression(textValue); + key = new Value(synapseExpression); } else { SynapseXPath synXpath = createSynXpath(elem, textValue); key = new Value(synXpath); diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/builtin/CallMediator.java b/modules/core/src/main/java/org/apache/synapse/mediators/builtin/CallMediator.java index a68e4f89b8..20be8fd817 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/builtin/CallMediator.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/builtin/CallMediator.java @@ -44,6 +44,7 @@ import org.apache.synapse.endpoints.EndpointDefinition; import org.apache.synapse.endpoints.IndirectEndpoint; import org.apache.synapse.mediators.AbstractMediator; +import org.apache.synapse.mediators.elementary.EnrichMediator; import org.apache.synapse.mediators.elementary.Source; import org.apache.synapse.mediators.elementary.Target; import org.apache.synapse.message.senders.blocking.BlockingMsgSender; @@ -167,8 +168,11 @@ public boolean mediate(MessageContext synInCtx) { sourceForInboundPayload.setClone(true); CallMediatorEnrichUtil .doEnrich(synInCtx, sourceForInboundPayload, targetForOriginalPayload, originalMessageType); - CallMediatorEnrichUtil - .doEnrich(synInCtx, sourceForOutboundPayload, targetForOutboundPayload, getSourceMessageType()); + if (!(EnrichMediator.BODY == sourceForOutboundPayload.getSourceType() && + EnrichMediator.BODY == targetForOutboundPayload.getTargetType())) { + CallMediatorEnrichUtil + .doEnrich(synInCtx, sourceForOutboundPayload, targetForOutboundPayload, getSourceMessageType()); + } if (!sourceMessageType.equalsIgnoreCase(originalMessageType)) { CallMediatorEnrichUtil.setContentType(synInCtx, sourceMessageType, sourceMessageType); if (originalMessageType.equalsIgnoreCase(JSON_TYPE)) { diff --git a/modules/core/src/main/java/org/apache/synapse/mediators/eip/EIPUtils.java b/modules/core/src/main/java/org/apache/synapse/mediators/eip/EIPUtils.java index 09b76b80d5..f8b6b6f9f5 100644 --- a/modules/core/src/main/java/org/apache/synapse/mediators/eip/EIPUtils.java +++ b/modules/core/src/main/java/org/apache/synapse/mediators/eip/EIPUtils.java @@ -434,4 +434,8 @@ public Set