## Apache Synapse

## Script Setup Guide

Apache Synapse ships with a set of scripting samples. This document explains how to setup the necessary script engines for these samples. In addition this guide describes how to setup the JSON message builder and formatter for JSON mediation samples.

## Contents

- Introduction
- JavaScripts Support
- Ruby Support
- Python Support
- JSON Support on Synapse 3.0.0
- JSON Support Prior to Synapse 3.0.0

## Configuring Synapse for Script Mediator Support

The Synapse Script Mediator is a Synapse extension, and thus all prerequisites are not bundled by default with the Synapse distribution.Before you use some script mediators you may need to manually add the required jar files to the Synapse lib directory, and optionally perform other installation tasks as may be required by the individual scripting language. This is explained in the following sections.

### JavaScript Support

The JavaScript/E4X support is enabled by default and comes ready-to-use with the Synapse distribution.

### Ruby Support

For Ruby support you need to download the 'jruby-complete.jar' from the Maven repository for JRuby, and copy it into the 'lib' folder of Synapse . The JRuby JAR can be downloaded from here

### Python Support

For Python support you need to download the 'jython.jar' from the Maven repository for Jython, and copy it into the 'lib' folder of Synapse . The Jython JAR can be downloaded from here

### JSON Support on Synapse 3.0.0

JSON is a lightweight data-interchange format. It can be used as an alternative to XML or SOAP. From Synapse 3.0.0 onward, there are no additional steps required to enable JSON.

### JSON Support Prior to Synapse 3.0.0

To enable JSON support on Synpase versions prior to 3.0.0, the following two jar files should be deployed into the 'lib' directory of Synapse.

- axis2-json.jar
- jettison.jar

Jettison 1.1 is recommended.

Having deployed the necessary libraries you should now register the JSON message builder and formatter with Synapse. Open up 'repository/conf/axis2.xml' file of Synapse and add the following two entries under the 'messageBuilders' and 'messageFormatters' sections respectively.

<messageBuilder contentType="application/json" class="org.apache.axis2.json.JSONOMBuilder"/> <messageFormatter contentType="application/json" class="org.apache.axis2.json.JSONMessageFormatter"/>

If you are planning to run sample 158, you should also add the above two entries to the 'samples/axis2Client/client_repo/conf/axis2.xml' file.