前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >How to create and consume web service in CRM

How to create and consume web service in CRM

作者头像
Jerry Wang
发布2019-05-31 09:15:20
5260
发布2019-05-31 09:15:20
举报

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”.
clipboard1
clipboard1
  1. start the web service creation wizard:
clipboard2
clipboard2

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

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

http://jerry.sap.corp:50056/sap/bc/srt/wsdl/flv_10002P111AD1/sdef_url/ZPRODUCTDESCRIPTION3?sap-client=001 click tab WSDL, write down your WSDL link:

clipboard5
clipboard5
  1. tcode SOAMANAGER, click Web Service Configuration
clipboard6
clipboard6

you can find your service definition created just now:

clipboard7
clipboard7

click the hyperlink and create a new service:

clipboard8
clipboard8

Make sure you use SSL.

clipboard9
clipboard9

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.

clipboard10
clipboard10

click Finish button.

clipboard11
clipboard11

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

clipboard12
clipboard12

write down this link for later usage:

clipboard13
clipboard13

How to consume web service in CRM

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

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

clipboard16
clipboard16

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

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

create a new logical point:

clipboard19
clipboard19
clipboard20
clipboard20
  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.
clipboard21
clipboard21

choose HTTPS:

clipboard22
clipboard22
  1. consume the web service in ABAP report:
代码语言:javascript
复制
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:

clipboard23
clipboard23
clipboard24
clipboard24

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:

clipboard25
clipboard25

Just test the consumer proxy class in class builder:

clipboard26
clipboard26

Specify request input just the same as in SoapUI:

clipboard27
clipboard27

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

clipboard28
clipboard28
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019年04月04日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • How to consume public web service in CRM
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档