How to Implement Attachments in XML Messages

This topic consists of the following sections:

Attachments and Oracle E-Business Suite

The Oracle Foundation module offers the ability to define attachments. An attachment may be defined as short text, long text, long RAW, or BLOB data type. When the attachment is defined in FND, unique identifiers are provided so that the attachment may be correlated to the business document. Example uses of attachments are terms and conditions associated with a purchase order or images associated with catalog items.

Attachments and OAG Standard

With OAG version 7.X, the ATTCHREF data type is used to associate large objects with a business document. Attachments are associated to an XML message by FILENAME. The ATTCHREF data type is defined as follows:

FILENAME (Required) The name of a file for reference purposes.
For XML Gateway message maps, the CID is mapped to the FILENAME element.
CMPRSNTYPE (Optional) Identifies the method used to compress or minimize the size, if a file is attached to the document. This enables the receiving application to process the file appropriately.
For Oracle Foundation module, the compression type is determined when the attachment is deposited.
CMPRSNID (Optional) Identifies the name of the compressed file. This enables the receiving application to find the file within the compressed package.
For XML Gateway, the physical file is not passed. The CID identified in the message map is used by OTA to construct the message payload with its associated attachments.
DATETIME (Optional) The creation date of the attachment.
DESCRIPTN (Optional) A free-form description of the transaction or any portion of the transaction.
FILETYPE (Optional) Identifies the application source or format of the data within the file. Examples are MS Excel, CSV, and AutoCAD.
NOTES1- NOTES99 (Optional)
QUANTITY (Optional) File size of the attachment.
TITLE (Optional) Describes the formal name of "title" of the item, person, or object.

Note: The URL option supported by OAG 7.3 is not supported by XML Gateway at this time.

The ATTCHREF data type is not required if the attachment is a text string. These attachments can be associated with an XML data type or element for text strings. Textual attachments will be in-line with the business document. Large attachments of the BLOB data type will be associated off-line to the business document using the ATTCHREF data type as the reference.

Attachments and Oracle Transport Agent (OTA)

The OTA component of Oracle XML Gateway is used to deliver business documents containing large objects of type BLOB in a Multipurpose Internet Mail Extension (MIME) payload over HTTP or HTTPS to a Trading Partner. Similarly, inbound documents containing attachments may be sent by a Trading Partner's OTA servlet and received by the Oracle E-Business Suite user's OTA servlet.

Note: The support for large object attachments is limited to Business-to-Business document exchanges with Trading Partners delivered/received using OTA.

OTA is responsible for the following:

Note: Oracle Transport Agent also supports MIME messages without attachments. Similarity to the message process with attachments, OTA uses the same approach to process the message, but without further processing attachments if they do not exist.

Attachments and Outbound Documents

For outbound documents, it is assumed that an attachment has been defined in the Oracle Foundation (FND) module and that it has been associated with a business document. A given business document can have any number of attachments defined at any level of the document.

To include an attachment in the generated XML message, the XML Gateway must be informed of the relationship between the attachment and the business document. This is accomplished by adding a Procedure Call action to the message map to call the register attachment API at every point in the business document where an attachment is identified.

The relationship data is maintained in the ECX_ATTACHMENT_MAPS table, which is used by OTA to construct the outbound XML message with a valid MIME message containing the message payload and associated attachments. The register_attachment API returns a unique content ID (referred to as CID) that is mapped to the OAG ATTCHREF data type, FILENAME element, or other standards-specific equivalent.

See register_attachment API for more information.

Because the attachment, with its unique identifiers defined for it in FND, has a direct relationship with the map for the business document, any changes to the attachment (such as deletion) or to the attachment identifiers must be reflected in the message map to maintain data integrity.

Attachment content changes are reflected in the next usage of the attachment on a business document. The change will not be retroactively applied to previously generated business documents.

Enable Attachments for Unit Test for Outbound Documents

The following outlines the steps necessary to set up attachments for outbound documents:

Attachments and Inbound Documents

For inbound documents, OTA will extract the business document from the multi-part message and enqueue it onto the ECX_INBOUND queue. It will also extract the associated attachments and deposit them into the FND module of the receiving instance. For each attachment deposited into the receiving instance, an entry is written to the ECX_ATTACHMENT_MAPS table to record the relationship between the attachment and the business document.

If the inbound business document contains a reference to an attachment via the OAG ATTCHREF data type, FILENAME element, or other standards-specific equivalent, and the Oracle E-Business Suite module is interested in the attachment, the attachment content can be retrieved from the FND module of the receiving instance. This is accomplished by adding a Procedure Call action to the message map at every point of the business document where an attachment of interest is identified. There is no requirement to retrieve every attachment associated with an inbound business document unless the application module is interested in them.

Because the BLOB data type is handled at the database layer, the Oracle E-Business Suite module must define an API that internally calls the XML Gateway retrieve_attachment API. The BLOB attachment content is passed from the retrieve_attachment API x_file_data OUT parameter to the IN parameter of the application API. The application module is responsible for storing the attachment content in the appropriate column of the application table.

The receiving Oracle E-Business Suite module may change the FND attributes associated with the attachment originally deposited by OTA. This is accomplished by calling the retrieve_attachment API to retrieve the original attachment, and then calling the reconfig_attachment API to reset the FND attributes for the attachment with the application-specific identifiers.

See retrieve_attachment and reconfig_attachment for more information about these APIs.

Enable Attachments for Unit Test for Inbound Documents

The following outlines the steps necessary to set up attachments for inbound documents: