XML Reuqest, POST


 datalo_client type ref to if_http_client.

  datalv_url   type string.

  lv_url `http://ws.******.com/v1/report.php?op=ServiceName`   .
perform create_client using lv_url
                     changing lo_client.
  if lo_client is not bound.
    message `Bağlantı başarısız` type `E` raising conn_error.
  endif.


  perform send_client_request   using lo_client 
                               changing lv_response.

  call method lo_client->close .


perform get_data_xml   using      lv_response
                             changing      et_report
                                            .







*&---------------------------------------------------------------------*
*&      Form  CREATE_CLIENT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_URL  text
*      -->P_GV_TXLEN  text
*      <--P_GO_CLIENT  text
*----------------------------------------------------------------------*
form create_client using p_url type string 
        changing lo_client type ref to if_http_client.

  " Create client
  cl_http_client=>create_by_url(
    exporting
      url                p_url
    importing
      client             lo_client
    exceptions
      argument_not_found 1
      plugin_not_active  2
      internal_error     3
      others             ).

  call method lo_client->set_compression
    exporting
      options                  =  IF_HTTP_CLIENT=>co_compress_none.

*  lo_client->PROPERTYTYPE_ACCEPT_COMPRESS =

  call method lo_client->request->set_compression
    exporting
      options                  =  IF_HTTP_CLIENT=>co_compress_none
*    exceptions
*      compression_not_possible = 1
*      others                   = 2
          .
  if sy-subrc <> 0.
*   Implement suitable error handling here
  endif.


  call method lo_client->request->set_header_field
    exporting
      name  `~request_method`
      value `POST`.

 
  call method lo_client->request->set_header_field
    exporting
      name  `Accept-Encoding`
      value `gzip,deflate`.

  call method lo_client->request->set_header_field
    exporting
      name  `Content-Type`
      value `text/xml`.
*      value = `application/x-www-form-urlencoded`.



  call method lo_client->request->set_header_field
    exporting
      name  `Connection`
      value `Keep-Alive`.


 

datalv_request_xml type string.

lv_request_xml =
`<?xml version="1.0" encoding="utf-8" ?>` &&
`<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"` &&
`               xmlns:xsd="http://www.w3.org/2001/XMLSchema"` &&
`               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> ` &&
`  <soap:Body>` &&
`   <ServiceNameXYZ xmlns="http://www.sapurlus.com/"> ` &&
`     <Username>ValueUsername</Username> ` &&
`     <Userpass>ValuePassword</Userpass> ` && 

`     <InputEmpty>ValuePassword</InputEmpty> ` && 
`     <InputNull/> ` &&   "Null Input
`   </ServiceNameXYZ>` &&
`  </soap:Body>` &&
`</soap:Envelope>`.
 
 

    call method lo_client->request->set_cdata
    exporting
      data   lv_request_xml
      offset .
*      length = lv_length.

  
endform.


form send_client_request  using lo_client type ref to if_http_client 
                       changing response.
 
  " Send request
  lo_client->send(
    exceptions
      http_communication_failure 1
      http_invalid_state         2
      http_processing_failed     3
      others                     ).

  " Catch result
  lo_client->receive(
    exceptions
      http_communication_failure 1
      http_invalid_state         2
      http_processing_failed     3
      others                     ).

  " Catch data
  response lo_client->response->get_cdata).

endform.



form get_data_xml    using      prm_response type string
                           changing   chn_data  type zxx_t_tablestruct .
datalv_xstr_response      type xstring.
dataXML_TABLE  type TABLE OF  SMUM_XMLTB,
      RETURN  type table of   BAPIRET2 .

        call function `SCMS_STRING_TO_XSTRING`
          exporting
            text   prm_response
          importing
            buffer lv_xstr_response.


 call function `SMUM_XML_PARSE`
   exporting
     xml_input       lv_xstr_response
   tables
     xml_table       XML_TABLE
     return          RETURN
           .


ENDFORM.