FUNCTION z_http_url.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(IV_URL) TYPE CSEQUENCE
*" EXPORTING
*" REFERENCE(EV_RESPONSE) TYPE CSEQUENCE
*" REFERENCE(EO_RESPONSE) TYPE REF TO IF_HTTP_RESPONSE
*" REFERENCE(EV_CODE) TYPE SYSUBRC
*" REFERENCE(EV_MESSAGE) TYPE STRING
*"----------------------------------------------------------------------
* URL 을 입력 받아서 http 통신하고 응답 받은 내용은 string 으로 반환한다.
DATA: lo_client TYPE REF TO if_http_client,
lv_url TYPE string.
CHECK: iv_url IS NOT INITIAL.
lv_url = iv_url.
FIND REGEX '^https?://' IN lv_url IGNORING CASE.
IF sy-subrc <> 0.
CONCATENATE 'http://' lv_url INTO lv_url.
ENDIF.
cl_http_client=>create_by_url(
EXPORTING
url = lv_url
IMPORTING
client = lo_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4
).
CHECK: sy-subrc EQ 0.
lo_client->send(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
http_invalid_timeout = 4
OTHERS = 5
).
* CHECK: sy-subrc EQ 0.
IF sy-subrc <> 0.
lo_client->get_last_error(
IMPORTING
code = ev_code
message = ev_message
).
ENDIF.
lo_client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4
).
* CHECK: sy-subrc EQ 0.
IF sy-subrc <> 0.
lo_client->get_last_error(
IMPORTING
code = ev_code
message = ev_message
).
ENDIF.
IF lo_client->response IS NOT INITIAL.
eo_response = lo_client->response.
ev_response = lo_client->response->get_cdata( ).
ENDIF.
ENDFUNCTION.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" REFERENCE(IV_URL) TYPE CSEQUENCE
*" EXPORTING
*" REFERENCE(EV_RESPONSE) TYPE CSEQUENCE
*" REFERENCE(EO_RESPONSE) TYPE REF TO IF_HTTP_RESPONSE
*" REFERENCE(EV_CODE) TYPE SYSUBRC
*" REFERENCE(EV_MESSAGE) TYPE STRING
*"----------------------------------------------------------------------
* URL 을 입력 받아서 http 통신하고 응답 받은 내용은 string 으로 반환한다.
DATA: lo_client TYPE REF TO if_http_client,
lv_url TYPE string.
CHECK: iv_url IS NOT INITIAL.
lv_url = iv_url.
FIND REGEX '^https?://' IN lv_url IGNORING CASE.
IF sy-subrc <> 0.
CONCATENATE 'http://' lv_url INTO lv_url.
ENDIF.
cl_http_client=>create_by_url(
EXPORTING
url = lv_url
IMPORTING
client = lo_client
EXCEPTIONS
argument_not_found = 1
plugin_not_active = 2
internal_error = 3
OTHERS = 4
).
CHECK: sy-subrc EQ 0.
lo_client->send(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
http_invalid_timeout = 4
OTHERS = 5
).
* CHECK: sy-subrc EQ 0.
IF sy-subrc <> 0.
lo_client->get_last_error(
IMPORTING
code = ev_code
message = ev_message
).
ENDIF.
lo_client->receive(
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4
).
* CHECK: sy-subrc EQ 0.
IF sy-subrc <> 0.
lo_client->get_last_error(
IMPORTING
code = ev_code
message = ev_message
).
ENDIF.
IF lo_client->response IS NOT INITIAL.
eo_response = lo_client->response.
ev_response = lo_client->response->get_cdata( ).
ENDIF.
ENDFUNCTION.
댓글 3
-
oracleuser
2016.12.21 09:07
-
oracleuser
2016.12.22 19:52
해당 링크는 이미 찾아서 진행중이었습니다.
문제는 샘플 프로그램에 문제가 있었고
해당 사항은 오늘 새벽에
몇가지 소스를 짜집기 하다가 해결 했습니다.
답변 감사 드립니다. -
대략나
2016.12.22 18:11
HTTPS를 사용하려면 SSL 기능을 켜 줘야 합니다. 서버에 약간 설치 및 세팅이 필요합니다.
아래 글을 참고하세요.
https://blogs.sap.com/2006/09/29/setup-data-encryption-between-rfc-client-and-web-as-abap-with-snc/
잘 안되네요
SMICM에 해줘야 하는것 아닌가까지 확인 좀 하다
접었네요