Skip to Content
0
Former Member
May 29, 2009 at 10:40 PM

Error when trying to run IF_HTTP_CLIENT->RECEIVE()

6134 Views

Hi experts,

I nedd to retrieve a file from any given URL (i.e. http://www.google.com/images/nav_logo4.png) and save it.

I thought that calling if_http_client->receive() method would be ideal, but when I call it I´m always getting exception 'http_communication_failure'.

Transaction SMICM looks good...what else should I check?

I give my source code:

data: client  type ref to if_http_client,
      content type string.


****Create the HTTP client
cl_http_client=>create_by_url( exporting url = 'http://www.google.com/images/nav_logo4.png' importing client = client exceptions others = 1 ).


****Set the Request type to GET
  client->request->set_header_field( name  = '~request_method'
                             value = 'GET' ).               "#EC *

****Make the call
  client->send( ).

****Receive the Response Object
  call method client->receive
    exceptions
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3
      others                     = 4.

****Get the response content in Character format
  content = client->response->get_cdata( ).

Thanks for your help.

Regards,

Federico