Skip to Content
0
Former Member
Mar 29, 2012 at 02:59 PM

Simple HTTP Send / Receive does not Work

707 Views

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!'.