XML Reuqest, POST
data: lv_url type string.
if lo_client is not bound.
message `Bağlantı başarısız` type `E` raising conn_error.
endif.
changing lv_response.
call method lo_client->close .
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 = 4 ).
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`.
data: lv_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> ` &&
` </ServiceNameXYZ>` &&
` </soap:Body>` &&
`</soap:Envelope>`.
call method lo_client->request->set_cdata
exporting
data = lv_request_xml
offset = 0 .
* length = lv_length.
endform.
changing response.
" Send request
lo_client->send(
exceptions
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
others = 4 ).
" Catch result
lo_client->receive(
exceptions
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
others = 4 ).
" Catch data
response = lo_client->response->get_cdata( ).
endform.
changing chn_data type zxx_t_tablestruct .
data: lv_xstr_response type xstring.
data: XML_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.