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

Consuming Rest based Https service in abap.

Former Member
0 Likes
1,139

Hi ,

I am trying to consume an external rest service in ABAP.

I am having an issue with the IF_HTTP_CLIENT~RECEIVE method.

It hangs indefinitely. If you have encountered same issue please help.

CLEAR w_string .
  w_string = "https//:XXXx.com"

  CALL METHOD cl_http_client=>create_by_url
  EXPORTING
  url = w_string
  IMPORTING
  client = http_client
  EXCEPTIONS
  argument_not_found = 1
  plugin_not_active = 2
  internal_error = 3
  OTHERS = 4.
  CALL METHOD http_client->send
  EXCEPTIONS
  http_communication_failure = 1
  http_invalid_state = 2.
  CALL METHOD http_client->receive
  EXCEPTIONS
  http_communication_failure = 1
  http_invalid_state = 2
  http_processing_failed = 3.
5 REPLIES 5
Read only

FredericGirod
Active Contributor
0 Likes
764

Hi,

is it a webservice ?

regards

fred

Read only

0 Likes
764

Hi,

yes it is a restful webservice.

Read only

0 Likes
764

So you have create all the necessary data : SOAMANGER / LPCONFIG / ....  

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

*   Form P_SEND_FILE.                                                 *

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

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

form p_send_file.

   data : ls_result  type zaipwsimport_fichier_soap_out ,

          ls_send    type zaipwsimport_fichier_soap_in ,

          ls_sys_exception type ref to cx_ai_system_fault ,

          lv_string  type string ,

          lv_xstring type xstring .

* Créé le string.

   concatenate lines of gt_tab into lv_string separated by space.

* Créé le XString

   call function 'SCMS_STRING_TO_XSTRING'

     exporting

       text   = lv_string

     importing

       buffer = lv_xstring

     exceptions

       failed = 1

       others = 2.

   ls_send-content       = lv_xstring.

   ls_send-str_directory = 'The directory'.

   ls_send-str_file_name = 'The file name'.

   try.

       create object oo_proxy

         exporting

           logical_port_name = 'Fxxxxx_HTTPS_002'. " 'TxxxxxxIQ'.

     catch cx_ai_system_fault into ls_sys_exception.

       if ls_sys_exception is not initial.

         write : /1 'System fault occured' ,

                    ls_sys_exception->code ,

                    ls_sys_exception->errortext .

       endif.

   endtry.

   check oo_proxy is not initial.

   try.

       call method oo_proxy->import_document

         exporting

           import_fichier1 = ls_send

         importing

           import_fichier  = ls_result.

     catch cx_ai_system_fault into ls_sys_exception.

       if ls_sys_exception is not initial.

         write : /1 'System fault occured' ,

                    ls_sys_exception->code ,

                    ls_sys_exception->errortext .

       endif.

     catch cx_ai_application_fault .

   endtry.

endform.                     " P_SEND_FILE.

Read only

0 Likes
764

Hi Frederic,

It is not a soap service. It is a rest service.

Read only

0 Likes
764

I never play with this, but I see someone have already post something with this :

regards

Fred