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

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>
主站蜘蛛池模板: 新郑市| 高阳县| 山东省| 易门县| 津市市| 静安区| 额敏县| 德保县| 永仁县| 遵化市| 泌阳县| 清新县| 阿图什市| 金溪县| 习水县| 台东县| 阿尔山市| 南阳市| 咸阳市| 任丘市| 乌拉特中旗| 靖江市| 边坝县| 永顺县| 祥云县| 县级市| 丰台区| 邹平县| 凌海市| 本溪市| 丰镇市| 呼和浩特市| 江山市| 安达市| 柳河县| 定兴县| 紫金县| 五大连池市| 林芝县| 平顶山市| 湘西|