This is show a step by step guide how to invoke a web service from SAP. There are three steps you need to follow.
- Create proxy object
- Create logical port
- Create program to consume created proxy object
You need to have your webservice URL ready Obviously! :P Check the webservice URL using IE to check the attributes and methods. This will give you a understanding of the behavior of the service.
I will explain each step with more detail.
1. Create Proxy Object
We need to create proxy object in SAP for the web-service URL you are going to invoke.
eg URL: http://<IP of the host>:8090/<Namespace>/<Service Name>.asmx?WSDL
Go to se80>select package>right click>Create>Enterprise Services/Web Services>Proxy Object
Select URL/HTTP Destination
option and type in the web service URL and click ok. Give the Class name.
If the URL is available and without any errors, proxy object will be generated.
You can check the created class using transaction se24. Select the method and it's parameters you are going to access. This will be needed to create data objects at 3rd step.
2. Create logical port
Go to transaction "lpconfig
" and create logical port
with the desired name.
Hit the create button.
Give the webservice URL in call parameter tab as below.
3. Create program
Proxy object and port are created, now we write a program to access methods of the created proxy class. You need to have a understanding of basic ABAP OO concepts to develop this program.
Using se24, check the structure and parameters of the method of proxy class.
Basic structure of the program is as below:
: lo_send_mail TYPE REF TO
*create object: Port name = Port created in step 2
logical_port_name = <PORT_NAME>.
This section of the code should include the logic to fill the ls_input or any other parameters that need to pass to the proxy object method.
*call desired method with correct parameters
lo_send_mail-><Method name from se24>
Labels: ABAP, ABAP proxy class, Invoke webservice from SAP, Isuru Fernando, Proxy, SAP ABAP, SAP Sri Lanka, SOAP, webservice