Messaging
Use the Messaging policy to trigger a messaging extension based on the specified conditions to enable request and response transformations.
Code view | Form view | Description |
---|---|---|
enabled |
N.A. |
Specifies whether the policy is active. Set the value to |
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 in the Conditions section:
You can use the following operators in the code view and in the form view by using the Add condition button, which is optional.
|
messageConfig |
Messaging |
Configures the messaging system details such as connection, destination, and message format.
Define these message configurations:
|
request_processing |
Request processing |
Specifies the request processing parameters. You can configure the following
|
response_processing |
Response processing |
Specifies the response processing parameters.
|
namespaces |
Namespace |
Configure the metadata for the message configuration request. In the code view, under In the form view, use the Custom metadata extension tab to configure the metadata. Click the Add namespace button for this configuration and specify the Namespace prefix and Namespace URL, which are both optional fields. |
Example of a Messaging policy in code view.
kind: InvokeMessagingExtension
apiVersion: api.webmethods.io/beta
metadata:
name: messaging-extension
version: 1
namespace: sample
tags:
- invoke
- messaging
- extension
- policy
spec:
enabled: true
condition: (${request.httpMethod} equals POST) or (${request.headers.name} notEquals ${request.payload.jsonPath[$.customer.name]})
# other operators include Equals, Equals ignore case, Not equals, Not equals ignore case, Contains, Not Contains, Exists, Not Exists, IP Range, Greater Than, Lesser Than
messageConfig:
$ref: sample:MessageConfig:1.0
request_processing:
transformations:
set:
- key: ${request.headers.h2}
value: test4
- key: ${request.query.q2}
value: ${request.payload.jsonPath[$.customer.name]}
setPayload:
content-types:
- application/json: |
{"empid" : "1"}
- application/xml: |
<a>a<a>
- text/plain: |
sample text
default-ContentType: application/json
xsl:
- feature:
- name: test
value: value
$path: ./a/a.xsl
content: sdsd
remove:
response_processing:
transformations:
set:
- key: ${request.headers.h2}
value: test4
- key: ${request.query.q2}
value: ${request.payload.jsonPath[$.customer.name]}
copyEntireResponse: true
abortAPIExecutionForFailure: true
namespaces:
- prefix: ps1
URI: http://test.com
- prefix: ps2
URI: http://test2.com