Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

In addition to standard XPath functions, the ESB supports the following custom functions for working with XPath expressions:

...

If you provide only the property name without the scope, the default synapse scope will be used.

Info

When the result of an XPath evaluation results in a single XML node, the evaluator will return the text content of this node by default (equivalent of doing /root/body/node/text()). If you want to retrieve the node itself, we you can use configure the Enrich mediator s shown in the following manner:example.

Code Block
languagexml
<inSequence>
<log level="custom">
<property name="WHERE" value="before doing stuff"/>
</log>
<enrich>
<source type="body" clone="true"/>
<target type="property" property="ENRICH_PROPERTY"/>
</enrich>
<property name="PROPERTY_PROPERTY"
expression="$body/child::node()"
scope="default"/>
<log level="custom">
<property name="WHERE" value="before doing stuff"/>
<property name="ENRICH_PROPERTY" expression="get-property('ENRICH_PROPERTY')"/>
<property name="PROPERTY_PROPERTY" expression="get-property('PROPERTY_PROPERTY')"/>
</log>
<enrich>
<source type="property" clone="true" property="ENRICH_PROPERTY"/>
<target type="body" action="sibling"/>
</enrich>
<log level="full"/>
</inSequence>

 

Synapse scope

When the scope of a property mediator is synapse, its value is available throughout both the in sequence and the out sequence. In addition to the user-defined properties, you can retrieve the following special properties from the synapse scope.

NameReturn Value
ToIncoming URL as a String, or empty string («») if a To address is not defined.
FromFrom address as a String, or empty string («») if a From address is not defined.
ActionSOAP Addressing Action header value as a String, or empty string («») if an Action is not defined.
FaultToSOAP FaultTo header value as a String, or empty string («») if a FaultTo address is not defined.
ReplyToReplyTo header value as a String, or empty string («») if a ReplyTo address is not defined.
MessageIDA unique identifier (UUID) for the message as a String, or empty string («») if a MessageID is not defined. This ID is guaranteed to be unique.
FAULTTRUE if the message has a fault, or empty string if the message does not have a fault.
MESSAGE_FORMATReturns pox, get, soap11, or soap12 depending on the message. If a message type is unknown this returns soap12
OperationNameOperation name corresponding to the message. A proxy service with a WSDL can have different operations. If the WSDL is not defined, ESB defines fixed operations.

...

Code Block
languagejava
public boolean mediate(org.apache.synapse.MessageContext mc) {  
// Available in both in-sequence and out-sequenc  
String propValue = (String) mc.getProperty("PropName");  
System.out.println("SCOPE_SYNAPSE : " + propValue);  
return true;  
}

 

axis2 scope

When the scope of a property mediator is axis2, its value is available only throughout the sequence for which the property is defined (e.g., if you add the property to an in sequence, its value will be available only throughout the in sequence). You can retrieve message context properties within the axis2 scope using the following syntax.

Syntax:
get-property('axis2', String propertyName)

...

Code Block
languagejava
propValue = (String) axis2MsgContext.getOptions().getProperty("PropName");  
System.out.println("SCOPE_AXIS2_CLIENT - 2: " + propValue);  
return true;  
}  

transport scope

When the scope of a property mediator is transport, it will be added to the transport header of the outgoing message from the ESB. You can retrieve message context properties within the transport scope using the following syntax.

Syntax:
get-property('transport', String propertyName)


registry scope

You can retrieve properties within the registry using the following syntax.

Syntax:
get-property('registry', String registryPath@propertyName)
get-property('registry', String registryPath)


system scope

You can retrieve Java System properties using the following syntax.

Syntax:
get-property('system', String propertyName)

Note: The system scope is available in WSO2 ESB 4.8.0 and later.


operation scope

You can retrieve a property in the operation context level from the operation scope. The properties within iterated/cloned message with the operation scope are preserved in the in sequence even if you have configured your API resources to be sent through the fault sequence when faults exist. A given property with the operation scope only exists in a single request and can be accessed by a single resource. 

Syntax:
get-property('operation', String propertyName)


Next, see Synapse XPath Variables.