Sunday, October 13, 2013

Synapse get-property function

Get property function retrieves a property from the message context at the given scope. If the scope is not specified, property is retrieved from the default synapse scope.

get-property(String scope, String propertyName)
get-property(String propertyName)

Supported Scopes

  • default
  • axis2
  • transport
  • registry
  • system

Default scope

Message context properties resides in synapse scope can be retrieved from the default scope. Apart from user defined properties, following special properties can be retrieved from the default scope.

get-property('default', String propertyName)
get-property(String propertyName)

Special Properties supported by get-property function in Default Scope
(Extracted from

Name Return Value
To Incoming URL as a String or empty string if a To address is not defined.
From From address as a String or empty string if a From address is not defined
Action SOAP Action header value as a String or empty string if a Action is not defined
FaultTo SOAP FautTo header value as a String or empty string if a FaultTo address is not defined
ReplyTo ReplyTo header value as a String or empty string if a ReplyTo address is not defined
MessageID A unique identifier (UUID) for the message as a String . This id is guaranteed to be unique.
FAULT TRUE if the message has a fault or empty string if message doesn't have a fault
MESSAGE_FORMAT Returns pox, get, soap11, soap12 depending on the message. If a message type is unknown this returns soap12
OperationName Operation name corresponding to the message.

Axis2 scope

Message context properties resides in axis2 scope can be retrieved from the axis2 scope.
get-property('axis2', String propertyName)

Transport scope

Message context properties resides in transport scope can be retrieved from the transport scope.
get-property('transport', String propertyName)

Registry scope

Properties resides in registry can be retrieved from the registry scope.
get-property('registry', String registryPath@propertyName)
get-property('registry', String registryPath)

System scope

Java System properties can be retrieved from the system scope. Syntax:
get-property('system', String propertyName)

Note: system scope is only available in synapse 3.0 or later versions and WSO2 ESB 4.8.0 or later versions.

Saturday, October 5, 2013

Maven Archetypes for WSO2 ESB Customizable Artifacts

WSO2 ESB provides most of the features you need to build your integration scenarios.
But there can be situations where built-in functionality is not sufficient to implement your requirement.
To cope with those situations WSO2 ESB has given you the enough freedom to simply extend the functionality by implementing custom artifacts.

Following are some of the main extension points where you can extend the functionality.

1. Class Mediators
2. Custom Tasks
3. Message Builders
4. Message Formatters

I am not going to discuss much on these artifacts here. Intention of this post is to provide you an easy way of creating these artifact projects.
I have created maven-architypes for above four artifacts.

You can checkout them from here.

Example usage

Let's create a project structure for a Class mediator.

1. Go to maven-archetype-classmediator directory.
Execute the command
mvn install

This will install classmediator maven archetype to your maven repository.

2. Go to the location where you want to create a new project structure.
Execute the command
mvn archetype:generate -DarchetypeCatalog=local -DarchetypeGroupId=org.wso2.carbon  -DarchetypeArtifactId=maven-archetype-classmediator

3. You will be prompted to enter following details.

This will create the project structure for your class mediator.
Now you can edit the Mediator java class and write your logic in the mediate() method.

4. After writing the code, you can simply execute the command
mvn clean install
to compile and create the jar file of the class mediator.