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

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>
主站蜘蛛池模板: 尚志市| 兴和县| 揭西县| 灵山县| 施甸县| 尼木县| 丹寨县| 黔西县| 什邡市| 临湘市| 延吉市| 玉田县| 吉隆县| 鱼台县| 当涂县| 平定县| 盐津县| 南开区| 遂溪县| 甘肃省| 临沂市| 紫阳县| 襄城县| 广水市| 元谋县| 若羌县| 突泉县| 木兰县| 吉林省| 石河子市| 山东省| 麻江县| 鹤庆县| 简阳市| 龙里县| 眉山市| 武鸣县| 阳信县| 抚松县| 西乡县| 普兰县|