- WSO2 Developer’s Guide
- Fidel Prieto Estrada Ramón Garrido Lázaro
- 176字
- 2021-07-08 10:06:01
The script mediator
We can use different scripting languages to process the payload and get some information or make a transformation, such as JavaScript, Groovy, and Ruby.
Inline script syntax is as follows:
<script language="js"> <![CDATA[ //script code ]]> <script/>
This is the registry script syntax:
<script key="path/to/script" language="(js | groovy | rb)" [function="nameOfTheFunction"]> [<include key="string"/>] </script>
The following is a list of the available methods:
- getPayloadXML(): Returns the current XML payload.
- setPayloadXML(payload): Set the body with the content of the payload parameter.
- addHeader(mustUnderstand, content): Add a new SOAP header.
- getEnvelopeXML(): Return the full payload.
- setTo(reference): Set the value of the To header (receiver).
- setFaultTo(reference): Set the value to the FaultTo header.
- setFrom(reference): Set the value to the From header (sender).
- setReplyTo(reference): Set the value to the ReplyTo header.
- getPayloadJSON(): Return the current JSON payload.
- setPayloadJSON(payload): Set the body with the content of the payload parameter.
- getProperty(name): Get the value of a property.
- setProperty(key, value): Create or update the content of the property from the first param with the value of the second param.
For example, this is the script to print the current value of a property and set the new value:
<script language="js"> <![CDATA[ var property = mc.getProperty("static"); print("property: " + property); mc.setProperty("static", "newValue"); ]]> </script>
推薦閱讀
- C# 7 and .NET Core Cookbook
- Learning RxJava
- C語言程序設計案例式教程
- Python數據分析(第2版)
- PhoneGap Mobile Application Development Cookbook
- Building a Quadcopter with Arduino
- 青少年Python編程入門
- Selenium Testing Tools Cookbook(Second Edition)
- 3ds Max印象 電視欄目包裝動畫與特效制作
- PyQt編程快速上手
- Building Slack Bots
- XML程序設計(第二版)
- 讓Python遇上Office:從編程入門到自動化辦公實踐
- Spring Microservices
- 軟件工程實用教程 (第3版)