in src/zrest/zcl_rest_framework.clas.abap [0:0]
METHOD zif_rest_framework~execute.
DATA: lwa_config_data TYPE zrest_srtuct_config,
rest_exception TYPE REF TO cx_rest_client_exception.
CREATE OBJECT rest_exception.
GET TIME STAMP FIELD pre_timestamp.
* Is this a retry ?
me->retry = is_retry.
* Change only for the retry sceario.
IF is_retry( ) = abap_true.
me->message_id = messageid.
retry_cnt = retry_count + 1.
ELSE.
* Create the unique guid . This is used across all the tables for storing
* and retrieving the information related to REST calls
me->message_id = me->create_message_id( ).
ENDIF.
* This method will execute GET,POST,PUT ...ased on the configuration set for the inteface. If Async is set , Request will
* in the wating status till the async program flushes this out. Apart from executing the calls , this method will hold
* the metrics of data
* Get the configuration data for the inteface.
lwa_config_data = zcl_rest_utility_class=>get_config_data(
interface_id = interface
method = method_call ).
* Get the static headers from the configuration
rest_client->if_rest_client~set_request_headers( zcl_rest_utility_class=>get_static_headers( interface_id = interface ) ).
* Set the corelation id
DATA lv_value TYPE string.
lv_value = message_id.
rest_client->if_rest_client~set_request_header( iv_name = 'id-sap-restfrmwrk' iv_value = lv_value ).
* Set the basic log parameters
log_start_params( ).
gwa_log-method = method.
* If it's Async , record and exit
IF async EQ abap_false.
TRY .
CASE lwa_config_data-method.
WHEN zif_rest_http_constants=>c_http_method_head.
rest_client->if_rest_resource~head( ).
WHEN zif_rest_http_constants=>c_http_method_get.
rest_client->if_rest_resource~get( ).
WHEN zif_rest_http_constants=>c_http_method_delete.
rest_client->if_rest_resource~delete( ).
WHEN zif_rest_http_constants=>c_http_method_options.
rest_client->if_rest_resource~options( ).
WHEN zif_rest_http_constants=>c_http_method_post.
rest_client->if_rest_resource~post( request ).
WHEN zif_rest_http_constants=>c_http_method_put.
rest_client->if_rest_resource~put( request ).
ENDCASE.
log_end_params( ).
CATCH cx_rest_client_exception INTO rest_exception.
log_end_params( ).
gwa_log-reason = rest_exception->get_text( ).
ENDTRY.
*Read the respomse and set the appropriate reason
response = rest_client->if_rest_client~get_response_entity( ).
IF response IS BOUND.
gwa_log-reason = 'Endpoint Called' .
ENDIF.
ELSE.
*Log the submitted time
log_submit_params( ).
gwa_log-reason = 'Async-Waiting'.
ENDIF.
* duration = duration * -1000. " Convert to microseconds
GET TIME STAMP FIELD pro_timestamp.
duration = cl_abap_tstmp=>subtract(
tstmp1 = pre_timestamp
tstmp2 = pro_timestamp ).
* Save the log to database for further reporing
save_log( ).