Set Message

Overview

The Set Message filter replaces the body of the message. The replacement data can be plain text, HTML, XML, or any other text-based markup.

You can use selectors representing the values of message attributes in the replacement text to insert message-specific data into the message body. For example, you can insert the authenticated user's ID into a <Username> element by using a ${authentication.subject.id} selector as follows:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
 <soap:Header>
  <Username>${authentication.subject.id}</Username>
 </soap:Header>
 <soap:Body>
  <getQuote xmlns="oracle.com">
   <ticker>ORM.L</ticker>
  </getQuote>
 </soap:Body>
</soap:Envelope>   

Assuming the oracle user authenticated successfully to the API Gateway, the message body is set as follows:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
 <soap:Header>
  <Username>oracle</Username>
 </soap:Header>
 <soap:Body>
  <getQuote xmlns="oracle.com">
   <ticker>ORM.L</ticker>
  </getQuote>
 </soap:Body>
</soap:Envelope>   

For more details on selectors, see Selecting Configuration Values at Runtime.

You can also use the Set Message filter to customize SOAP faults that are returned to clients in the case of a failure or exception in the policy. For a detailed explanation of how to use this filter to customize SOAP faults, see the SOAP Fault topic.

Configuration

Perform the following steps to configure the Set Message filter:

  1. Enter a name for this filter in the Name field.

  2. Specify the content type of the new message body in the Content-type field. For example, if the new message body is HTML markup, enter text/html in the Content-Type field.

  3. Enter the new message body in the Message Body text area. You can use selectors, as shown in the example above, to ensure that current message attribute values are inserted into the message body at the appropriate places. You can also load the message contents from a file by browsing to the location of the file using the Browse button.