Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Read Https website content using report program

former_member202253
Participant
0 Likes
1,064

Hi ,

I need your help experts. I need to validate website url and read its content. For example http://www.google.com.

I am able read non https url content but when I am trying to read content for https url my below code is not working like https://www.google.com its not working but url is validate. How do i read https website content without certificate download

Below is my program please suggest.

DATA: http_client TYPE REF TO if_http_client .

DATA: wf_string TYPE string ,

result TYPE string ,

r_str TYPE string .

DATA: result_tab TYPE TABLE OF string.

START-OF-SELECTION .

  CLEAR wf_string .

wf_string = 'https://www.google.com'.

  CALL METHOD cl_http_client=>create_by_url

    EXPORTING

      url                = wf_string

    IMPORTING

      client             = http_client

    EXCEPTIONS

      argument_not_found = 1

      plugin_not_active  = 2

      internal_error     = 3

      OTHERS             = 4.

  CALL METHOD http_client->send

    EXCEPTIONS

      http_communication_failure = 1

      http_invalid_state         = 2.

  CALL METHOD http_client->receive

    EXCEPTIONS

      http_communication_failure = 1

      http_invalid_state         = 2

      http_processing_failed     = 3.

  CLEAR result .

  result = http_client->response->get_cdata( ).

  REFRESH result_tab .

  SPLIT result AT cl_abap_char_utilities=>cr_lf INTO TABLE result_tab .

  LOOP AT result_tab INTO r_str.

    WRITE:/ r_str .

  ENDLOOP .

Thanks,

NJ

3 REPLIES 3
Read only

Former Member
0 Likes
590

Hi Nikhilesh,

check this out. The correct code should look like this:

DATA: http_client TYPE REF TO if_http_client .

call method cl_http_client=>create

  exporting

    host          = 'www.google.com'

    service       = '443'

    scheme        = '2'

  importing

    client        = http_client.

Regards, Michael

Read only

0 Likes
590

Hi Michael,

Thanks for the reply.

I have tried the given solution by replacing CALL METHOD cl_http_client=>create_by_url with

call method cl_http_client=>create

  exporting

    host          = 'www.google.com'

    service       = '443'

    scheme        = '2'

  importing

    client        = http_client.

But still I am getting same error  "http_communication_failure"

CALL METHOD http_client->receive

    EXCEPTIONS

      http_communication_failure = 1

      http_invalid_state         = 2

      http_processing_failed     = 3.

Please suggest.

Thanks

NJ

Read only

0 Likes
590

Hi Nikhilesh,

ok, maybe it will work, if check out the following:

Wouter Venhuizen describes a solution for this problem right here. Try to follow his instructions step by step. 


When you still getting the error-message "http_communication_failure", try to set up the HTTP(S) destination in SM59 and test it from there. After that, you can try to create your http_client with the method CREATE_BY_DESTINATION.

Good luck!!

Michael