Attachments
Use
An attachment comprises any data (for example, text or graphics) that can be appended to a message. You can attach any number of attachments to a request or response message in order to pass them on to the receiver.
Prerequisites
Note that not all receivers of a message can understand attachments and therefore some receivers will ignore them. The proxy runtime (ABAP/Java) can process attachments, however the majority of the adapters cannot.
Features
Methods of Protocol IF_WSPROTOCOL_ATTACHMENTS
| Method | Meaning |
|---|---|
|
GET_ATTACHMENT_FROM_TEXT |
Returns an attachment object for a parameter of type STRING. |
|
GET_ATTACHMENT_FROM_BINARY |
Returns an attachment object for a parameter of type XSTRING. |
|
SET_ATTACHMENTS |
Attaches one or more attachment objects to the output message by using a table. |
|
GET_ATTACHMENTS |
Returns a table with attachment objects at the receiver. |
|
RESET_ATTACHMENTS |
Deletes the attachment table for the output message. |
Attachment Objects
Attachment objects implement the IF_AI_ATTACHMENT interface. This interface specifies a selection of constants, for example IF_AI_ATTACHMENT=>C_MIMETYPE_TEXT_HTML to help specify the attachment type. You must specify this constant when you want to create an attachment object.
Methods of Interface IF_AI_ATTACHMENT
| Method | Meaning |
|---|---|
|
GET_KIND |
Returns the type of attachment as either IF_AI_ATTACHMENT=>C_ATTACH_TYPE_BINARY or IF_AI_ATTACHMENT=>C_ATTACH_TYPE_TEXT. |
|
GET_CONTENT_TYPE |
Returns the attachment type. |
|
GET_TEXT_DATA |
Only use for attachment objects of type IF_AI_ATTACHMENT=>C_ATTACH_TYPE_TEXT. Returns the attachment data as STRING. |
|
GET_BINARY_DATA |
Returns the attachment data as XSTRING. You can use this method for both types of attachments. |
|
GET_DOCUMENT_NAME |
Returns the attachment name. |
Activities
Sender
- Get a protocol object for the protocol IF_WSPROTOCOL_ATTACHMENTS (see Protocols ).
- You must declare the following variables both at the attachment sender and receiver:
data: lt_attach type prx_attach, l_name type string, l_xstring type xstring, l_string type string, l_type type string,
l_attachment type ref to if_ai_attachment.
- At the sender, create attachment objects by using the GET_ATTACHMENT_FROM_BINARY() method and attach them to the lt_attachtable. You can use the GET_ATTACHMENT_FROM_TEXT() method for string attachments.
- Transfer the lt_attach table to the ABAP proxy runtime with the SET_ATTACHMENTS() attachment protocol method.
- Call the client proxy (see also: Sending a Message ).
Receiver
- At the receiver, declare the same variables as in step two above and get a protocol object for the IF_WSPROTOCOL_ATTACHMENTS protocol (see Protocols ).
- Using the GET_ATTACHMENTS()attachment protocol method, get the attachment table. When reading the attachments, ensure that you use the GET_KIND() method to check the attachment object type before you access the data.