Attachments
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.
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.
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 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. |
...
1. Get a protocol object for the protocol IF_WSPROTOCOL_ATTACHMENTS (see Protocols).
2. 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.
3. At the sender, create attachment objects by using the GET_ATTACHMENT_FROM_BINARY() method and attach them to the lt_attach table. You can use the GET_ATTACHMENT_FROM_TEXT() method for string attachments.
4. Transfer the lt_attach table to the ABAP proxy runtime with the SET_ATTACHMENTS() attachment protocol method.
5. Call the client proxy (see also: Sending a Message).
6. 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).
7. 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.

Once you have fetched the input message attachments, you can set attachments for the output message in the synchronous case, using SET_ATTACHMENTS(). Since only one protocol object exists for the attachment protocol, you overwrite the attachments of the input message. If you do not want to return any attachments, call the method RESET_ATTACHMENTS(), so that the system deletes received attachments and does not return them.