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.
Perform the following steps to configure the Set Message filter:
-
Enter a name for this filter in the Name field.
-
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. -
Enter the new message body in the Message Body text area.
You can use selectors to ensure that current message attribute values are inserted into the message body at the appropriate places. For more information, see the section called “Example of using selectors in the message body”.
Alternatively, click Populate on the right of the window, and select From file on disk to load the message contents from a file, or select From web service operation to load the message contents from a web service (WSDL file) that you have already imported into the web service repository.
You can also insert REST API parameters into the message body. Right-click within the message body at the point where the parameter should be inserted and select Insert > REST API Parameter.
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 user authenticated successfully to the API Gateway Explorer, 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 Select configuration values at runtime.