Creating a SOAP (WSDL) web service within SAP


Creating a SOAP (WSDL) web service within SAP that can then be accessed from anywhere (with network access) is actually very easy. In fact, providing a web service out of SAP is no more difficult than creating a function module and running a creation wizard via SE80. It’s also very easy to then test this service from industry recognised (i.e. none SAP) web services testing software such as SOAPUI or POSTMAN.

Just as a quick overview we will create a function group which will hold the function modules we want to perform the functionality in SAP. Each of these function modules will represent an operation of the new web service. Anyway, follow the instruction below and it should all become clear very quickly.

Step 1 – Create a function group for your Web Service

First, we will create a simple function group to hold all the function modules we want to build into our demo web service. Each function module will map to an operation of the web service

Step 2 – Create function modules

Next, you need to create a function module with the importing and export parameters you want to use as part of the web service.


Let create the function module called Z_OPERATION1


First enter the attributes, ensuring it is set as a remote-enabled function module

Enter the import parameters ensuring all are set as pass by value. Note the underscores in the parameter names, these will help explain some functionality later in this course when the web service is created.

Now enter your export parameters, again ensuring the pass by value option is selected for each parameter. This example will return a single EKKO line and multiple EKPO lines for a purchase order.

 Save and activate the function module

Step 3 – Create a second function module (operation)

Just for simplicity just copy the first function module into a new one called Z_OPERATION2

Save and activate the function group

Step 4 – Create a web service

The next step is to create the web service. To do this simply go to the object selection and choose the Enterprise Services tab. Now enter a name in the Service Definition field (i.e. Ztest_webservice) and press create

This will then activate the wizard where you can simply follow the steps

Step 5 – Web service creation wizard

First choose the object type of the proxy you want to create, which for this example is a service provider. i.e. you are going to provide a service that other systems can use/call.

Note the wizard in not 100% bug-free if you have messed around with the options you may need to log out of SAP and log back in again to reset the screen flow.

Then choose what will be used to generate the service provider which in this case will be the function modules we have just created so choose Existing ABAP object.

Enter name and description for the Web service.

Now chose Function group

If you wanted a web service with one operation you could also choose function module here and enter the function module name on the next screen

But we are going to use the function group and create a web service with 2 operations.

Now enter the name of the function group that is to be used by the Web Service.

Note the “Map Names” option which is used to map the names of the function modules so that initial letters are capitalized and underscores are removed. If you do not select this all names of the web service will remain the same as created within the function module.

Check the Map Names option

Choose the function modules to be used by the web service, you must choose at least one.

Use refresh to reset the list to all available function modules and use the delete rows to remove function modules you do not want to use. For this example, we will use them all so simple hit continue.

On the next, you need to Select a security profile that meets the security requirements of your Web service. You can specify a security level for the profile. This security level will be the minimum requirement for all the runtime configurations for this service definition.

For this example, just use the default and press continue

Enter the package for the new web service objects or choose “Local Object” to use $TMP.

That’s it, press complete. Although at this stage the service does not have any runtime release and therefore cannot be used. We will create this next using transaction SOAMANAGER.

Step 6 – Web service object created by the wizard

Properties

External view

Internal view

Types

Used objects

Configuration

Step 7 – Change security level

Just to ensure there are no authorisation issues set the security level to none. To do this go to the configuration tab and select authorisation.

Then choose profile none.

Step 8 – Activate sap web service

Now simply activate the gernerated SAP enterprise service (web service provider)