Previous Table of Contents Next


15.3.3 Encapsulation


   As described above, OMG IDL data types may be independently marshaled into encapsulation octet streams. The octet stream is represented as the OMG IDL type sequence<octet>, which may be subsequently included in a GIOP message or nested in another encapsulation.

   The GIOP and IIOP explicitly use encapsulations in three places: TypeCodes (see Section 15.3.5.1, “TypeCode,? on page 15-23), the IIOP protocol profile inside an IOR (see Section 15.3.6, “Object References,? on page 15-30), and in service-specific context (see Section 13.7, “Service Context,? on page 13-28). In addition, some ORBs may choose to use an encapsulation to hold the object_key (see Section 15.7.2, “IIOP IOR Profiles,? on page 15-52), or in other places that a sequence<octet> data type is in use.

   When encapsulating OMG IDL data types, the first octet in the stream (index 0) contains a boolean value indicating the byte ordering of the encapsulated data. If the value is FALSE (0), the encapsulated data is encoded in big-endian order; if TRUE (1), the data is encoded in little-endian order, exactly like the byte order flag in GIOP message headers (see Section 15.4.1, “GIOP Message Header,? on page 15-31). This value is not part of the data being encapsulated, but is part of the octet stream holding the encapsulation. Following the byte order flag, the data to be encapsulated is marshaled into the buffer as defined by CDR encoding rules. Marshaled data are aligned relative to the beginning of the octet stream (the first octet of which is occupied by the byte order flag).

   When the encapsulation is encoded as type sequence<octet> for subsequent marshaling, an unsigned long value containing the sequence length is prefixed to the octet stream, as prescribed for sequences (see Section 15.3.2.5, “Sequence,? on page 15-12). The length value is not part of the encapsulation’s octet stream, and does not affect alignment of data within the encapsulation.

   Note that this guarantees a four-octet alignment of the start of all encapsulated data within GIOP messages and nested encapsulations.2

   Whenever the use of an encapsulation is specified, the GIOP version to use for encoding the encapsulation, if different than GIOP version 1.0, shall be explicitly defined (i.e., the default is GIOP 1.0).

   If a parameter with IDL char or string type is defined to be carried in an encapsulation using GIOP version greater than 1.0, the transmission Code Set for characters (TCSC), to be used when encoding the encapsulation, shall also be explicitly defined.

   If a parameter with IDL wchar or wstring type is defined to be carried in an encapsulation using GIOP version greater than 1.0, the transmission Code Set for wide characters (TCS-W), to be used when encoding the encapsulation shall also be explicitly defined.