Code: Alles auswählen.
DATA: o_client TYPE REF TO if_http_client,
lv_http_status TYPE i,
lv_status_text TYPE string,
response_content TYPE string,
lv_uri TYPE string.
TRY.
" Create HTTP client based on destination
CALL METHOD cl_http_client=>create_by_destination
EXPORTING
destination = 'TEST_DESTINATION'
IMPORTING
client = o_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
others = 4.
IF sy-subrc <> 0.
o_client->close( ).
RETURN. " Exit if there's an error
ENDIF.
" Setting specific path or adding parameters to the URL
lv_uri = '/this/could/be/your/endpoint'.
o_client->propertytype_logon_popup = abap_false.
o_client->request->set_header_field( name = '~request_uri' value = lv_uri ).
" Make a GET request
o_client->request->set_method( if_http_request=>co_request_method_get ).
o_client->send( timeout = if_http_client=>co_timeout_default ).
o_client->receive( ).
" Get the HTTP status and response content
o_client->response->get_status( IMPORTING
code = lv_http_status
reason = lv_status_text ).
response_content = o_client->response->get_cdata( ).
" Displaying the response code and content for debugging
WRITE: / 'HTTP Status:', lv_http_status.
WRITE: / 'Response:', response_content.
CATCH cx_root INTO DATA(lx_error).
" Handle exception
WRITE: / lx_error->get_text( ).
ENDTRY.
Folgende Benutzer bedankten sich beim Autor a-dead-trousers für den Beitrag:
sap_koun
Wie hast du das gemacht?
Folgende Benutzer bedankten sich beim Autor IHe für den Beitrag:
a-dead-trousers
Hallo,a-dead-trousers hat geschrieben: ↑07.08.2023 18:54...
Zumindest für die Logischen Ports von Webservices hätte ich eine "Umgehungslösung" anzubieten, die eine interne Schnittstelle "ausnutzt". Bei RFC Destination kann ich jetzt auf die schnelle leider nichts finden.
...
Code: Alles auswählen.
* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_SRT_LOGICAL_PORT=>SELECT
* +-------------------------------------------------------------------------------------------------+
* | [--->] ID_PROXYCLASS TYPE SRT_LP_PROXYCLASS
* | [--->] ID_LP_NAME TYPE SRT_LP_NAME(optional)
* | [--->] ID_PROPERTIES TYPE ABAP_BOOL (default =ABAP_TRUE)
* | [--->] ID_OPERATIONS TYPE ABAP_BOOL (default =ABAP_TRUE)
* | [<-()] RS_DATA TYPE ZS_SRT_LOGICAL_PORT_DATA
* | [!CX!] CX_STATIC_CHECK
* | [!CX!] CX_DYNAMIC_CHECK
* +--------------------------------------------------------------------------------------</SIGNATURE>
METHOD select.
DATA:
ld_proxyclass TYPE srt_lp_proxyclass,
lr_dt_query TYPE REF TO if_srt_wsp_dt_config_query,
lr_registry TYPE REF TO if_srt_wsp_config_registry,
lt_config TYPE srt_wsp_config_lp_list,
lr_config TYPE REF TO if_srt_wsp_config_rt,
lt_binding TYPE srt_if_srt_wsp_subject_bndgs,
lt_operation TYPE srt_if_srt_wsp_subject_bndgops,
lr_propertylist TYPE REF TO if_srt_wsp_property_list,
lt_property TYPE srt_if_srt_wsp_properties.
FIELD-SYMBOLS:
<ls_config> TYPE srt_wsp_config_lp,
<lr_property> TYPE REF TO if_srt_wsp_property.
CLEAR rs_data.
lr_dt_query = cl_srt_wsp_dt_config_data=>open_dt_query_if( ).
lr_registry = cl_srt_wsp_factory=>create_registry( ).
IF lr_dt_query->is_stcm( i_name = id_proxyclass ) EQ abap_true.
ld_proxyclass = lr_dt_query->get_source_proxy_for_stcm( i_stcm_name = id_proxyclass ).
lt_config = lr_registry->list_stcm_client_cfgs_with_lps( i_source_proxy_name = ld_proxyclass
i_lp_name = id_lp_name ).
ELSE.
lt_config = lr_registry->list_client_configs_with_lp( pi_proxy_class_name = id_proxyclass
pi_lp_name = id_lp_name ).
ENDIF.
IF id_lp_name IS INITIAL.
READ TABLE lt_config ASSIGNING <ls_config> WITH KEY is_default = abap_true.
ELSE.
READ TABLE lt_config ASSIGNING <ls_config> INDEX 1.
ENDIF.
IF sy-subrc EQ 0.
lr_config = lr_registry->open_config_rt( name = <ls_config>-config_name
type = tsrtp_c_conf_type_cl_rt
dt_obj_name = id_proxyclass ).
IF lr_config IS BOUND.
lt_binding = lr_config->get_bindings( ).
READ TABLE lt_binding ASSIGNING FIELD-SYMBOL(<lr_binding>) INDEX 1.
IF sy-subrc EQ 0.
IF id_properties EQ abap_true.
lr_propertylist = <lr_binding>->get_selected_property_list( ).
IF lr_propertylist IS NOT BOUND.
lr_propertylist = <lr_binding>->create_property_list( ).
ENDIF.
* get properties
lt_property = lr_propertylist->get_properties( ).
LOOP AT lt_property ASSIGNING <lr_property>.
APPEND VALUE #( name = <lr_property>->name
value = <lr_property>->value ) TO rs_data-properties.
ENDLOOP.
CLEAR lt_property.
CLEAR lr_propertylist.
ENDIF.
IF id_operations EQ abap_true.
lt_operation = <lr_binding>->get_operations( ).
LOOP AT lt_operation ASSIGNING FIELD-SYMBOL(<lr_operation>).
APPEND VALUE #( name = <lr_operation>->name ) TO rs_data-operations ASSIGNING FIELD-SYMBOL(<ls_operation>).
lr_propertylist = <lr_operation>->get_selected_property_list( ).
IF lr_propertylist IS NOT BOUND.
lr_propertylist = <lr_operation>->create_property_list( ).
ENDIF.
* get properties
lt_property = lr_propertylist->get_properties( ).
LOOP AT lt_property ASSIGNING <lr_property>.
APPEND VALUE #( name = <lr_property>->name
value = <lr_property>->value ) TO <ls_operation>-properties.
ENDLOOP.
CLEAR lt_property.
CLEAR lr_propertylist.
ENDLOOP.
CLEAR lt_operation.
ENDIF.
ENDIF.
CLEAR lt_binding.
rs_data-description = lr_config->description.
lr_config->terminate( ).
CLEAR lr_config.
ENDIF.
ENDIF.
CLEAR lt_config.
CLEAR lr_registry.
CLEAR lr_dt_query.
ENDMETHOD.
Code: Alles auswählen.
READ TABLE ls_data-properties ASSIGNING <ls_property>
WITH KEY name-name = tsrtp_f_bdg_proxy_user.
IF sy-subrc EQ 0.
ld_username = <ls_property>-value.
ENDIF.
READ TABLE ls_data-properties ASSIGNING <ls_property>
WITH KEY name-name = tsrtp_f_bdg_proxy_passwd.
IF sy-subrc EQ 0.
ld_password = <ls_property>-value.
ENDIF.
Folgende Benutzer bedankten sich beim Autor a-dead-trousers für den Beitrag:
cb1000r