2016 Feb 10 5:32 AM
Hi all,
I am using a java rest service to push SAP data but I am getting a http communication failure. What settings need to be done while making the http request. I tested the http connection from the report program RSHTTP20. Connection is established when the report program is run.
DATA lv_url TYPE string VALUE 'http://ip address/data/add'.
DATA lo_client TYPE REF TO if_http_client.
DATA lo_conv TYPE REF TO cl_abap_conv_in_ce.
DATA lv_response TYPE string.
DATA lo_split_res TYPE REF TO /saar/cldm_json_document..
cl_http_client=>create_by_url(
EXPORTING
url = lv_url
IMPORTING
client = lo_client
EXCEPTIONS
OTHERS = 4 ).
lo_client->request->set_method( if_http_request=>co_request_method_post ).
lo_client->request->set_content_type( content_type = 'application/json' ).
lo_client->request->append_cdata( data = gv_json ).
lo_client->send( ).
lo_client->receive( ).
lv_bin = lo_client->response->get_data( ).
lo_conv = cl_abap_conv_in_ce=>create( input = lv_bin ).
lo_conv->read( IMPORTING data = lv_response ).
thanks in advance
thanuja kb
2016 Feb 11 2:58 AM
2016 Feb 10 7:46 AM
Hi,
To verify your connection to the web Try something simple like:
*----------------------------------------------------------------------*
FORM test_02 .
DATA lv_url TYPE string VALUE 'http://httpbin.org/ip'.
DATA lo_client TYPE REF TO if_http_client. " HTTP Client Abstraction
DATA lo_conv TYPE REF TO cl_abap_conv_in_ce. " Code Page and Endian Conversion (External -> System Format)
DATA lv_response TYPE string.
cl_http_client=>create_by_url(
EXPORTING
url = lv_url
IMPORTING
client = lo_client
EXCEPTIONS
OTHERS = 4 ).
lo_client->send( ).
lo_client->receive( ).
DATA(lv_bin) = lo_client->response->get_data( ).
lo_conv = cl_abap_conv_in_ce=>create( input = lv_bin ).
lo_conv->read( IMPORTING data = lv_response ).
ENDFORM.
*----------------------------------------------------------------------*
2016 Feb 10 8:02 AM
Hi Eitan,
Connection is established with the url you have posted. But not with the url I am trying to post.
2016 Feb 11 2:58 AM
2016 Feb 11 9:24 AM
PLEASE CHECK HTTP port is there or not.
for that
tcode SMICM->goto->services
if http port is not there, then create port there only.
srveices->create like below.
seconds 15 are increase some moew seconds.
give port and http.
2016 Feb 11 9:25 AM
2016 Feb 16 6:13 AM