Call web service in ABAP



Αξιολόγηση Χρήστη:  / 4
ΧειρότεροΚαλύτερο 
Λεπτομέρειες

The following ABAP program call a web service :

View source
report zcall_WS.
 
*------------------------------------------------------------------------------
*  www.developerpages.gr
*
*  Call web service
*------------------------------------------------------------------------------
 
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.


You have no rights to post comments

   
   

     

© Developerpages