ztestproxy2_eg2_auth
ztestproxy2_eg2_auth
************************************************************************
************************************************************************
* Structures:
************************************************************************
* Variables:
************************************************************************
*
DATA: p_url LIKE w_url.
DATA: lv_uri TYPE string.
DATA: lv_service_url TYPE string,
lv_url TYPE string,
lv_service_url1 TYPE string,
lo_http_client TYPE REF TO if_http_client,
lo_rest_client TYPE REF TO cl_rest_http_client,
lo_response TYPE REF TO if_rest_entity,
lv_http_status TYPE i,
lv_result TYPE string,
reason TYPE string,
l_url TYPE string,
l_url1 TYPE string,
l_token TYPE string,
lv_token TYPE string.
START-OF-SELECTION.
*******code 1
lv_service_url =
'https://asbqa.azurewebsites.net/api/ASBToken/GetAccessToken'.
.
** GET CSRF token
cl_http_client=>create_by_url(
EXPORTING url = lv_service_url " oData service URL
IMPORTING client = lo_http_client
EXCEPTIONS OTHERS = 1 ).
CHECK sy-subrc EQ 0.
lo_http_client->request->set_content_type( 'application/json' ).
CREATE OBJECT lo_rest_client
EXPORTING
io_http_client = lo_http_client.
* body
input-service_bus_name = 'IArcade'.
input-saskey_value = 'cI1A9fzAvMaHAmQKMhCPTDJw1IEwraujCfl39e/cGmA='.
input-processrrfulfilmentforsaphana = 'processteammemberupdatesqueue'.
l_body = | \{ | &&
| "ServiceBusName":"{ input-service_bus_name }", | &&
| "SASKeyValue":"{ input-saskey_value }", | &&
| "processrrfulfilmentforsaphana":"{ input-
processrrfulfilmentforsaphana }" | &&
| \} |.
CALL METHOD lo_http_client->request->set_cdata
EXPORTING
data = l_body.
* fetching token
lo_rest_client->if_rest_client~set_request_header( EXPORTING iv_name =
'X-CSRF-Token' iv_value = 'Fetch' ).
lo_http_client->propertytype_accept_cookie =
if_http_client=>co_enabled.
lo_http_client->propertytype_logon_popup = lo_http_client->co_disabled.
*****
CALL METHOD lo_http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2.
FREE lo_http_client.
p_url =
'https://IArcade.servicebus.windows.net/processteammemberupdatesqueue/
messages?timeout=60'.
cl_http_client=>create_by_url(
EXPORTING url = p_url " oData service URL
IMPORTING client = lo_http_client
EXCEPTIONS OTHERS = 1 ).
*
* l_url =
'http://xmlns.lntinfotech.com/UNIFYEnterpriseDataModelLibrary/Enterprise/
HR/Employee/ImmigrationLanguageMaster'.
* l_url1 = 'http://schemas.xmlsoap.org/soap/envelope/'.
*l_data = '10662984'.
l_body = | \{ | &&
| "ServiceHeader" : " " , | &&
| "ImmigrationLanguageData" : \{ | &&
| "LanguageDetails" : \{ | &&
| "EMPID":"{ 1_1 }" , | &&
| "LANGUAGE_CODE" : " { 1_2 } " , | &&
| "READ" : " { l_3 } " , | &&
| "WRITE" : " { l_3 }" ,| &&
| "SPEAK" : "{ l_3 }" | &&
| \} | &&
| \} | &&
| \} |.
lo_http_client->propertytype_accept_cookie =
if_http_client=>co_enabled.
lo_http_client->propertytype_logon_popup = lo_http_client->co_disabled.
lo_http_client->send(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2 ). "send the http request
lo_http_client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3 ). "receive the response
CLEAR: w_http_return_code,w_http_error_descr.
lo_http_client->response->get_status( IMPORTING code =
w_http_return_code ).
lo_http_client->response->get_status( IMPORTING reason =
w_http_error_descr ).
CLEAR lv_result.
lv_result = lo_http_client->response->get_cdata( ).
FREE lo_http_client.
END-OF-SELECTION.