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

发送请求,拿到返回数据

边栏推荐
- MIT science and Technology Review released the list of innovators under the age of 35 in 2022, including alphafold authors, etc
- 自旋锁探秘
- 【剑指Offer】53 - I. 在排序数组中查找数字 I
- 阿里云ECS导入本地,解决部署的问题
- Thinking on large file processing (upload, download)
- Parker Parker sensor p8s-grflx
- 联想“双平台”运维解决方案 助力智慧医疗行业智慧管理能力全面提升
- 同济、阿里的CVPR 2022最佳学生论文奖研究了什么?这是一作的解读
- Exch:exchange server 2013 is about to end support
- MOOG servo valve d661-4577c
猜你喜欢

如何写一个技术方案

阿里云ECS导入本地,解决部署的问题

Key to understanding the trend of spot Silver

Development: how to install offline MySQL in Linux system?

Plane intersection and plane equation
![leetcode:787. The cheapest transfer flight in station K [k-step shortest path + DFS memory + defaultdict (dict)]](/img/28/78e2961877776ca3dfcba5ee7e35d2.png)
leetcode:787. The cheapest transfer flight in station K [k-step shortest path + DFS memory + defaultdict (dict)]

Fragmentary knowledge points of MySQL

Exploration and practice of "flow batch integration" in JD
![[Netease Yunxin] playback demo build: unable to convert parameter 1 from](/img/6e/41e1eafd4c863c9e5f3a545b69a257.png)
[Netease Yunxin] playback demo build: unable to convert parameter 1 from "asyncmodalrunner *" to "std:: nullptr\u T"**

Parker Parker sensor p8s-grflx
随机推荐
Exch: database integrity checking
流批一体在京东的探索与实践
巴比特 | 元宇宙每日必读:未成年人打赏后要求退款,虚拟主播称自己是大冤种,怎么看待这个监管漏洞?...
3D chart effectively improves the level of large data screen
canvas鼠标控制重力js特效
Canvas cloud shape animation
Advanced Mathematics (Seventh Edition) Tongji University General exercises one person solution
零基础也能做Apple大片!这款免费工具帮你渲染、做特效、丝滑展示
k线图快速入门必读
MOOG servo valve d661-4577c
Hyper-V: enable SR-IOV in virtual network
Send the injured baby for emergency medical treatment. Didi's driver ran five red lights in a row
万卷书 - 书单整理 [01]
Radio and television 5g officially set sail, attracting attention on how to apply the golden band
canvas云朵形状动画
Exch:完整性检查 Database Integrity Checking
NFT铸造交易平台开发详情
Is there an optimal solution to the energy consumption anxiety in the data center?
Splitting.js文本标题缓慢加载js特效
5G商用三年,未来创新何去何从?