- 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>
推薦閱讀
- 信息可視化的藝術(shù):信息可視化在英國
- 看透JavaScript:原理、方法與實(shí)踐
- Quarkus實(shí)踐指南:構(gòu)建新一代的Kubernetes原生Java微服務(wù)
- SAS數(shù)據(jù)統(tǒng)計(jì)分析與編程實(shí)踐
- GameMaker Programming By Example
- 實(shí)戰(zhàn)Java高并發(fā)程序設(shè)計(jì)(第2版)
- Visual Basic程序設(shè)計(jì)(第三版)
- Laravel Application Development Blueprints
- 劍指大數(shù)據(jù):企業(yè)級(jí)電商數(shù)據(jù)倉庫項(xiàng)目實(shí)戰(zhàn)(精華版)
- Swift iOS Programming for Kids
- JSP大學(xué)實(shí)用教程
- Learning Java Lambdas
- 小小的Python編程故事
- Odoo Development Essentials
- 物聯(lián)網(wǎng)及低功耗藍(lán)牙5.x高級(jí)開發(fā)