Step by step to create, consume and trace web service in ABAP system
This document could be used as guide for beginners to learn and use ABAP web service.
How to create web service provider in ABAP system
The following steps demonstrates how to expose a function module as a web service provider in SAP CRM system.
1. create a new function module to return product description by given input product ID.
Signature and source code of function module:
FUNCTION ZGET_PROD_DESCRIPTION.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(IV_PROD_ID) TYPE COMM_PRODUCT-PRODUCT_ID
*" EXPORTING
*" VALUE(RV_TEXT) TYPE STRING
*"----------------------------------------------------------------------
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.
ENDFUNCTION.
Make sure the FM is marked as “Remote enabled”.
2. start the web service creation wizard:
Just follow the wizard to finish creation. Choose the appropriate authentication approach according to your use case.
3. Once creation is finished, you would find your service definition as below:
click tab WSDL, write down your WSDL link:
4. use tcode SOAMANAGER, click Web Service Configuration
you can find your service definition created just now:
click the hyperlink and create a new service:
For security reasons choose radio box “SSL”.
click Finish button:
Now your web service is ready for consumption. click this icon:
write down this link for later usage.
How to consume web service in ABAP system
1. tcode SE80, create a new service consumer:
2. Choose external WSDL:
choose the url got from last step of chapter “How to create web service provider in ABAP system”:
activate your consumer proxy and write down the ABAP class name.
3. go back to SOAMANAGER, find the consumer proxy created in step2:
create a new logical port:
4. Make sure you specify URL got from the last step of web service creation chapter. If you just use the URL got from SE80 in tab “WSDL”, you will meet with below error.
5. consume the web service in ABAP report:
you can find the data type for input and output parameters in SE80:
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 execute the report and get the web service execution result as expected:
The product description in UI:
How to trace the web service execution
Use tcode SRT_UTIL, add a new configuration for your user which triggers the web service call:
Set the Functional Trace to “High”. You could also enable Performance and Payload trace if necessary.
Click Save Configuration button to persist the change.
Execute the report which triggers the web service call. After it finishes, click tab “Functional Trace” and click refresh button, you should see several records for execution trace.
Double click and select the row with type “Response”, where you could find the product description value returned by service provider.
Very nice document!
Thank you Jerry for this document.
A minor remark:
I suppose that in the section 'How to consume web service in ABAP system'.
At step 3. 'create a new logical point', should be 'create a new logical port'.
Hi Piet,
thanks a lot for pointing out the typo. I have fixed it. 🙂
Best regards,
Jerry
Hi Jerry,
When I create the logical port,
I find that I have to enter the User Name and Password in the tab 'Comsumer Security'.
If I use that logical port in ABAP code, and I do not specify the user name and password, I get a popup asking for user name and password, when I call an operation on the proxy.
I do not want the authentication to be done with a fix user and password,
but without authentication.
Is that possible?
Thanks,
Piet
Hello Piet,
If you don't like to use authentication with username & password, you can use two other authentication settings, although I haven't tried myself. And so far I didn't know whether there is a way to consume web service generated via SOAMANAGER without authentication.
Although I have a rough research on SAP logon procedure, currently I still don't know how to consume it without authentication. Any reasons for this requirement( not good from my point of view regarding security guideline )?
Best regards,
Jerry
Hi Jerry / Piet
It is possible to access the web service even without authentication. You have to make the changes in SOAMANAGER accordingly. If the service is consumed in a secure environment, then there could be no need of authentication as well.
Regards,
Karthi M R.
Hello Karthi,
Thanks a lot for your information 🙂 Would you please kindly share the screenshot of necessary changes in SOAMANAGER to achieve this?
Best regards,
Jerry
Hi Jerry,
I hope there are four levels of authentication to be selected while creating the web service.
The authentication is set to Basic when Low Security is selected. If "No Security" is selected, the authentication level will be set to None.
Also, you can manually edit and activate the service from the available configurations in the Configurations tab.
Regards,
Karthi M R.
Hello Karthi,
I think you are showing the configuration of the service here.
In my question, I was referring to the configuration of the consumer proxy.
Even if I set the authentication of the service to 'None',
I have to choose between one of the 3 authentication settings that Jerry mentioned
(user ID/Password, SAP Authentication Assertion Ticket, X.509 SSL Client Certificate),
when I add a logical port for the consumer proxy.
Best Regards,
Piet
Hi Jerry,
Thanks for your reply.
I did not express myself correctly. I am not a security specialist, so please bear with me.
I am not looking for a solution without authentication,
but for a solution without authentication with a separate userid and password (basic authentication). In our company, the policy is that everyone, including IT staff, authenticates to the SAP portal using Shibboleth, and when authenticated accesses using SSO to the SAP environmnent. We are not supposed to use basic authentication with a password and userid in production.
My goal is to use a webservice that is not created via the web service tool (WST),
and use it in a document template. So, in short, I want to combine the ideas of both your
blogs http://scn.sap.com/docs/DOC-55153 and http://scn.sap.com/docs/DOC-55507.
If I would create a web service using the WST, and I use it in a document template, during this process, I do not have to specify a separate userid and password. Hence, I suppose that the system knows that the user is already authenticated at the moment that he uses the document template and thus allows to call the web service.
I was wondering if the same authentication principle cannot be used when using a web service which is not created using the WST.
[Update (7 Sept '14)]
Hi, I was able to achieve my goal by choosing the authentication settings to 'SAP Authentication Assertion Ticket'.
During one test (which I am not able to consistently reproduce), I was able to enter far more parameters in the Security tab (no longer labeled 'Consumer Security' tab, but 'Security'):
If I choose Authentication Method SAP Logon Ticket then, it also works.
If anyone knows how to get access to those additional security parameters consistently, I am interested to know how.
Best Regards,
Piet
Hi Jerry
I have a question regarding consuming a web service -
If the server location of the web service changes do we have to follow all the steps all over again that is create new PROXY CLASS, Create Logical Port and then call that in report?
What if the third party application also have a landscape just like SAP for ex - DEV, QA, PRD - the IP of the web service is different on each system.
The user(who is not a technical person) wants something very simple where they just want to put the web service's new link and system should function as it was with old link.
Will really appreciate if you can help with this.
Thanks
Rohit
Hi Jerry,
why does
the document template designer looks so different? The CALL BADI-Buttonis
missing, also the radio buttons and the URL button . Our system parameters are
BBPCRM release 713, SP 8.
Rainer
Hi Jerry,
Thanks a lot for the nice document. I have the same approach like Piet: use external web service for document template.
We have CRM 7.14 with SP04. So the SOAMANAGER looks a little different.
I created the FM and web service with profile “Authentication with Certificates and Transport Guarantee”. (same as your step 2). Configuration of binding and creation of service consumer were successful.
By configuration of logical port system shows that the Authentication Level ist “Strong”. So I couldn’t select UserID/Password. I selected “Single Sign On using SAP Assertion Ticket”. The Logical Port was created successfully.
But by testing of the service consumer in SE80 I got exception.

And the trace in SRT_UTIL:


Can you please provide some advice?
Thanks a lot.
Wei
Hi pankaj pandey,
Thanks for this great information. That’s an awesome article you posted.
Am beginner with SOA. I am confused with, Is binding between SOAP and WSDL possible?
By the way I was just going through the gathered studies on Mulesoft , its really great and with your article am very much confident that its great indeed.
I would like to connect you on linkedin, great to have experts in my connection (In case, if you don’t have any issues)
Regards,
Sunil
read the article
If like to read the response from program i.e output of proxy method, it is returning in some raw code how do i get the actual values ?
SRT_UTIL trace log stays for only 2 hours how do we keep it live ?
Hi
what, if "Service Administration" tab is missing in SOAMANAGER?
The whole tab is missing.
thx
I have a requirement to get the data from the SAP field glass system. For this we got the WSDL file from the team. We created service consumer on the same followed by creation of Logical port by uploading the dame file.
When i am trying to ping the logical port it is giving me below error:
SRT Framework exception: Service Ping ERROR: Error when calling SOAP Runtime functions: SRT: Processing error in Internet Communication Framework: ("Connect to euint20.fgvms.eu:443 failed: NIEHOST_UNKNOWN(-2)")
Please help me with the same
Hi Jerry,
really, a very good document! Congratulations!
Here is a little suggestion to improve the quality of your document further more:
The PDF-Document in SAP-note: 2045119 - Dokumentvorlage konnte nur Web-Service mit internem Einzelschemaknoten verwenden - SAP ONE Support Launchpad
describes that:
Only web service with single schema node is supported in CRM
document template integration
I think this is a very important information for persons who want to use the WEB-Service for their Word-Templates and it would be great if you can insert the contents of its PDF-document into your documentation!
Thanks and greetings from Germany
Dirk Jäckel
Hi,
I am unable to generate a binding WSDL document in SOAMANAGER, here's a link to my question:
Unable to generate WSDL document for Service Provider in SOAMANAGER | SAP Community
Thanks,
S.Bhat
It might be your host id is not exposed outside.
Add a line in your windows location host file.
path: c:\Windows\System32\Drivers\etc\hosts
<ip address>
and try.
all the best.
Thanks,
Mahesh