The service message object (SMO) structure can store WebSphere® MQ header information.
The md element contains all the fields from the MQMD definition (see the WebSphere MQ documentation), except for certain control fields that carry no useful data (such as StrucId and Version) and message format fields (Encoding, CodedCharSetId and Format).
The control element carries the Encoding, CodedCharSetId and Format fields, which describe the message body. If the WebSphere MQ message contains any message headers (for example, MQRFH2), the Encoding, CodedCharSetId and Format fields that describe the header are carried in the header element.
The header element contains Encoding, CodedCharSetId and Format fields, which describe the header. The Format field, in particular, must be set correctly; for example, MQHRF2 for an MQRFH2 header. In addition, the CodedCharSetId and Encoding fields are important for opaque data. When rendered as a WebSphere MQ message, this format information is written into the previous MQ header (or into the MQMD if there is no previous header).
Precisely one of these four subelements must be set: it is an error to have more than one of these set in any header element. The value subelement stores the structure used by the user-supplied header data binding; the other three elements (rfh, rfh2 and opaque) are described in the following sections.
If you use a mediation module to invoke an import with a native MQ binding, and you create the MQ header by setting the MQ header fields in the SMO, you must ensure that the format field of the header is set. Otherwise, a NullPointerException is thrown at runtime. You can set the format field of the MQ header by using one of the supplied mediation primitives. For example, the XSLT primitive or the Message Element Setter primitive. The IBM WebSphere MQ Information Center documents the values supported for the format field. For example, MQHRF2 for an MQRFH2 header.
A WebSphere MQ RFH header contains a string of name-value pairs, where each name and value is simply a text string. This is represented, in SMO, as a repeating property element, containing a name and a value element.
A WebSphere MQ RFH2 header contains zero or more named folders, each of which contains a sequence of properties and groups. A property has a name, optional type and value (all represented as string). A group has a name and itself contains a sequence of properties and groups. The SMO representation of an RFH2 header also contains a NameValueCCSID element, which determines the CCSID used to encode the folders in the WebSphere MQ message.
A WebSphere MQ CIH header can be modeled using the supplied type com.ibm.websphere.sca.mq.structures, and will appear under the value sub-client of the MQ header structure.
The opaque element represents any WebSphere MQ header of the standard structure. Fields common to all such headers (StrucId, Version and Flags) are represented as elements. There is also a data element that contains the unmodeled portion of the header as hexBinary data. When using the opaque element, it is usually important to keep the correct Encoding and CodedCharSetId values associated with the header to avoid data corruption.
The WebSphere MQ header fields are defined using the same set of types used by WebSphere MQ itself. MQLONG fields are represented as int; MQBYTEnn fields as hexBinary data limited to nn in length; and MQCHARnn fields as string data limited to nn characters in length.