You are viewing the documentation for Blueriq 17. Documentation for other versions is available in our documentation directory.

When creating your own Blueriq as a Service (BaaS), it is possible to include a justification tree in your response to the caller of the webservice. This tree explains how a certain attribute was derived by the inference engine and provides the justification texts.

To do this, you need the Custom Schema Element: AQ_JustificationTreeV2, which is part of the BlueriqBasicModelling Library. Justification trees can be added to SOAP responses and REST responses. 


Adding a justification tree to the response of a REST webservice

Adding a justification tree to a REST message is straightforward: just add a custom schema element of type AQ_JustificationTreeV2 to the domain schema. 

The message in the response of the Blueriq webservice could look like this:

{
    "Costs": 3000.0,
    "AQ_JustificationTreeV2": {
        "key": "Tax.AnnualAmount",
        "values": [
            {
                "type": "number",
                "value": 3000.0
            }
        ],
        "justification": [
            {
                "key": "AdditionalText",
                "value": "Additional Justification tax statement."
            },
            {
                "key": "Text",
                "value": "A car that is over 60k has a high annual tax."
            }
        ],
        "used_values": [
            {
                "key": "Car.ModelYear",
                "values": [
                    {
                        "type": "integer",
                        "value": 1993
                    }
                ],
                "justification": null
            },
            {
                "key": "Car.Value",
                "values": [
                    {
                        "type": "number",
                        "value": 70000.0
                    }
                ],
                "justification": null
            }
        ]
    }
}

Adding a justification tree to the response of a SOAP webservice

If you open this schema element, you find under the 'XSD' tab the following XSD:

XSD of AQ_JustificationTreeV2
<?xml version="1.0" encoding="utf-8"?>
<xs:schema
    targetNamespace="http://aquima.com/schemas/justification/2.0"
    xmlns="http://aquima.com/schemas/1.0"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="justificationTree">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="attribute" minOccurs="1" maxOccurs="1"/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  <xs:element name="attribute" type="attributeType">
    <xs:attribute name="name" type="xs:string"/>
  </xs:element>
  <xs:complexType name="attributeType">
    <xs:sequence>
      <xs:element name="value" minOccurs="0" maxOccurs="unbounded" type="valueType"/>
      <xs:element name="justifications" minOccurs="1" maxOccurs="1" type="justificationsType"/>
      <xs:element ref="attribute" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="valueType">
    <xs:sequence>
      <xs:element name="type" minOccurs="1" maxOccurs="1" type="xs:string"/>
      <xs:element name="value" minOccurs="1" maxOccurs="1" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="justificationType">
    <xs:sequence>
      <xs:element name="justification" minOccurs="0" maxOccurs="unbounded" type="xs:string">
        <xs:attribute name="type" type="xs:string"/>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:schema>

You need to make this XSD part of the response of your webservice. The easiest way is to save the justification XSD in a separate file and use the <import> statement in your own XSD. After importing your WSDL/XSD with the justification tree in it, go to the corresponding Schema set and open the justification tree element.

You have to make the justification XSD really part of your own WSDL/XSD. This means referring to it with an <import> statement and supplying this file together with your own WSDL during the import.

  • No labels