当前位置:网站首页>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未设置默认认证账号时使用)

发送请求,拿到返回数据

边栏推荐
- Mo Tianlun salon | Tsinghua qiaojialin: Apache iotdb, originated from Tsinghua, is building an open source ecological road
- Exch:Exchange Server 2013 即将终止支持
- 联想“双平台”运维解决方案 助力智慧医疗行业智慧管理能力全面提升
- How to write a technical proposal
- 自旋锁探秘
- Develop those things: how to add text watermarks to videos?
- Canvas mouse control gravity JS effect
- svg实现的订票UI效果
- .NET ORM框架HiSql实战-第一章-集成HiSql
- Development details of NFT casting trading platform
猜你喜欢
随机推荐
Rexroth hydraulic control check valve z2s10-1-3x/
TFTP下载kernel,nfs挂载文件系统
分享 5 大常用的特征选择方法,机器学习入门必看!!!
Nouvelle version de shangdingyun | la fonction favorite est en ligne pour répondre aux besoins d'utilisation personnelle
Servlet运行原理_API详解_请求响应构造进阶之路(Servlet_2)
Radio and television 5g officially set sail, attracting attention on how to apply the golden band
Mo Tianlun salon | Tsinghua qiaojialin: Apache iotdb, originated from Tsinghua, is building an open source ecological road
Exch: database integrity checking
TFTP download kernel, NFS mount file system
6 张图带你搞懂 TCP 为什么是三次握手?
Plane intersection and plane equation
The gates of Europe
Apache 解析漏洞(CVE-2017-15715)_漏洞复现
流批一体在京东的探索与实践
leetcode:1042. Do not plant flowers adjacent to each other [randomly fill in qualified + no contradiction will be formed behind + set.pop]
splitting. JS password display hidden JS effect
[proteus simulation] Arduino uno uses 74ls148 to extend interrupt
【网易云信】播放demo构建:无法将参数 1 从“AsyncModalRunner *”转换为“std::nullptr_t”**
万卷书 - 欧洲的门户 [The Gates of Europe]
生成对抗网络,从DCGAN到StyleGAN、pixel2pixel,人脸生成和图像翻译。









