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

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>
主站蜘蛛池模板: 阆中市| 屏山县| 涞源县| 都昌县| 商河县| 商丘市| 楚雄市| 大足县| 牟定县| 上虞市| 平罗县| 罗定市| 甘泉县| 凌云县| 上蔡县| 新河县| 海南省| 黑河市| 麻栗坡县| 张家界市| 依兰县| 凤冈县| 宝鸡市| 铜山县| 措美县| 木兰县| 通山县| 黄龙县| 房产| 福清市| 马尔康县| 崇文区| 通州区| 津南区| 承德县| 旌德县| 宣恩县| 崇礼县| 肥东县| 安徽省| 拜泉县|