Microgateway 10.7 | webMethods Microgateway Help | Policies | Request Processing | Request Transformation
 
Request Transformation
This policy enables you to configure several transformations on the request messages from clients into a format required by the native API before it is submitted to the native API.
The transformations include Header, Query Parameter, Path Parameter transformation, HTTP Method transformation, and Payload transformation. You can configure conditions according to which the transformations are executed.
Microgateway supports the following parameter types that can be used to configure the transformation policy:
*request.headers
*request.query.QUERY_NAME (applicable only for REST API)
*request.path(applicable only for REST API)
*request.path.regex[Expression] (applicable only for REST API)
*request.httpmethod (applicable only for REST API)
*request.headers.HEADER_NAME
*request.authorization.clientId
*request.authorization.claims.CLAIM_NAME
*request.authorization.userName
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. You can have multiple conditions with logical operators.
Available values are:
*AND. Microgateway transforms the requests that comply with all the configured conditions.
*OR. This is selected by default. Microgateway transforms the requests that comply with 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 - path, payload, httpMethod. For example: ${request.path}
*${PARAMTYPE.paramName} : This is applicable for map types - query and headers and also applicable for path. For example: ${request.query.var1}, ${request.header.Content-Type}, ${request.path.name}
*${PARAMTYPE.QUERYTYPE[queryValue]} : This syntax is applicable for payload and path. regex can be applied on path while XPath, JSONPath and regex can be applied on payload. For example:
${request.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
${request.payload.jsonPath[$.cardDetails.number]} where $.cardDetails.number is the jsonPath to be applied on the payload if contentType is application/json
${request.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:
${request.payload.xpath[//ns:emp/ns:empName] || request.payload.jsonPath[$.cardDetails.number]} This applies xpath for application/xml and jsonPath for application/json
${request.payload.xpath[//ns:emp/ns:empName] || request.payload.jsonPath[$.cardDetails.number] || request.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
Specifies the Header, Query or path transformation to be configured for incoming requests.
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 - path, payload, httpMethod. For example: ${request.path}
*${PARAMTYPE.paramName}. This is applicable for map types - query and headers and also applicable for path. For example: ${request.query.var1}, ${request.header.Content-Type}, ${request.path.name}
*${PARAMTYPE.QUERYTYPE[queryValue]}. This syntax is applicable for payload and path. regex can be applied on path while XPath, JSONPath and regex can be applied on payload. For example:
${request.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
${request.payload.jsonPath[$.cardDetails.number]} where $.cardDetails.number is the jsonPath to be applied on the payload if contentType is application/xml
${request.payload.regex[[0-9]+]} where [0-9]+ is the regex to be applied on the payload if contentType is anything
*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:
${request.payload.xpath[//ns:emp/ns:empName] || request.payload.jsonPath[$.cardDetails.number]} This applies xpath for application/xml and jsonPath for application/json
${request.payload.xpath[//ns:emp/ns:empName] || request.payload.jsonPath[$.cardDetails.number] || request.payload.regex[[0-9]+]} This applies xpath for application/xml, jsonPath for application/json, and regex for text/xml.
*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] || ...}
Method transformation for REST API
Specifies the method transformation to be configured for incoming requests.
You can have any of the HTTP Method listed:
*GET
*POST
*PUT
*DELETE
*HEAD
*CUSTOM
Note: 
*When CUSTOM is selected, the HTTP method in incoming request is sent to the native service. When other methods are selected, the selected method is used in the request sent to the native service.
*Only Method Transformation happens when configured, but you have to take care of adding payload during transformations involving method change like GET to POST, and so on.
Payload Transformation
Specifies the payload transformation to be configured for incoming requests.
Specifies the following information:
*An xslt document that contains the following information:
*XSLT file. Specifies the XSLT file used to transform the request 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 incoming requests. For example, the namespaces configured in this section can be used when you provide the syntax for XPath ${request.payload.xpath} For example: ${request.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.