官术网_书友最值得收藏!

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>
主站蜘蛛池模板: 思茅市| 宜阳县| 宜城市| 句容市| 二连浩特市| 黄陵县| 天门市| 卓尼县| 乐清市| 综艺| 永安市| 大竹县| 温宿县| 苏州市| 宜章县| 白玉县| 达日县| 德兴市| 江陵县| 县级市| 小金县| 噶尔县| 保亭| 昌平区| 伊宁市| 天峻县| 南澳县| 乌鲁木齐市| 中阳县| 阿拉善右旗| 房山区| 安塞县| 巨野县| 永春县| 托克逊县| 城步| 镶黄旗| 保山市| 武义县| 蓝田县| 岳阳县|