当前位置:网站首页>ABAP-发布Restful服务
ABAP-发布Restful服务
2022-06-30 16:33:00 【InfoQ】
创建实施类
事务代码:SE24

设置需要实现的接口:IF_HTTP_EXTENSION

实现实施类
主要实现的方法:IF_HTTP_EXTENSION~HANDLE_REQUEST

实现代码
METHOD if_http_extension~handle_request.
TYPES: BEGIN OF ty_input,
rows TYPE i,
END OF ty_input.
DATA: l_input TYPE ty_input.
DATA: i_string TYPE string,
o_string TYPE string.
"Get Importing Json
i_string = server->request->if_http_entity~get_cdata( )."
"Deserialize Json to data
/ui2/cl_json=>deserialize( EXPORTING json = i_string CHANGING data = l_input ).
"Get Return Data
SELECT *
FROM sflight
INTO TABLE @DATA(lt_sflight)
UP TO @l_input-rows ROWS.
"Serialize Data to Json
o_string = /ui2/cl_json=>serialize( lt_sflight ).
"Set the return data format
CALL METHOD server->response->if_http_entity~set_content_type
EXPORTING
content_type = 'application/json'.
"set exporting data
server->response->set_cdata(
EXPORTING
data = o_string ).
ENDMETHOD.定义RESTful服务
事务代码:SICF,新建子元素


设置服务处理器

设置默认登录信息(如果不设置,访问数据则需要SAP账号认证)

激活服务


测试服务
直接测试服务是否可访问


使用第三方工具APIPost SoaUI测试
设置Json查询数据

设置SAP账号认证(SICF未设置默认认证账号时使用)

发送请求,拿到返回数据

边栏推荐
- 高等数学(第七版)同济大学 总习题一 个人解答
- Rexroth hydraulic control check valve z2s10-1-3x/
- Cloud practice of key business migration of Internet of things by well-known Internet housing rental service companies
- 【义修换届大礼包】
- 5G业务正式商用,属于广电的机会在哪?
- 开发那些事儿:如何在视频中添加文字水印?
- 数据中心的能耗焦虑, 到底有没有最优解?
- 万卷书 - 欧洲的门户 [The Gates of Europe]
- 万卷书 - 书单整理 [01]
- DeFi借贷协议机制对比:Euler、Compound、Aave和Rari Capital
猜你喜欢

Rexroth hydraulic control check valve z2s10-1-3x/

5G商用三年,未来创新何去何从?

4年工作经验,多线程间的5种通信方式都说不出来,你敢信?

k线图精解与实战应用技巧(见位进场)

Horizontal visual error effect JS special effect code

零基础也能做Apple大片!这款免费工具帮你渲染、做特效、丝滑展示

Solution: STM32 failed to parse data using cjson

Key to understanding the trend of spot Silver

Daily question brushing record (IX)

Course design for the end of the semester: product sales management system based on SSM
随机推荐
Parker proportional overflow valve rs10r35s4sn1jw
MOOG servo valve d661-4577c
Thinking on large file processing (upload, download)
Compile and generate busybox file system
Servlet operation principle_ API details_ Advanced path of request response construction (servlet_2)
【义修换届大礼包】
[C language] detailed explanation of threads - multi threads for collaborative operation
构建基本buildroot文件系统
In the past, the industrial Internet we knew only appeared as a substitute for the consumer Internet
腾讯云的一场硬仗
编写C语言的最简单小程序Hello world
Exch: database integrity checking
Horizontal visual error effect JS special effect code
开发那些事儿:如何在视频中添加文字水印?
New skill: accelerate node through code cache JS startup
[proteus simulation] Arduino uno uses 74ls148 to extend interrupt
数据中心的能耗焦虑, 到底有没有最优解?
5g has been in business for three years. Where will innovation go in the future?
浅析搭建高速公路视频监控平台的建设方案及必要性
[BJDCTF2020]The mystery of ip|[CISCN2019 华东南赛区]Web11|SSTI注入