IF_HTTP_EXTENSION
IF_HTTP_EXTENSION~HANDLE_REQUEST
相关变量定义
DATA: it_headers TYPE tihttpnvp,
wa_headers TYPE ihttpnvp.
获取请求方法 GET/POST
DATA(v_method) = server->request->get_method( ).
获取传输内容 postman => raw
recieve = server->request->if_http_entity~get_cdata( ).
返回传输内容
server->response->set_cdata( EXPORTING data = return ).
获取抬头内容 postman => Headers
server->request->get_header_fields( CHANGING fields = it_headers ).
获取字段内容 postman => Params
server->request->get_form_fields( CHANGING fields = it_fields ).
JSON 解析
CALL METHOD /ui2/cl_json=>deserialize
EXPORTING
json = wa_fields-value
pretty_name = /ui2/cl_json=>pretty_mode-camel_case
CHANGING
data = gs_data.
CALL METHOD /ui2/cl_json=>serialize
EXPORTING
data = wa_return
RECEIVING
r_json = v_return.
XML 解析
DATA: r_conv_out TYPE REF TO cl_abap_conv_out_ce,
xml_input TYPE xstring,
it_xml_table TYPE STANDARD TABLE OF smum_xmltb,
it_return TYPE STANDARD TABLE OF bapiret2.
r_conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' ).
r_conv_out->convert( EXPORTING data = gs_data-reqdata IMPORTING buffer = xml_input ).
CALL FUNCTION 'SMUM_XML_PARSE'
EXPORTING
xml_input = xml_input
TABLES
xml_table = it_xml_table
return = it_return.
结论
以上内容源于馒头日常工作中的记录,如有新内容的添加,将持续更新。
点赞收藏关注不迷路
|