2013 Apr 22 1:06 PM
Hi,
I have a requirement where I have to read the data from URL Link. Below is the code i have written
The issue is when i used the below mentioned URL my code was working.
But when i used a link which has User name and password which is encrypted the code is not working.
Kindly provide me a solution.
START-OF-SELECTION .
* Build the url string based on input
CONCATENATE 'http://www.thomas-bayer.com/sqlrest/CUSTOMER/19'
p_cnt
INTO http_url .
* Creation of new IF_HTTP_Client object
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = http_url
IMPORTING
client = http_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4.
CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
EXPORTING
NAME = 'Authorization'
VALUE = 'Basic dmthbm5h'.
http_client->request->set_header_field( name = '~request_method'
value = 'POST' ).
* Send the request
http_client->send( ).
CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
EXPORTING
NAME = 'Accept'
Value = 'text/xml'.
CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
EXPORTING
NAME = 'Content-Type'
VALUE = 'text/xml; charset=utf-8'.
* Reterive the result
CALL METHOD http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
g_str = http_client->response->get_cdata( ).
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
text = g_str
IMPORTING
buffer = g_xmldata
EXCEPTIONS
failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE 'Error in the XML file' TYPE 'E'.
ENDIF.
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = g_xmldata
TABLES
xml_table = g_t_xml_info
return = g_t_return
EXCEPTIONS
OTHERS = 0.
Regards.
2013 Apr 22 3:07 PM