The following example modifies an existing response object by adding a header to it:
<AssignMessage name="modify-response"> <Set> <Headers> <Header name="Cache-Hit">{lookupcache.LookupCache-1.cachehit}</Header> </Headers> </Set> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> <AssignTo createNew="false" type="response"></AssignTo> </AssignMessage>
This example does not create a new message. Instead, it modifies an existing response message by adding an HTTP header.
Because this example omits a variable name in the <AssignTo>
element, and specifies
type
as "response", this policy modifies the response object returned by the target
server.
The HTTP header added to the response message by this policy is derived from a variable populated by the LookupCache policy. Therefore the response message modified by this Assign Message policy contains an HTTP header that indicates whether the results have been pulled from the cache or not. Setting headers in the response can be handy for debugging and troubleshooting.