Microgateway 10.7 | webMethods Microgateway Help | Policies | Response Processing | Response Transformation
 
Response Transformation
This policy specifies the properties required to transform response messages from native APIs into a format required by the client.
This policy enables you to configure several transformations on the response messages before it is sent to the client.
Microgateway supports the following parameter types that can be used to configure the transformation policy:
*response.payload
*response.headers
*response.statusCode
*response.statusMessage
Microgateway supports the following Query types that can be used to configure the transformation policy:
*xpath
*jsonPath
*regex
When you use these syntaxes to extract a value from the payload, the content-types applicable are:
*${payload.jsonPath} - application/json, application/json/badgerfish
*${payload.regex} - text/plain
*${payload.xpath} - application/xml, text/xml, text/html.
The table lists the properties that are supported for this policy in Microgateway:
Parameter
Description
Condition
Conditions are used to specify when the policy has to be executed. We can add multiple conditions with logical operators.
Available values are:
*AND. Microgateway transforms the responses that comply with all the configured conditions
*OR. This is selected by default. Microgateway transforms the responses that comply at least one configured condition.
Various conditions you can define are:
*Variable. Specifies the variable type with a syntax as follows:
*${PARAMTYPE} : This is applicable for variables of string type - payload, statusCode and statusMessage. For example: ${response.payload}
*${PARAMTYPE.paramName} : This is applicable for map types - headers. For example: , ${response.header.Content-Type},
*${PARAMTYPE.QUERYTYPE[queryValue]} : This syntax is applicable for payload. XPath, JSONPath and regex can be applied on payload. For example:
${response.payload.xpath[//ns:emp/ns:empName]} where //ns:emp/ns:empName is the xpath to be applied on the payload if contentType is application/xml
${response.payload.jsonPath[$.cardDetails.number]} where $.cardDetails.number is the jsonPath to be applied on the payload if contentType is application/json
${response.payload.regex[[0-9]+]} where [0-9]+ is the regex to be applied on the payload if contentType is text/plain
*If you want Microgateway to apply xpath, jsonPath, regex based on Content-Type of the payload, use the following common syntax: ${PARAMTYPE.QUERYTYPE[queryValue] || PARAMTYPE.QUERYTYPE2[queryValue2] || ...}
For example:
${response.payload.xpath[//ns:emp/ns:empName] || response.payload.jsonPath[$.cardDetails.number]} This applies xpath for application/xml and jsonPath for application/json
${response.payload.xpath[//ns:emp/ns:empName] || response.payload.jsonPath[$.cardDetails.number] || response.payload.regex[[0-9]+]} This applies xpath for application/xml, jsonPath for application/json, and regex for text/plain.
*Operator. Specifies the operator to use to relate variable and the value provided. You can select one of the following:
*Equals
*Equals ignore case
*Not equals
*Contains
*Exists
*Value. Specifies a value with a syntax as follows:
*PLAIN VALUE, for example, application/json
*${PARAMTYPE.paramName}
*${PARAMTYPE.QUERYTYPE[queryValue]}
*${PARAMTYPE.QUERYTYPE[queryValue] || PARAMTYPE.QUERYTYPE2[queryValue2] || ...}
Transformation Configuration. Specifies various transformations to be configured.
Header/Query/Path Transformation for REST API
Specifies the Header, Query or path transformation to be configured for the responses received from the native API.
Various configurations you can define are:
*Variable. Specifies the variable type with a syntax as follows:
*${PARAMTYPE} : This is applicable for variables of string type - payload, statusCode and statusMessage. For example: ${response.payload}
*${PARAMTYPE.paramName} : This is applicable for map types - headers. For example: , ${response.header.Content-Type},
*${PARAMTYPE.QUERYTYPE[queryValue]} : This syntax is applicable for payload. XPath, JSONPath and regex can be applied on payload. For example:
${response.payload.xpath[//ns:emp/ns:empName]} where //ns:emp/ns:empName is the xpath to be applied on the payload if contentType is application/xml
${response.payload.jsonPath[$.cardDetails.number]} where $.cardDetails.number is the jsonPath to be applied on the payload if contentType is application/json
${response.payload.regex[[0-9]+]} where [0-9]+ is the regex to be applied on the payload if contentType is text/plain
*If you want Microgateway to apply xpath, jsonPath, regex based on Content-Type of the payload, use the following common syntax: ${PARAMTYPE.QUERYTYPE[queryValue] || PARAMTYPE.QUERYTYPE2[queryValue2] || ...}
For example:
${response.payload.xpath[//ns:emp/ns:empName] || response.payload.jsonPath[$.cardDetails.number]} This applies xpath for application/xml and jsonPath for application/json
${response.payload.xpath[//ns:emp/ns:empName] || response.payload.jsonPath[$.cardDetails.number] || response.payload.regex[[0-9]+]} This applies xpath for application/xml, jsonPath for application/json, and regex for text/plain.
*Value. Specifies a value with a syntax as follows:
*PLAIN VALUE, for example, application/json
*${PARAMTYPE.paramName}
*${PARAMTYPE.QUERYTYPE[queryValue]}
*${PARAMTYPE.QUERYTYPE[queryValue] || PARAMTYPE.QUERYTYPE2[queryValue2] || ...}
Status transformation
Specifies the status transformation to be configured for the responses received from the native API.
*Code. Specifies the status code that is sent in the response to the client.
*Message. Specifies the Status message that is sent in the response to the client.
Payload Transformation
Specifies the payload transformation to be configured for the responses received from the native API.
Specifies the following information:
*An xslt document that contains the following information:
*XSLT file. Specifies the XSLT file used to transform the response messages as required.
*Feature Name. Specifies the name of the XSLT feature.
*Feature value. Specifies the value of the XSLT feature.
You can have multiple XSLT features and xslt documents.
Transformation Metadata. Specifies the metadata for transformation of the responses received from the native API. For example, the namespaces configured in this section can be used when you provide the syntax for XPath ${response.payload.xpath} For example: ${response.payload.xpath[//ns:emp/ns:empName]}
Namespace
Specifies the namespace information to be configured for transformation.
Provide the following information:
*Namespace Prefix. The namespace prefix of the payload expression to be validated.
*Namespace URI. The namespace URI of the payload expression to be validated.
Note:
You can have multiple namespace prefix and URI.