Format an IBM z/OS Connect rule set
A z/OS Connect rule set must be written in a specific format.
A rule set consists of one or more rules. Each rule contains one or more conditions and one or more actions. If the conditions are met, z/OS Connect completes the related actions.
zosConnect-3.0 Applies to zosConnect-3.0.
z/OS Connect rule specifications
A rule consists of a name attribute and the following sub elements:- conditions
- Only one
conditionselement is allowed in each rule. Theconditionselement has one or moreheaderelements with the attribute's name and value. Multipleheaderelements have a Boolean AND relationship, so all header conditions must be met for the actions to be performed. If more than one value is defined, then any one of those values can match. - actions
- An action or list of actions to be performed if the condition is met. The
setaction can be used to change the value of a property.
- Leading and trailing white space for each comma-separated value is ignored.
- If match="ANY_VALUE" is specified, the header condition is satisfied when an HTTP header with the correct name is included in the API request, regardless of the HTTP header value.
- z/OS Connect does not validate the rules. If the header name, property, or value is not entered correctly, results are unpredictable.
Example 1
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ruleset>
<rule name="groupOne">
<conditions>
<header name="group" value="A,B,C"/>
</conditions>
<actions>
<set property="imsConnectionRef" value="groupOneConnection"/>
<set property="imsTranExpiration" value="true"/>
</actions>
</rule>
<rule name="groupTwo">
<conditions>
<header name="group" value="X,Y,Z"/>
</conditions>
<actions>
<set property="imsConnectionRef" value="groupTwoConnection"/>
<set property="imsTranExpiration" value="false"/>
</actions>
</rule>
<rule name="setTrancode">
<conditions>
<header name="trancode" value="update"/>
</conditions>
<actions>
<set property="imsTranCode" value="IVTNO"/>
</actions>
</rule>
</ruleset>
group is B and trancode is
update, then z/OS Connect completes the
following actions:<rule name="groupOne">. The condition is met and the value ofimsConnectionRefis changed to groupOneConnection and the value ofimsTranExpirationis changed totrue.-
<rule name="groupTwo">. The condition is not met, so the actions are ignored. <rule name="setTrancode">. The condition is met, so theimsTranCodeproperty is changed to IVTNO.
Variables
You can use variable substitution to target a specific transaction according to the header value in the request.
Example 2
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ruleset name="variableSubstitution">
<rule name="connectionInteraction">
<conditions>
<header name="connectionType" value="A,B,C"/>
</conditions>
<actions>
<set property="imsConnectionRef" value="${connectionType}Connection"/>
</actions>
</rule>
</ruleset>
This rule set has only one rule, but performs as if there are many rules. For example, if a
request is received where the header property connectionType contains the value
A, then the imsConnectionRef property is changed to
AConnection.
Variable substitution can be placed at any location in the value string, provided it is in the correct format. The substitution can also be used with no hardcoded value.
Example 3
Example 3 illustrates the use of multiple headers.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ruleset>
<rule name="groupOne">
<conditions>
<header name="groupA" value="A"/>
<header name="groupB" value="B"/>
</conditions>
<actions>
<set property="imsConnectionRef" value="groupOneConnection"/>
<set property="imsTranCode" value="GRPONE"/>
</actions>
</rule>
<rule name="groupTwo">
<conditions>
<header name="groupA" value="A"/>
</conditions>
<actions>
<set property="imsConnectionRef" value="groupTwoConnection"/>
<set property="imsTranCode" value="GRPTWO"/>
</actions>
</rule>
</ruleset>
When multiple headers are defined in the same conditions element, they have a
Boolean AND relationship so that all conditions must be met for the actions to be performed. In this
example, the rule groupOne has multiple conditions. The header
groupA must match the value A and the header
groupB must match the value B. If either condition is not met,
then no actions occur.
In this example, the header that is named groupA appears in both rules, but
the rule groupOne has two headers, so it is considered to be more specific than the
rule groupTwo and is checked first.
If both conditions are met, then rule groupTwo is not checked. It is good
practice to write your ruleset so that the most specific rules appear first. This format is easier
to understand when diagnosing problems.
Example 4
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ruleset>
<rule name="groupOne">
<conditions>
<header name="groupA" value="A"/>
</conditions>
<actions>
<set property="cicsConnectionRef" value="cicsOneconnection" />
<set property="imsTranCode" value="IVTNO"/>
</actions>
</rule>
</ruleset>Each service checks the actions that are applicable to it and ignores the others. In this
example, the CICS® service acts on the
cicsConnectionRef property and the IMS service acts on the imsTranCode property.
Example 5
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ruleset>
<rule name="cicsTransId">
<conditions>
<header name="target" value="" match="ANY_VALUE"/>
</conditions>
<actions>
<set property="cicsTransId" value="${target}" />
</actions>
</rule>
</ruleset>cicsTransId. value="" as this attribute is required but is
not used when the request header is checked for a matching name.Example 6
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ruleset>
<rule name="connectionRefRule">
<conditions>
<header name="AppEnv" value="DevEnv"/>
<header name="AppType" value="1"/>
</conditions>
<actions>
<set property="endpointConnectionRef" value="devConnectionRef"/>
</actions>
</rule>
</ruleset>