gpt4 book ai didi

HTTPS 通信失败 ABAP

转载 作者:可可西里 更新时间:2023-11-01 17:05:50 25 4
gpt4 key购买 nike

我正在开发一个应该连接到两个网络应用程序的应用程序。第一个 Web 应用程序已完成 (http://example.com)。不幸的是,第二个使用 HTTPS 的 Web 应用程序 (https://example.com) 抛出了这个错误:Http_Communication_Failure SY-SUBRC = 1

这是我的程序:

FORM CHEKCV_LOG_PASS.

DATA : lv_flag TYPE flag,
iv_user TYPE CHAR20,
iv_pass TYPE CHAR20.

iv_user = 'username'.
iv_pass = 'Pw1-a83-333'.

IF sy-subrc IS NOT INITIAL.

ENDIF.


CONSTANTS: c_type_get VALUE 0,
c_type_post VALUE 1.

TYPES: BEGIN OF ty_parameter,
name TYPE string,
type TYPE char1,
value TYPE string,
END OF ty_parameter.

DATA ls_parameter TYPE ty_parameter.
DATA lt_parameters TYPE TABLE OF ty_parameter.
DATA lt_fields TYPE tihttpnvp.
DATA lv_url TYPE string.
DATA SOAP_ACTION TYPE string.
DATA lv_uri TYPE string.
DATA lv_value TYPE string.
DATA lv_name TYPE string.
DATA lt_html TYPE TABLE OF string.

DATA: lo_client TYPE REF TO if_http_client,
lc_content TYPE string,
xcontent_clear TYPE xstring,
contentencoding TYPE string.

DATA ls_field TYPE ihttpnvp.
DATA lc_url TYPE string.
DATA lv_user TYPE zvrs_veyes_user.
DATA lv_pass TYPE char32.

lv_user = iv_user.
lv_pass = iv_pass.
ls_parameter-name = '_username'.
ls_parameter-value = lv_user.
ls_parameter-type = c_type_post.
APPEND ls_parameter TO lt_parameters.
CLEAR ls_parameter.
ls_parameter-name = '_password'.
ls_parameter-value = lv_pass.
ls_parameter-type = c_type_post.
APPEND ls_parameter TO lt_parameters.
CLEAR ls_parameter.

LOOP AT lt_parameters INTO ls_parameter.
IF ls_parameter-type = c_type_post.
ls_field-name = ls_parameter-name.
ls_field-value = ls_parameter-value.
APPEND ls_field TO lt_fields.
ELSEIF ls_parameter-type = c_type_get.
IF lv_url = ''.
CONCATENATE '?' ls_parameter-name '=' ls_parameter-value
INTO lv_url.
ELSE.
CONCATENATE lv_url '&' ls_parameter-name '=' ls_parameter-value
INTO lv_url.
ENDIF.
ENDIF.
ENDLOOP.

lc_url = 'https://Example.com/login_check'.
CONCATENATE lc_url lv_url INTO lv_url.

CALL METHOD cl_http_client=>create_by_url
EXPORTING
url = lv_url
IMPORTING
client = lo_client
EXCEPTIONS
OTHERS = 1.
IF sy-subrc IS NOT INITIAL.
EXIT.
ENDIF.
CALL METHOD lo_client->request->set_header_field
EXPORTING
name = '~request_method'
value = 'POST'.
******************************************************************

******************************************************************
LOOP AT lt_fields INTO ls_field.
lo_client->request->if_http_entity~set_form_field(
name = ls_field-name value = ls_field-value ).
ENDLOOP.

CALL METHOD lo_client->request->set_header_field
EXPORTING
name = '~request_uri'
value = lv_url.
lo_client->propertytype_accept_cookie = 1.


CALL METHOD lo_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
http_invalid_timeout = 4
OTHERS = 5.
IF sy-subrc <> 0.
ENDIF.

CALL METHOD lo_client->receive
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
IF sy-subrc IS NOT INITIAL.

EXIT.
ENDIF.
CALL METHOD lo_client->request->set_header_field
EXPORTING
name = '~request_method'
value = 'GET'.
CALL METHOD lo_client->request->set_header_field
EXPORTING
name = '~request_uri'
value = lc_url.
CALL METHOD lo_client->send
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
http_invalid_timeout = 4
OTHERS = 5.
IF sy-subrc <> 0.
ENDIF.

CALL METHOD lo_client->receive *HERE IS THE PROBLEME
EXCEPTIONS
http_communication_failure = 1
http_invalid_state = 2
http_processing_failed = 3
OTHERS = 4.
IF sy-subrc IS NOT INITIAL.

EXIT.
ENDIF.
lc_content = lo_client->response->get_cdata( ).

endform.

最佳答案

检查系统变量 SY-MSGxx 以获得有关实际问题的更多信息。最可能的原因:服务器证书未由 SAP 系统配置为信任的任何 CA 签名。 You might have to add the server and/or CA certificates to the PSE.警告:除非您知道自己在做什么并且已与您的基础管理员/信息安全官员明确这一点,否则不要这样做,否则您可能最终会在关键系统中打开安全漏洞。

关于HTTPS 通信失败 ABAP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43996153/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com