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

http communication failure

Former Member
0 Likes
8,451

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

1 ACCEPTED SOLUTION
Read only

rosenberg_eitan
Active Contributor
0 Likes
4,686

Hi,

Check this post (fresh....)

By

Re: ABAP CL_HTTP_CLIENT REST JSON issue

Regards.

6 REPLIES 6
Read only

rosenberg_eitan
Active Contributor
0 Likes
4,686

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.

*----------------------------------------------------------------------*

Read only

0 Likes
4,686

Hi Eitan,

      Connection is established with the url you have posted. But not with the url I am trying to post.

Read only

rosenberg_eitan
Active Contributor
0 Likes
4,687

Hi,

Check this post (fresh....)

By

Re: ABAP CL_HTTP_CLIENT REST JSON issue

Regards.

Read only

former_member241258
Active Participant
0 Likes
4,686

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.

Read only

former_member241258
Active Participant
0 Likes
4,686

Read only

Former Member
0 Likes
4,686

thanks alot everyone.