开发者社区> jerrywangsap> 正文

如何在SAP CRM里创建和消费Web service

简介: Created by Wang, Jerry, last modified on Dec 19, 2014 The following steps demonstrates how to expose a function module as a web service in CRM.
+关注继续查看

Created by Wang, Jerry, last modified on Dec 19, 2014

The following steps demonstrates how to expose a function module as a web service in CRM.

  1. create a FM to return product description by given product ID.

Just use the following source code:

SELECT SINGLE A~short_text INTO rv_text FROM COMM_PRSHTEXT  AS A
INNER JOIN comm_product AS B ON B~product_id = iv_prod_id AND B~product_guid = A~product_guid.

Make sure the FM is marked as "Remote enabled".

  1. start the web service creation wizard:

Just follow the wizard to finish creation. Choose the appropriate authentication approach according to your use case.

  1. Once creation is finished, you would find your service definition as below:

click tab WSDL, write down your WSDL link:

  1. tcode SOAMANAGER, click Web Service Configuration

you can find your service definition created just now:

click the hyperlink and create a new service:

Make sure you use SSL.

Otherwise, you will meet with the following error code in the runtime. This is simply because web service via HTTP protocal is set as forbidden in Suite landscape and all such communication will be redirected, as set up in SMICM.

click Finish button.

Now your web service is ready for consumer. click this icon:

write down this link for later usage:

How to consume web service in CRM

  1. tcode SE80, create a new service consumer:
  1. Choose external WSDL:

choose the url got from "how to create web service in CRM", step3

activate your consumer proxy and write down the ABAP class name.

  1. go back to SOAMANAGER, find the consumer proxy created in step2:

create a new logical point:

  1. Make sure you specify URL got from web service creation last step. If you just use the URL got from SE80 in tab "WSDL", you will meet with below error.

choose HTTPS:

  1. consume the web service in ABAP report:
data: lr_proxy TYPE REF TO CO_ZPRODUCTDESCRIPTION4,
input TYPE ZGET_PROD_DESCRIPTION,
output TYPE ZGET_PROD_DESCRIPTION_RESPONSE.
input-iv_prod_id = 'ARNO_TEST004'.
CREATE OBJECT lr_proxy
EXPORTING
LOGICAL_PORT_NAME = 'ZLP_JERRY1'.
CALL METHOD lr_proxy->ZGET_PROD_DESCRIPTION
EXPORTING
input      = input
IMPORTING
output     = output.

Now we get the web service execution result:

How to consume public web service in CRM

The steps to consume the public web service is almost exactly the same as consuming SAP internal web service.

Use the public web service http://www.webservicex.com/FinanceService.asmx?WSDL as example.
First it is necessary to verify whether this web service is working correctly for the time being - test it in soapUI:

Just test the consumer proxy class in class builder:

Specify request input just the same as in SoapUI:

Execution result is the same as what we get in SoapUI:

本文来自云栖社区合作伙伴“汪子熙”,了解相关信息可以关注微信公众号"汪子熙"。

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
PyScript:让 Python 脚本在 Web 中跑起来
这是下一个大事件吗?如果继续发展下去,有可能。
15 0
我用一个跨平台 Web 应用替换了原生 iOS 应用,竟没人发现
不知为何,我的跨平台 Web 应用实际上更稳定。我想,我浪费了大量时间开发原生 iOS 应用。
7 0
Node.js安装与基本使用
Node.js安装与基本使用
10 0
开源许可证的变迁:从 Elastic 两次变更开源协议说开去
开源从开始到现在已经有几十年历史,开源许可证在开源运动的发展中起到了基石作用,不管是从文化还是法律的角度,都较好地推动了开源的发展。
10 0
【jQuery入门】为JavaScript而生,简化JavaScript操作的神技术
之前我们学习了这个JSON热门技术,在之后的学习中都会多多少少的牵扯到JSON相关的知识的,好多技术中也会用到JSON,所以如果你还不知道JSON建议先去看一下我的上一篇博客。
7 0
【Ajax入门】实现页面的局部刷新,前后端交互少不了的技术
之前已经学习jQuery了,我们今天在jQuery的基础上继续学习Ajax。如果你不知道jQuery那么你可以先去看看本专栏的上一篇文章。
8 0
注册vmvare账号验证码问题
注册vmvare账号验证码问题。
3 0
推荐一款 Postman 的开源替代品: Postwoman
推荐一款 Postman 的开源替代品: Postwoman
8 0
①万字《详解canvas api画图》小白前端入门教程(建议收藏)
①万字《详解canvas api画图》小白前端入门教程(建议收藏)
7 0
+关注
2624
文章
0
问答
来源圈子
更多
+ 订阅
文章排行榜
最热
最新
相关电子书
更多
OceanBase 入门到实战教程
立即下载
阿里云图数据库GDB,加速开启“图智”未来.ppt
立即下载
实时数仓Hologres技术实战一本通2.0版(下)
立即下载