Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 11 Private Messages : Attachment

Attachment
You can use TIBCO BusinessConnect SOAP Protocol to send and receive attachments in binary format, such as .jpg, .zip, or .doc, or in the text format. TIBCO BusinessConnect SOAP Protocol private process sends the attachments to BusinessConnect, or receives the attachments from BusinessConnect.
The attachment class in the messages has the following fields:
name  The name of the attachment
content-type  The type of the content associated with this attachment, such as text of binary
content-id  The content ID for the attachment
content  Content of the attachment
originalContentType  The original received content type
This field is only available for the ResponderRequest and InitiatorResponse private process messages. It has the same value as the content-type field, unless the content-type field cannot be inferred by Business Connect. In that case, the content-type field is changed to application/octet-stream and the originalContentType field is set to the actual value that is received.
All attachment fields are defined as strings, which require that the binary content be specified as base64 encoded.
MTOM and attachments from the private process cannot be used together. If the SOAP MTOM Enabled check box is selected, meanwhile some attachments are also specified from the private process request message, the request is rejected and the outbound process is ended.
Multipart MIME Messages
When attachments are present, SOAP messages are formulated as multipart Multipurpose Internet Mail Extensions (MIME) messages and TIBCO BusinessConnect SOAP Protocol depends on the parameters in the content-type field for packaging.
MIME messages are configured as follows:
Content-Type  Indicates the type of the content embedded in the part.
Content-Disposition  Indicates the presentation style used for the MIME part.
Content-Transfer-Encoding  Indicates the encoding used for the MIME part.
Content-ID  Indicates the content from anywhere in the multipart SOAP message.
Determining the Content Type of an Attachment
The value in the content-type field must be defined in the type/subtype format, such as text/xml, application/zip, and so on.
TIBCO BusinessConnect SOAP Protocol processes the attachment content based on the value in the content-type field as follows:
Content is processed as plain text and the content type is referred to as text if it is in the text/* or application/*xml* formats.
Content is processed as binary and the content type is referred to as binary if it is in the application/binary, application/octet-stream, application/zip, application/pdf, application/doc, image/*, audio/*, or video/* formats.
Content type that is not in text or in binary format is processed as unknown and referred to as unknown. Content is packaged or interpreted as either text or binary, depending on the situation.
If the value in the content-type field does not conform to the Request for Comments (RFC) standard, it is changed to application/octet-stream and the content is processed as binary.
The only exception to this rule is when the value in the content-type field is defined as binary and is subsequently changed to application/binary. This change is made to maintain backward compatibility with TIBCO BusinessConnect SOAP Protocol 5.0.
The value in the content-type field for attachments must conform to MIME [RFC2045] standards, for example, it has to be in the type/subtype format. For complete syntax of this property, see RFC 2045 at http://www.ietf.org/rfc/rfc2045.txt.
Outbound Attachments
Outbound attachments are populated for the outbound request or response messages such as InitiatorRequest or ResponderResponse.
If the value in the content-type field is not specified, it is determined based on the type of content:
If content is of type String, the value in the content-type field defaults to text/plain.
If content is of type byte Array, the value in the content-type field defaults to application/octet-stream.
Content for the outbound attachments is packaged as a byte array as follows:
If the value in the content-type field is text, content is converted to bytes and the attachment is populated.
If the value in the content-type field is binary, content is base64 decoded if it was previously base64 encoded. Otherwise, content is converted to bytes and the attachment is populated.
If the value in the content-type field is unknown, the content type is changed to application/octet-stream, content is converted to bytes, and the attachment is populated.
Inbound Attachments
Inbound attachments are received from public process multipart MIME SOAP messages, which can carry the attachment content either in text or binary format.
Since the private process has to receive the attachment content as a string, TIBCO BusinessConnect SOAP Protocol handles the attachments with the different content types as follows:
If the attachment content type is text, content is sent to the private process as text.
If the attachment content type is binary, content is base64 encoded and sent to the private process.
If the attachment content type is unknown, content is base64 encoded and sent to the private process. In this case, the value in the content-type field is changed to application/octet-stream and the content is processed as binary. For example, even if the plain text is received with the value in the content-type field described as unknown, this content is base64 encoded.
See Converting Attachments to Base64 Strings.
Converting Attachments to Base64 Strings
Attachments are converted to base64 string as follows:
1.
Content-Transfer-Encoding is inspected. If it is base64, content is sent as base64 to the private process.
2.
Content itself is inspected for base64 characters. If all the characters are in the base64 character range, content is sent as base64. Otherwise, content is base64 encoded and sent.
OriginalContentType
For inbound attachments, if the content type is unknown, it is changed to application/octet-stream. The same value is passed on to the private process in the content-type field. The original value received is populated in the originalContentType field.
For text and binary content types, the content-type and originalContentType fields for the private process have the same value. The originalContentType field is populated even when the attachment property from the release 5.0 is preserved.
Preserving the SOAP 5.0 Attachment Functionality
TIBCO BusinessConnect SOAP Protocol version 5.0 processes the attachments as plain strings. For binary attachments, this could cause a problem.
From 5.1 release and onward, the behavior has been changed so that the binary attachments are converted to base64 encoding before they are sent to private process if they are not in base64 encoding originally.
However, you can still keep version 5.0 behavior for a particular partner by setting the TIBCO BusinessConnect SOAP Protocol Boolean property:
bc.soap.<tpname>.enable50Attachment = true
where <tpname> is the name of the trading partner. When enabled, the original content type that was received is sent to the private process.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved