Querying the Payload
On both the sender and receiver side, it is useful to be able to access the payload of a message. Note the following two cases:
· You only need the payload after you have sent or received the message (for example, to archive the sent message).
· You need to know what the payload looks like before you send the message (for example, for the XI runtime, because you want to identify the receiver in advance and the receiver depends on data in the payload).
All the methods described here return the payload as an object of type IF_WS_PAYLOAD. You use the methods of this object to access the payload.
To call the payload, first fetch an instance for the payload protocol IF_WSPROTOCOL_PAYLOAD. Use the following methods:
Methods for Calling the Payload After Sending/Receiving a Message
Method |
Used in: |
GET_SENT_REQUEST_PAYLOAD |
Client proxy and server proxy |
GET_SENT_RESPONSE_PAYLOAD |
Client proxy |
GET_SENT_EXCEPTION_PAYLOAD |
Client proxy |
The method GET_PAYLOAD_HANDLER of the payload protocol returns a payload handler (object of type REF TO IF_WS_PAYLOAD_HANDLER). You use this handler to generate (render) or parse the payload for a request, response, or fault message.

You can also fetch the handler by using the method GET_PAYLOAD_HANDLER of the class CL_PROXY_ACCESS of the ABAP proxy runtime, independently of a proxy instance. In this case, you also have to specify the class name of the proxy and the proxy method. The parameter EXTENDED_XML_HANDLING of this method determines whether the extended XML handling is active for all methods of the payload handler.
The following methods of the payload handler are also used internally by the ABAP proxy runtime.
Methods of IF_WS_PAYLOAD_HANDLER
Method |
Use |
GET_PAYLOAD_FROM_REQUEST_DATA |
Generates a payload for proxy request data (rendering) |
GET_PAYLOAD_FROM_RESPONSE_DATA |
Generates a payload for proxy response data (rendering) |
GET_PAYLOAD_FROM_EXCEPTION |
Returns a fault message from an exception class instance (rendering) |
GET_REQUEST_DATA_FROM_PAYLOAD |
Parses a request message payload to have the system return the request data |
GET_RESPONSE_DATA_FROM_PAYLOAD |
Parses a response message payload to have the system return the response data |
GET_EXCEPTION_FROM_PAYLOAD |
Parses a fault message payload to have the system return an instance of the corresponding exception class |
The following program fetches the payload for a request message independently of a proxy instance and returns it in the system:
DATA:
ls_request TYPE
[Data type of output parameter],
lo_fault TYPE
REF TO cx_ai_system_fault,
lo_payload_handler TYPE REF TO
IF_WS_PAYLOAD_HANDLER,
lo_payload TYPE
REF TO if_ws_payload,
lt_request_data TYPE PRX_T_PARAM,
ls_request_data TYPE PRX_S_PARAM.
lo_pointer TYPE
REF TO xstring,
* Fill request data
request-field1
= '[Value1]'.
request-field1 = '[Value1]'.
*...
request-fieldN = '[ValueN]'.
*
Use payload handler to get payload independently
* from proxy call:
TRY.
*
Get Payload handler for a proxy method.
* Note: You have to provide the proxy and method name in uppercase.
lo_payload_handler
= cl_proxy_access=>get_payload_handler(
proxy_name = 'CO_...'
proxy_method = 'EXECUTE_SYNCHRONOUS'
).
* Pass request data to payload handler
CLEAR
lt_request_data.
CLEAR ls_request_data.
ls_request_data-name = 'OUTPUT'.
GET REFERENCE OF request into ls_request_data-value.
append ls_request_data to lt_request_data.
lo_payload =
lo_payload_handler->get_payload_from_request_data(
lt_request_data).
* Catch system faults
CATCH
cx_ai_system_fault INTO lo_fault.
WRITE: / 'System fault'.
WRITE: / 'Code:', lo_fault->code.
WRITE: / 'Text:', lo_fault->errortext.
EXIT.
ENDTRY.
* Show payload for test purposes
lo_pointer =
lo_payload->get_xml_pointer( ).
cl_proxy_service=>show_xml_document( lo_pointer->* ).