TYPES : BEGIN OF ty_file,
text TYPE string,
END OF ty_file.
DATA : lt_file TYPE TABLE OF ty_file,
ls_file TYPE ty_file.
ls_file-text = '<soap> '.
append ls_file to lt_file.
ls_file-text = '<text1> Testing text </text1> '.
append ls_file to lt_file.
ls_file-text = '<text2> Testing Data 2 </text2> '.
append ls_file to lt_file.
ls_file-text = '</soap> '.
append ls_file to lt_file.
CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = 'https://sample.url.link?WSDL'
"Sample link but link ending with WSDL and starting with https.
IMPORTING
client = o_http_client1
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
pse_not_found = 4
pse_not_distrib = 5
pse_errors = 6
OTHERS = 7.
IF sy-subrc <> 0.
ENDIF.
o_http_client1->propertytype_logon_popup = o_http_client1->co_disabled.
o_http_client1->propertytype_accept_cookie = if_http_client=>co_enabled.
o_http_client1->request->set_method( 'POST' ).
"Set Header fields
CALL METHOD o_http_client1->request->set_header_field
EXPORTING
name = '~request_method'
value = 'POST'.
CALL METHOD o_http_client1->request->set_header_field
EXPORTING
name = 'Content-Type'
value = 'text/xml'.
CALL METHOD o_http_client1->request->set_header_field
EXPORTING
name = 'Connection'
value = 'keep-alive'.
DATA(lo_http_request) = o_http_client1->request.
DATA : lv_str TYPE string.
LOOP AT lt_file INTO DATA(wa).
CONCATENATE lv_str wa-text INTO lv_str.
CLEAR wa.
ENDLOOP.
CALL METHOD lo_http_request->append_cdata
EXPORTING
data = lv_str.
"Send data
CALL METHOD o_http_client1->send
EXCEPTIONS
http_communication_failure = 1 " Communication Error
http_invalid_state = 2 " Invalid state
http_processing_failed = 3 " Error when processing method
http_invalid_timeout = 4 " Invalid Time Entry
OTHERS = 5.
DATA errortext TYPE string.
CALL METHOD o_http_client1->get_last_error
IMPORTING
code = subrc
message = errortext.
CALL METHOD o_http_client1->receive
EXCEPTIONS
http_communication_failure = 1 " Communication Error
http_invalid_state = 2 " Invalid state
http_processing_failed = 3 " Error when processing method
OTHERS = 4.
"Get the response
CALL METHOD o_http_client1->response->get_status
IMPORTING
code = gv_http_status_code " HTTP Status Code
reason = gv_http_status_text. " HTTP status description
DATA(result) = o_http_client1->response->get_cdata( ).
IF result IS NOT INITIAL.
cl_abap_browser=>show_html(
EXPORTING
title = 'Status'
size = cl_abap_browser=>medium
modal = abap_true
html_string = result
printing = abap_false
format = cl_abap_browser=>landscape
position = cl_abap_browser=>topleft
context_menu = abap_false
check_html = abap_true
dialog = abap_true
).
Endif.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 | |
3 |