An ExtensionObject is a container for any Structured DataTypeswhich cannot be encoded as one of the other built-in data types. The ExtensionObject contains a complex value serialized as a sequence of bytes or as an XML element. It also contains an identifier which indicates what data it contains and how it is encoded.
There are four primary use cases where ExtensionObjects appear:
- When encoding a top-level DataTypeas a Service Requestor Response;
- When encoding a Structure value inside a Variant;
- When encoding a field value in a Structure where the field DataTypeis Structure.
- When encoding a field value in a Structure whereAllowSubTypes=TRUE (see F.12).
In all of these cases, the ExtensionObjectprovides an identifier that allows a decoder to know if it understands the Structurecontained with it and a length that allows the Structureto be skipped if it is not recognized.
Structured DataTypesare represented in a Serveraddress space as sub-types of the Structure DataType. The DataEncodingsavailable for any given Structured DataTypesare represented as a DataTypeEncoding Objectin the Server AddressSpace. The NodeIdfor the DataTypeEncoding Objectis the identifier stored in the ExtensionObject. OPC 10000-3describes how DataTypeEncoding Nodesare related to other Nodesof the AddressSpace.
Elements of an array of ExtensionObjectsmay have different DataTypeEncoding NodeIdsspecified. In some cases, this will be invalid, however, it is the responsibility of the application layer to enforce whatever constraints are imposed by the Information Model on a given array. Decoders shall accept any valid ExtensionObject as an array element.
Serverimplementers should use namespace qualified numeric NodeIdsfor any DataTypeEncoding Objectsthey define. This will minimize the overhead introduced by packing Structured DataType values into an ExtensionObject.
ExtensionObjects and Variantsallow unlimited nesting which could result in stack overflow errors even if the message size is less than the maximum allowed. Decoders shall support at least 100 nesting levels. Decoders shall report an error if the number of nesting levels exceeds what it supports.