2010 Jul 16 11:40 AM
Hi,
The need is to read a file from a URL and parse it. The class CL_HTTP_REQUEST and CL_IXML is supposed to be used for the same.
The URL is like https://abc.com/def . when we access the URL a txt file is read in the browser. we wish to programatically read this file in ABAP.
It will be very much appreciated if any of you can share with us in case you have done something like this.
Regards,
Madhura
2010 Jul 16 2:29 PM
Hello Lobo,
you can refer to the code below:
INITIALIZATION.
DATA : url_ TYPE string,
http_client TYPE REF TO if_http_client,
xbuffer TYPE xstring.
START-OF-SELECTION.
url_ = 'http://bluepages.ibm.com'.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = url_
IMPORTING
client = http_client
EXCEPTIONS
OTHERS = 1.
CALL METHOD http_client->request->set_header_field
EXPORTING
name = '~request_uri'
value = '/BpHttpApis/slaphapi?ibmperson/((sn=Chow)(c=cn)).list/byxml'.
CALL METHOD http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
WRITE / sy-subrc.
CALL METHOD http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
IF sy-subrc <> 0.
WRITE / sy-subrc.
EXIT.
ENDIF.
END-OF-SELECTION.
xbuffer = http_client->response->get_data( ).
WRITE : / xbuffer.
Best Regards.
Jerry
2010 Jul 16 2:29 PM
Hello Lobo,
you can refer to the code below:
INITIALIZATION.
DATA : url_ TYPE string,
http_client TYPE REF TO if_http_client,
xbuffer TYPE xstring.
START-OF-SELECTION.
url_ = 'http://bluepages.ibm.com'.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = url_
IMPORTING
client = http_client
EXCEPTIONS
OTHERS = 1.
CALL METHOD http_client->request->set_header_field
EXPORTING
name = '~request_uri'
value = '/BpHttpApis/slaphapi?ibmperson/((sn=Chow)(c=cn)).list/byxml'.
CALL METHOD http_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
WRITE / sy-subrc.
CALL METHOD http_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3.
IF sy-subrc <> 0.
WRITE / sy-subrc.
EXIT.
ENDIF.
END-OF-SELECTION.
xbuffer = http_client->response->get_data( ).
WRITE : / xbuffer.
Best Regards.
Jerry
2010 Jul 17 6:26 AM
Hi Jerry,
Thanks for the response. Was helpful.
But the url is https, and i am getting Native SSL error. Any idea how to get this solved.
I added the following calls in addition to what you have specified above
http_client->send_sap_logon_ticket( ).
http_client->request->set_header_field( EXPORTING name = '~request_method' "#EC NOTEXT
value = 'GET' ).
cl_http_utility=>set_request_uri( request = http_client->request
uri = url_ ).
http_client->response->get_status( IMPORTING code = lv_status
reason = lv_reason ).
Also specified the sap_username and sap_client in the create_by_url() method.
But the lv_status = 500 and lv_reason = Native SSL error.
Regards,
Madhura