You are viewing an older version of this section. Click here to navigate to the latest version.

Manipulating Requests Using Scripting

You can write Java code to interact with Mule. This example introduces using scripting in Mule. Scripting is a powerful way to manipulate requests and create custom logic. The benefit of scripting is that you can use different languages in Mule namely, Groovy, Ruby (using JRuby), Python (using Jython) and server-side Rhino (open-source implementation of JavaScript). The example in this document uses Groovy to transform an incoming message.

What You Learn

  • Using the Script Transformer and configuring it from Mule Studio

  • Embedding script code in your configuration file, removing the need to create an external code file


Ideally, you should be working through these tutorials in sequence and have completed the Invoking a Component Method lesson.

Running the Example

  • Create a scripting transformer configured to use Groovy as the language

  • Embed a script in your Mule configuration file to perform a transformation on the incoming request

  • The resulting behavior was the same as Working with Transformers except you don’t need to create a separate Java class to perform the transformation.