Web service application

What is the web service?

I would skip this part and go right away to the example of client weh service application. We will create a simple client web service application to send a service request to service provider and received the result from service provider. The service is the dictionary service.

  1. Find services from service provider

You can find the service discription file (WSDL) which is required.

Here is the WSDL file contents

You can download WSDL file into your PC

2. Create client proxie in SAP system

  • Call SE80 , enter your package (eg. ZBC416 )

  • Right click at package ? Create ? Enterprise service ? Proxy object

  • Give the ABAP name and activate

The system will generate structures and other configuration

3. Create your ABAP program to call web service

*&---------------------------------------------------------------------**& Report ZBC416_WS_DICT*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*
REPORT ZBC416_WS_DICT.
parameters:
word type string.
*----- Create Port -----------------------------------------------------data proxy type ref to ZXXCO_DICT_SERVICE_SOAP.try.create object proxyEXPORTINGlogical_port_name = 'LP_DICT'.catch cx_ai_system_fault.endtry.*----- Call Web service -----------------------------------------------data: input type ZXXDEFINE_SOAP_IN,output type ZXXDEFINE_SOAP_OUT.move word to input-word.TRY.CALL METHOD proxy->DEFINEEXPORTINGINPUT = inputIMPORTINGOUTPUT = output .CATCH CX_AI_SYSTEM_FAULT .CATCH CX_AI_APPLICATION_FAULT .ENDTRY.
data: line type ZXXDEFINITION.write:/1 word.uline.loop at output-DEFINE_RESULT-DEFINITIONS-DEFINITION into line.write:/1 line-word,line-WORD_DEFINITION.
endloop.

That is all you need to do. Now you can test your application by execute this program and enter key word, the program will send request to the service provider and return the result back to your program.

You can also test the sample program in our test system:-

  • Logon to test system

  • Run SA38 and enter program ZBC416_WS_DICT and press Execute

  • Enter any key word and press Execute