Return Template Response to Requestor Assertion

The Return Template Response to Requestor assertion lets you define a message to be returned to the requestor. This allows you (for example) to create a more descriptive message for a SOAP fault or to elaborate an error condition to aid troubleshooting. For example, you place this assertion in an "At least one assertion must evaluate to true"assertion folder after an . If the Evaluate Response XPath assertion fails, then the template response message is sent back to the requestor.
gateway90
The
Return Template Response to Requestor
assertion lets you define a message to be returned to the requestor. This allows you (for example) to create a more descriptive message for a SOAP fault or to elaborate an error condition to aid troubleshooting. For example, you place this assertion in an "At least one assertion must evaluate to true"assertion folder after an Evaluate Response XPath Assertion. If the Evaluate Response XPath assertion fails, then the template response message is sent back to the requestor.
Example:
A Return Template Response to Requestor assertion is configured as follows:
Response HTTP Status:
200
Response Content Type:
text/plain
Response Body:
Hello
This will return the following message to the client:
HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Content-Type: text/plain Content-Length: 5 Date: Mon, 17 Apr 2006 17:38:28 GMT Hello
(1) The template response is always sent at the end of the policy processing, regardless of its actual position within the policy. (2) Use of increasing number of context variables in a policy may impact the Return Template Response to Requestor assertion and may cause an overall decrease in policy performance.
Using the Assertion
  1. Do one of the following:
    • To add the assertion to the Policy Development window, see Adding an Assertion.
    • To change the configuration of an existing assertion, proceed to step 2 below.
  2. When adding the assertion, the
    Template Response Properties
    automatically appear; when modifying the assertion, right-click
    Return Template Response to Requestor
    in the policy window and select
    Template Response Properties
    or double-click the assertion in the policy window. The assertion properties are displayed.
  3.  Configure the response as follows:
    Setting
    Description
    Response HTTP Status
    Enter a valid numeric HTTP status code (for example, 200, 401).
    You may reference context variables.
    Send Response immediately
    Select this check box to send the template response message immediately, with or without a payload. The transmission of a payload depends on the status code (for example, a '204 (No Content) response status indicates to skip payload transmission).
    Clear this check box to send the template response at the completion of the policy.
    WARNING:
    Do not enable this option for most common use cases. Doing so closes the connection immediately and disables keep-alive, causing significant performance degradation. Additionally, the Gateway will apply no WS-Security decoration to the response message.
    Response Content Type
    Enter any Content-Type in the format
    "first/last".
    You can type in any compatible charset to be used for encoding. A sample response Content-Type might be: "text/xml; charset=utf-8"
     
    Response Body
    Type the message for the template response. You may include context variables within the message body, if necessary. However note the following if context variables are used:
    • When a context variable is used in the template response, the Gateway does not check whether the XML response is well formed. This may result in invalid body content.
    • If the context variable is of type Message, you may need to refer to the
      ${variableName.mainpart}
      part of the context variable to avoid problems. Using “.mainpart” turns the contents into a String.
      Set the response body to a single context variable, in the form
      ${message}
      or
      ${message.parts[x]}
      , to return the content of the specified message or part. This works for binary (not just text) messages and message parts. 
      For context variables of types other than Message, the
      mainpart
      part is not required. For more information about the data types, see "Context Variable Data Types" in Context Variables.
  4. Click [
    OK
    ] when done.