Creating a Web service from a function module

In this recipe, we will see how we can create a Web service using a Web service creation wizard from a remote-enabled function module. The function module simply takes as input an amount (in figures, for example, 1000) and currency such as USD, and then outputs the corresponding amount in words such as One Thousand US Dollars (similar to the function module SPELL_AMOUNT).

Getting ready

Since the SPELL_AMOUNT function module is not remote-enabled, it cannot be used for generating a Web service. One such attempt will result in the following error during creation of the service.

Getting ready

So, we will copy the function module SPELL_AMOUNT and rename it as ZST8_MY_SPELL_AMOUNT and make the copy remote-enabled after making necessary changes in the interface. In this recipe, we will use our remote-enabled function module as the basis for creation of a Web service. The function group containing this function module was created by the name ZST8_SPELL.

How to do it...

We will now follow the steps as shown:

  1. Call transaction SE80. From the list of the local objects of your user ID, we select the root node and right-click to access the context menu. We then navigate to Create | Enterprise Service.
    How to do it...
  2. This will start the wizard for Web service creation. On the first screen of the wizard, a number of radio buttons are presented.
    How to do it...
  3. Since we are creating a Web service, (we will choose the option Service Provider). The same wizard may be used for creating proxies for a number of object types such as a Service Consumer, or a Service Group. Then click on the Continue button.
  4. Next, a number of options are again presented. You may either create a Service Provider using the ESR Service Interface, a Service Variant, or an Existing ABAP Object (Inside Out) option. We will choose the third option Existing ABAP Object (Inside Out) approach. (A Service Variant uses certain parameters of a service that are relevant to a particular business scenario. The ESR object option allows us to create a proxy based on the Outside-In approach. In this case, the service interface exists in the enterprise service repository.) Then, click on the Continue button.
    How to do it...
  5. On the next screen (step of the wizard), we need to enter the Service Definition name, its description, and the Endpoint type (meaning whether a BAPI, function group, or a function module) is used as the basis for creating the service. Appropriate entries are made and the function module option is selected as the Endpoint type. Then, click on the Continue button.
    How to do it...
  6. This will take you to the next screen where you are able to enter the name of the function module, based on which the Web service is to be created. Enter the function module name in the field provided.
    How to do it...
  7. On the next screen, enter the profile PRF_DT_IF_SEC_NO in the Profile field. Then click on the Next button.
    How to do it...
  8. On the screen that appears now, you will be asked to enter data in the Request number and the Package fields. We will choose the checkbox Local Object. Then click on the Next button.
  9. Finally, you will be asked to complete your action. Click on the Complete button.

How it works...

We first created a remote-enabled function module that was used for creation of the Web service. The essential steps that we need to carry out for creation of a Web service are done using the wizard. The approach we follow is the Inside-Out approach. We used a function module as the basis of our Web service—the endpoint. The wizard guides us through the various steps and essentials for creating a service provider. The Web service is created by the name ZST8_MYSERVICE, as specified. We did not keep any authentication for the Web service.

This web service has been created but cannot be called yet. Now we need to make this configuration of the Web service created. The runtime configuration needs to be undertaken via transaction SOAMANAGER. We will do this in the next recipe.

There's more...

Instead of the path shown in the recipe, we may use transaction SE37, which directly creates creating a Web service. From inside the Function Builder, navigate to Utilities | More Utilities | Ceate Web Service.

An alternate path is to go to transaction SE80 and then navigate to Edit | Other Object. Then choose the tab Enterprise Services. Now, enter a name in the Service Definition field and click on the Create button.

On the Security Settings profile screen, we choose PRF_DT_IF_SEC_NO (meaning without authentication and no transport guarantee). There are three other possibilities:

  • PRF_DT_IF_SEC_LOW: Authentication with user ID and password but no transport guarantee
  • PRF_DT_IF_SEC_MEDIUM: Authentication with user ID and password as well as transport guarantee
  • PRF_DT_IF_SEC_HIGH: Authentication with certificates as well as transport guarantee
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.51.36