Response transformation
This policy specifies the properties required to transform response messages from native APIs into a format required by the client.
The Response transformation transformations include Header transformation, Status transformation, Payload transformation, and Advanced transformation. You can configure conditions according to which the transformations are executed.
In IBM API Studio, this policy
is identified by the kind TransformResponse.
Example of a Response processing policy in code view:
kind: TransformResponse
apiVersion: api.ibm.com/v2
metadata:
name: response-processing
version: 1.0
namespace: wm_project
tags:
- iden
spec:
condition: (${response.headers.test} equals test1) or (${response.headers.test}
notEquals ${response.payload.jsonPath[$.customer.name]})
transformations:
set:
- key: ${response.headers.h2}
value: test-header-value
- key: ${response.query.q2}
value: ${response.path.name}
setStatus: # Introduced for Response Processing
code: 400
message: Invalid request
setPayload:
content-types:
- application/json: |
{
"empid":"1"
}
- application/xml: |
<test></test>
- text/plain: |
"This is a plain content"
defaultContentType: application/xml
xsl:
- feature:
- name: http://javax.xml.XMLConstants/feature/secure-processing
value: true
$path: format.xsl
remove:
- ${response.query.q1}
- ${response.path.mki}
namespaces:
- prefix: ps1
URI: http://test.com
- prefix: ps2
URI: http://test2.com
webMethodsISService:
- $ref: wm_project:webMethodsISService:1.0 # refer
For the TransformResponse policy kind, configure these specifications:
| Code view | Form view | Description |
|---|---|---|
condition |
Conditions |
Conditions are used to specify when the policy is run. You can add multiple conditions with logical operators. Provide the condition in the format: {set} operator {value} condition {set} operator {value} You can configure the following conditions:
You can use the following operators to add conditions.
|
transformations |
Transformation configuration |
Specifies the response processing parameters. You can configure the following under
|
namespaces |
Namespace |
Configure the metadata for the message configuration request in form view under the Transformation metadata tab. In the code view, under In the form view under Transformation metadata tab, click the Add namespace button to specify the optional Namespace prefix and Namespace URL. |