码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2018-12-02 14:59:10      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:dir   imp   inner   forbidden   wing   external   output   esc   orb   

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:
    技术分享图片

  2. 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:
技术分享图片

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

技术分享图片

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

标签:dir   imp   inner   forbidden   wing   external   output   esc   orb   

原文地址:https://www.cnblogs.com/sap-jerry/p/10053310.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!