In this exercise we will look at how we can consume a web service using a client proxy with ABAP.

Why do we need a Web service Client Proxy :

1. Webservice Client Proxy acts as transfer program.
2. It is used to connect to Server of the required Web Service
3. Creation of Valid SOAP messages and evaluation of received responses is taken care by the proxy.
So developer can concentrate on the Business Application without bothering about the technical aspects,
that is how the SOAP messages are exchanged.
CREATE PROXY CLASS :
Step 1: To start the Service Wizard again, from SE80 right click and choose Create->Enterprise Service.

As we are at consumer site. .Step 2 : This time in the Object Type step of the Service Wizard. choose Service Consumer .

a URL to a WSDL or the local file location of a WSDL. you can choose between the Enterprise Service Repository. a UDDI.Step 3: For the source of the Service Consumer. and the Service Registry. Please choose .

URL/HTTP Destination. . Step 4: Enter the URL of WSDL file which we had created in earlier exercise.

Step 5: Fill in the necessary details in the wizard. .

.Step 6: On the final step. you can press Complete to start the Proxy object generation.

Step 7 : You will be promoted for your logon User name and Password. .

Logical port takes care of this. Click on save and activate.The generated proxy class is now displayed. These details need to be configured through logical ports and endpoints. We can create a logical port by either tcode LPCONFIG(obsolete) or Soamanager as show below. Step :1 . The proxy class doesn’t hold any information about in which server the webservice needs to be called. Logical Ports are used to configure runtime features of a web service. SET UP LOGICAL PORT Go back to transaction SOAMANAGER and in order to setup a Logical Port for our new Service Provider. Why do we need a Logical port: A consumer proxy never stores any details regarding the URl server which are specific one system. For example:When you transport a proxy class from a development system to production.

choose to Search by Consumer Proxy. This time when you search in the Web Service Administration. This way the application will read all the necessary security settings for calling this service directly from the . choose Create Logical Port. Don’t forget to press the Apply Selection button after highlighting your proxy. Next we need to use WSDL Based Configuration. We will navigate to the same location as the last exercise – the Service Administration tab and the click the link named Single Service Administration. First you will need to name your logical port and set it as the Default.Go back to transaction SOAMANAGER and in order to setup a Logical Port for our new Service Provider. you will have to fill in several parameters. From the Configurations tab. Step :2 From the Popup screen that is generated.

you will be returned to the Configuration for Logical Port screen. Finally you will again need to supply the WSDL URL for the services you are call (hopefully you still left that browser window open).WSDL definition. Step :4 If successful. For now we need to embed user credentials for calling this . From here you can further define the settings for this logical port. You also must supply your system User name and Password to access the WSDL.

TESTING You can now return to the ABAP workbench in the package ZPROXIES and the definition of your Service .Enterprise Service. So once again input your User name and Password and then Save the Logical Port.

.Consumer and test it.

choose ZSQRT Method Name.On the Test Service Consumer options dialog . The response should show the XML version of the squareroot . You can go ahead and execute the request call. Finally execute the test. Switch to the XML Editor and replace the number value with 16.

.Now what. Goto SE80 and create a new report program ZPW_WEBSERVICE. If you want to consume web service using ABAP.

.

Modify the template for invoking the web service with the below code.Drag and Drop the proxy class ZCO_ZWS_SQRT and you get the template for consuming. input-number = ‘1212′. CREATE OBJECT proxy . DATA: proxy TYPE REF TO zco_zws_sqrt . This looks like as shown below. DATA : input TYPE zzsqrt . DATA : output TYPE zzsqrt_response . REPORT zpw_webservice. TRY.

CALL METHOD proxy->zsqrt EXPORTING input = input IMPORTING output = output. CATCH zcx_zsqrt_exception . TRY. ENDTRY. . output-result.EXPORTING logical_port_name = ‘ZP00′. CATCH cx_ai_application_fault . CATCH cx_ai_system_fault . CATCH cx_ai_system_fault . ENDTRY. WRITE : ‘Square root is’ .

Here we go. .Now its ready for execution.

Obviously its not the best kind of report to build. but I hope the basics fundamentals for consuming a web service would be clear by now. .