How to Define Dynamic Attributes in XML connector


This guide shows how to send attributes dynamically to an XML backend.

java
<FieldName Currency="<VALUE>">0</FieldName>


  1. Create a new class in the SDK project.
    All fields in this class that have names different than value, will be generated as dynamic attributes.

    e.g. XmlEntityMeasuresRequest.java file with 'Currency' as dynamic attribute

  2. On the field you want to have dynamic attribute:

    1. Remove all attributes attributes except for 'DataType' attribute

      • 'DataType' attribute name is mentioned in ol-xml.yml file, in `typeAttribute: DataType`

      • The removed attributes should be added to the class 


    2. Remove @RpcNumericField annotation for numeric field


    e.g. measures field with BigDecimal data type was changed from:

    java
        @FieldAttributes(attributes = {
                @Attribute(key = "Currency", value = "2"),
                @Attribute(key = "DataType", value = "Numeric")
        })
        @RpcField(direction = Direction.INPUT, originalName = "Measures")
        @RpcNumericField(decimalPlaces = 0)
        private BigDecimal measures;

    To:

    java
        @FieldAttributes(attributes = {
                @Attribute(key = "DataType", value = "Numeric")
        })
        @RpcField(direction = Direction.INPUT, originalName = "Measures")
        private XmlEntityMeasuresRequest measures;

The result - Currency attribute is now dynamic:

java
<Measures DataType="Numeric" Currency="<VALUE>">0</Measures>