天天看點

How to create and consume web service in CRM

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

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”.

How to create and consume web service in CRM
How to create and consume web service in CRM
start the web service creation wizard:
How to create and consume web service in CRM
Just follow the wizard to finish creation. Choose the appropriate authentication approach according to your use case.
How to create and consume web service in CRM
Once creation is finished, you would find your service definition as below:
How to create and consume web service in CRM

http://jerry:50056/sap/bc/srt/wsdl/flv_10002P111AD1/sdef_url/ZPRODUCTDESCRIPTION3?sap-client=001

click tab WSDL, write down your WSDL link:

How to create and consume web service in CRM
tcode SOAMANAGER, click Web Service Configuration
How to create and consume web service in CRM
you can find your service definition created just now:
How to create and consume web service in CRM
click the hyperlink and create a new service:
How to create and consume web service in CRM
Make sure you use SSL.
How to create and consume web service in CRM
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.
How to create and consume web service in CRM
click Finish button.
How to create and consume web service in CRM
Now your web service is ready for consumer. click this icon:
How to create and consume web service in CRM
write down this link for later usage:
How to create and consume web service in CRM

How to consume web service in CRM

tcode SE80, create a new service consumer:

How to create and consume web service in CRM
Choose external WSDL:
How to create and consume web service in CRM
choose the url got from “how to create web service in CRM”, step3
How to create and consume web service in CRM
activate your consumer proxy and write down the ABAP class name.
How to create and consume web service in CRM
go back to SOAMANAGER, find the consumer proxy created in step2:
How to create and consume web service in CRM
create a new logical point:
How to create and consume web service in CRM
How to create and consume web service in CRM
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.
How to create and consume web service in CRM
choose HTTPS:
How to create and consume web service in CRM

  1. consume the web service in ABAP report:
How to create and consume web service in CRM

Now we get the web service execution result:

How to create and consume web service in CRM

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:

How to create and consume web service in CRM

Just test the consumer proxy class in class builder:

How to create and consume web service in CRM

Specify request input just the same as in SoapUI:

How to create and consume web service in CRM

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

How to create and consume web service in CRM