- 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>
推薦閱讀
- MySQL數(shù)據(jù)庫管理實戰(zhàn)
- Android項目開發(fā)入門教程
- 兩周自制腳本語言
- PyTorch Artificial Intelligence Fundamentals
- 實用防銹油配方與制備200例
- OpenNI Cookbook
- 網(wǎng)頁設計與制作教程(HTML+CSS+JavaScript)(第2版)
- Apex Design Patterns
- C#程序設計(項目教學版)
- Spring 5 Design Patterns
- RubyMotion iOS Develoment Essentials
- Java Web開發(fā)實例大全(基礎卷) (軟件工程師開發(fā)大系)
- IBM Cognos TM1 Developer's Certification guide
- PhoneGap 4 Mobile Application Development Cookbook
- AI自動化測試:技術原理、平臺搭建與工程實踐