Try OpenEdge Now
skip to main content
Messaging and ESB
Messaging Examples : MultiPartMessage example
 

MultiPartMessage example

The following fragment creates a MultiPartMessage:
/* Create a multipart message */
RUN createMultipartMessage IN hPTPSession (OUTPUT hMessage).
/* Create a Sonic text message */
RUN createTextMessage IN hPTPSession (OUTPUT messagePartH).
RUN setText IN messagePartH (cTextString).
/* Add part to multipart message */
RUN addMessagePart IN hMessage (INPUT messagePartH, INPUT contentIDString).
/* Add a memptr part */
RUN addBytesPart IN hMessage
  (memptr, contentTypeString, contentIDString).
/* Add a text part */
RUN addTextPart IN hMessage
  (memptr, msgTextString, contentTypeString, contentIDString).
First, the fragment creates a MultiPartMessage just as it would create any other supported message type. The createMultipartMessage procedure returns a message handle, which supports methods for adding parts.
Next, the fragment creates a text message and adds it to the MultiPartMessage. Each message part has two main identifiers: content type and content ID. Content type identifies the type of part, while content ID identifies a particular part. Since a Sonic text message already has a content type, when the text message is added, only the content ID must be specified.
Finally, the fragment adds a bytes part, comprising an arbitrary set of bytes represented as a MEMPTR. Adding the bytes part resembles adding the text message except that the content type must also be specified.