In the REST service for ruleset execution, primitive Java™ types, XSD types, and Java XOM classes are serialized
differently.
Ruleset parameters are handled differently depending on whether
they are expressed as XML elements or as Java types.
Primitive types
Primitives types are Java types and classes that can
be written as inline strings. The XML element that is used to serialize
a primitive type as a ruleset parameter is the name of the ruleset
parameter in the parameter namespace.
You can find more information
here:
- Changing target namespaces explains
how to customize the parameter namespace from the Ruleset
View in the Rule Execution Server console.
- XML serialization of Java types shows the XML types and Java Architecture for XML Binding
(JAXB) annotations for Java primitive
types and simple types.
Dynamic XOM
For dynamic XOMs, the root element
depends on how the ruleset parameters are defined. The XML description
is serialized from the original XSD code of the dynamic XOM on which
the ruleset is based.
- Name of the root element
For rulesets that are based on a dynamic XOM, the root element
name is determined as follows:
- If the parameter is an XML element in the ruleset signature, that
element is used as the root element name of the parameter in requests
and responses.
- If the parameter is a complex or primitive Java type, the parameter name is used as the
root element name of the parameter in requests and responses, within
the configured param namespace.
Note: A ruleset parameter
is declared from an XML element if it meets the following condition:
that parameter uses an XML complex type for which an XML element was
declared from that complex type in the original imported XSD file.
For example, starting from the following XSD definition:
<xsd:element name="MyConference">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="session" type="session" maxOccurs="unbounded"/>
<xsd:element name="participant" type="participant" minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
the ruleset parameter is declared from
the
MyConference XML element:
<par:Request xmlns:par="http://www.ibm.com/rules/decisionservice/myruleapp/myruleset/param" xmlns:jav="http://www.acme.com/myconference">
<jav:MyConference>
<jav:session>
[…]
<jav:session>
<jav:MyConference>
</par:Request>
- Serialization
The root element depends on your XML types.
- For XML complex types, the parameter declaration uses the parameter
name (in the parameter namespace) as the root element.
- For XML elements, the parameter declaration uses the defined XML
element as the root element in the original namespace. In this case,
the name of the parameter that is attached to each node is provided
in the WADL code as a comment message.
When multiple elements have the same name, element nodes are
differentiated alphabetically. In this case, if you want one of the
elements to be null, you must set the
xsi:nil attribute
to
true. You can do that only if the
nillable attribute
is set to
true for the root element in the original
XSD schema of the dynamic XOM. The default value of the
nillable attribute
is
false.
Java XOM
For Java XOMs, the root element derives
from the parameter declaration and XML serialization uses JAXB annotations.
Arrays are supported for ruleset parameters.
- Name of the root element
For rulesets that are based on a Java XOM,
the parameter declaration uses the parameter name (in the parameter
namespace) as the root element.
- Serialization
- The XML structure of Java XOM
classes is serialized through the standard JAXB process. If the default
serialization does not provide the results that you expect for your
classes, you can customize the serialization process by using JAXB
annotations.
Note: A parameter is visible as an XML element only if
you specify it with an XmlElement annotation or if
valid getXXX and setXXX methods
apply to the parameter.
- Arrays as ruleset parameters
In Java XOM, you can
specify ruleset parameters as simple or multidimensional arrays. XML
serialization is processed differently for either type of arrays: