Consuming a Web service

In this recipe, we will see how we can create a client proxy based on a given Web service (using its WSDL document). As an example, we will use the Web service that we created earlier in this chapter. We will use the Web service wizard from the transaction SE80. This will generate the class and other necessary objects that are needed to call the Web service.

How to do it...

We will now follow the steps as shown:

  1. Go to transaction SE80, and select the menu option Edit Other Object.
  2. On the dialog box that appears, choose the Enterprise Services tab and in the Client Proxy field enter a suitable name. Then click on the Create button.
    How to do it...
  3. The wizard will then start. The first step will ask for the Source of the Web service. Choose the option URL/HTTP Destination and click on Continue.
    How to do it...
  4. For the next step of the wizard, enter the WSDL URL of our Web service binding. This is the same URL as shown in the Service Definition Overview tab in the SOAMANAGER transaction.
    How to do it...
  5. Enter the URL in the URL field and then click on Continue.
    How to do it...
  6. You will then be asked to specify the Package and Request number. Choose the Local Object checkbox and enter a suitable Prefix of the class to be generated. We will use the prefix ZST8_. Then click on Continue.
    How to do it...
  7. Finally, the screen appears where it is specified that clicking the complete button will generate the proxy class. Press the Confirm button to complete the action.

How it works...

This will create the service consumer proxy as shown in the following screenshot. The proxy by the name ZST8_CO_ZST8_MYSERVICE is created. The relevant class corresponding to the proxy is also generated and activated along with the necessary methods.

How it works...

The method contains the necessary logic for converting the amount based on the function module used while defining. The input structure corresponds to the importing parameters, whereas the output structure corresponds to the exporting parameters of the function module used for generating the Web service. All the necessary objects are generated. In addition, the relevant structures needed for the Web service call (consumer proxy method call) are also generated.

In the next recipe, we will see how to create a logical port for the Web service consumer. After this, the service may be called from a program using the proxy class methods.

There's more...

Apart from WSDL URL, you may use other options as the source of your web service. You may use a local file that contains the WSDL document pertaining to the service or the enterprise service repository of a PI instance. In addition, a UDDI registry (maintained on the SAP server that provides access to information about published Web services) may also be specified.

Alternatively, a more sophisticated Service Registry may be used as the source. The service registry is a UDDI v3 complaint registry within an SOA landscape. It may have services published from activated service interfaces from ESR, or from sender agreements from Integration Directory. Also, it may be used on ABAP or Java services definitions from AS, ABAP, or Java, respectively. They provide important information about services along with the reference to WSDL data. After entering the name of the UDDI registry or service registry the name of the relevant service may then be specified on the next screen.

..................Content has been hidden....................

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