Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

call webservice from abap

Hello,

I use the following code to call web service from abap, but in the method "http_client->receive"  i see "http_communication_failure = 1" .

this is the code:

DATA: SMS_TEXT       TYPE STRING,
       SMS_TEXT_UTF   TYPE STRING,
       SEND_STRING    TYPE STRING.

DATA: w_string TYPE string ,
       w_result TYPE string ,
       r_str    TYPE string .

DATA: result_tab TYPE TABLE OF string.

DATA: http_client    TYPE REF TO if_http_client.

SEND_STRING = 'http://www.currencyserver.de/webservice/currencyserverwebservice.asmx/getDollarValue?provider=AVERAGE&currency=EUR'.

CALL METHOD cl_http_client=>create_by_url
   EXPORTING
     url                = SEND_STRING
   IMPORTING
     client             = http_client
   EXCEPTIONS
     argument_not_found = 1
     plugin_not_active  = 2
     internal_error     = 3
     others             = 4.

if sy-subrc = 0.
   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.
   if sy-subrc = 0.

     w_result = http_client->response->get_cdata( ).
     REFRESH result_tab .
     SPLIT w_result AT cl_abap_char_utilities=>cr_lf INTO TABLE result_tab .
     loop at result_tab into w_result.
       write :/ w_result.
     endloop.
   endif.
endif.




Any Idea?


thanks.

Ouail.

Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question