如何在SAP CRM里创建和消费Web service
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:
SELECTSINGLEA~short_textINTOrv_textFROMCOMM_PRSHTEXTASAINNERJOINcomm_productASBONB~product_id=iv_prod_idANDB~product_guid=A~product_guid.
Make sure the FM is marked as "Remote enabled".
start the web service creation wizard:
Just follow the wizard to finish creation. Choose the appropriate authentication approach according to your use case.
Once creation is finished, you would find your service definition as below:
click tab WSDL, write down your WSDL link:
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:
tcode SE80, create a new service consumer:
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.
go back to SOAMANAGER, find the consumer proxy created in step2:
create a new logical point:
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:
consume the web service in ABAP report:
data:lr_proxyTYPEREFTOCO_ZPRODUCTDESCRIPTION4,inputTYPEZGET_PROD_DESCRIPTION,outputTYPEZGET_PROD_DESCRIPTION_RESPONSE.input-iv_prod_id='ARNO_TEST004'.CREATEOBJECTlr_proxyEXPORTINGLOGICAL_PORT_NAME='ZLP_JERRY1'.CALLMETHODlr_proxy->ZGET_PROD_DESCRIPTIONEXPORTINGinput=inputIMPORTINGoutput=output.
Now we get the web service execution result:
How to consume public web service in CRMThe steps to consume the public web service is almost exactly the same as consuming SAP internal web service.
Use the public web servicehttp://www.webservicex.com/FinanceService.asmx?WSDLas 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的原创文章,请关注公众号"汪子熙":
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。