Versions Compared

Key

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

...

  1. synapse:get-property() function
  2. base64Encode() function

synapse:get-property()
Anchor
func
func

The get-property() function allows any XPath expression used in a configuration to look up information from the current message context. Using property mediator, you can retrieve properties previously set, and/or information from the Synapse, Axis2 message contexts or transport header.

...

Synapse XPath variables

There are several variables supported by the ESB. These are used for accessing various properties and refer to fixed parts in the ESB.

  • $axis2
  • $trp
  • $ctx
  • $url

These XPath variables gets the properties at various scopes.

$axis2

Gets the property at the axis2 scope.

For example, to get the property named 'messageType' use the following XPath expression:

$axis2:messageType

$trp

Gets a transport header.

For example, to get the transport header named Content-Type use the following XPath expression:

$trp:Content-Type

HTTP transport headers are case-insensitive, so in the HTTP case,

$trp:Content-Type 

and

$trp:CONTENT-TYPE 

are equal.

$ctx

Gets a property at the default scope.

For example, to get the property named 'foo' at the default scope use the following XPath expression:

$ctx:foo

$url

Gets a URL parameter.

For example, to get the URL parameter named 'bar' use the following XPath expression:

$url:foo

 

 

 

 

 

 

There is a set of predefined XPath variables that you can directly use to write XPaths in the Synapse configuration, instead of using the synapse:get-property() function. They are These XPath variables get properties of various scopes as follows:

body

The SOAP 1.1 or 1.2 body element. For example, expression="$body/getQuote" refers to the first getQuote element in the SOAP body regardless of whether the message is SOAP-11 or SOAP-12.

...

The SOAP 1.1 or 1.2 header element. For example, expression="$header/wsa:To refers to the addressing To header regardless of whether this message is SOAP-11 or SOAP-12.

axis2

Gets the property at the axis2 scope.

For example, to get the property named 'messageType' use the following XPath expression:

$axis2:messageType

 

 

Prefix for Axis2 MessageContext properties. For example, expression="$axis2:REST_URL_POSTFIX" gives the value of the axis2 message context property with name REST_URL_POSTFIX. We have discussed an example below.

...

ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy/test/prefix 

3. You will notice Note the following message in the ESB log.

Code Block
INFO - LogMediator To: http://localhost:8280/services/StockQuoteProxy/test/prefix, WSAction: urn:getQuote, SOAPAction: urn:getQuote, ReplyTo: http://www.w3.org/2005/08/addressing/anonymous, MessageID: urn:uuid:ecd228c5-106a-4448-9c83-3b1e957e2fe5, Direction: request, stockprop = /test/prefix

...

Similarly, you can use $axis2 prefix with HTTP transport propertiesTransport Properties.

ctx

Prefix for Synapse MessageContext properties. For example, expression="$ctx:RESPONSE" gives the value of the Synapse message context property with name "RESPONSE."

...

Prefix for the transport headers. For example, expression="$trp:Content-Type" gives the value of the "Content-Type" transport header, which is going to be the Content-Type of the current message.

 

 

 

$axis2

 

$trp

Gets a transport header.

For example, to get the transport header named Content-Type use the following XPath expression:

$trp:Content-Type

HTTP transport headers are case-insensitive, so in the HTTP case,

$trp:Content-Type 

and

$trp:CONTENT-TYPE 

are equal.

$ctx

Gets a property at the default scope.

For example, to get the property named 'foo' at the default scope use the following XPath expression:

$ctx:foo

$url

Gets a URL parameter.

For example, to get the URL parameter named 'bar' use the following XPath expression:

$url:foo

 

 

 

 

 

 

 

 

 

Syntax

Code Block
<property name="string" [action=set|remove] (value="literal" | expression="xpath") [scope=transport|axis2|axis2-client]/>

...