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

Simple HTTP Send / Receive does not Work

Former Member
0 Likes
1,998

Hello,

I am attempting to perform a simple HTTP Send/Receive using the SAP Interface IF_HTTP_CLIENT. For example to read a twitter feed.

I have no issues using a SICF entry for BSP pages such as   http://www.mysystemxxx.com:8000/sap/bc/bsp/sap/z_http/z_simple_http.xml to create some simple XML data, so internet connectivity is established..However when using ABAP to call out to the internet, I get communication errors when I attempt to receive data back...the error message is:

communication_error( receive )

code:    400  message:  ICM_HTTP_CONNECTION_FAILED

I attempted to use transaction SMICM (ICM monitor but cannot see any errors)...

Am I missing some setup and/or configuration to perform a call to the outside?

Thanks in advance for your reply..

Regards,

Steve


Sample HTTP program:

REPORT  z_http_example.

DATA: my_client TYPE REF TO if_http_client.

DATA: host_sf       TYPE string VALUE 'http://search.twitter.com/search.atom?q=jazz',
      uri           TYPE string VALUE 'http://search.twitter.com/search.atom?q=jazz',
      service_str   TYPE string VALUE '8000',
      timeout       TYPE i  VALUE 10,
      v_subrc       TYPE sysubrc,
      errortext     TYPE string. "used for error handling

START-OF-SELECTION.


  CALL METHOD cl_http_client=>create
    EXPORTING
      host               = host_sf
      service            = service_str
    IMPORTING
      client             = my_client
    EXCEPTIONS
      argument_not_found = 1
      internal_error     = 2
      plugin_not_active  = 3
      OTHERS             = 4.

* set http method GET
  CALL METHOD my_client->request->set_method(
    if_http_request=>co_request_method_get ).

* set request uri (/<path>[?<querystring>])
  cl_http_utility=>set_request_uri( request = my_client->request
                                 uri     = uri ).


* Send
  CALL METHOD my_client->send
    EXPORTING
      timeout                    = timeout
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3
      OTHERS                     = 4.
  IF sy-subrc <> 0.
    CALL METHOD my_client->get_last_error
      IMPORTING
        code    = v_subrc
        MESSAGE = errortext.
    WRITE: / 'communication_error( send )',
           / 'code: ', v_subrc, 'message: ', errortext.
    EXIT.
  ENDIF.

* receive
  CALL METHOD my_client->receive
    EXCEPTIONS
      http_communication_failure = 1
      http_invalid_state         = 2
      http_processing_failed     = 3
      OTHERS                     = 4.
  IF sy-subrc <> 0.
    CALL METHOD my_client->get_last_error
      IMPORTING
        code    = v_subrc
        MESSAGE = errortext.
    WRITE: / 'communication_error( receive )',
           / 'code: ', v_subrc, 'message: ', errortext.
    EXIT.
  ENDIF.

* close
  CALL METHOD my_client->close
    EXCEPTIONS
      http_invalid_state = 1
      OTHERS             = 2.

END-OF-SELECTION.

write: /1 'HTTP Call Complete!'.

1 REPLY 1
Read only

jane_cruz
Explorer
0 Likes
1,294

Hello,

When you use cl_http_utility=>set_request_uri

you need to pass proxy settings, if you dont want to do

you'll try remove this instruction.

Regards