In previous blog we have finished the creation for web service PROD_WS, and ABAP consumer proxy class ZZCO_PROD_WS. Before it can be used in ABAP program to consume the web service we created, a logical port is needed.
Create a new Logical Port in SOAMANAGER
1. Go back to SOAMANAGER and search PROD_WS again, this time the ABAP consumer proxy ZZCO_PROD_WS is also visible in search result list.
2. Click consumer proxy class and click button Create->WSDL Based Configuration:
3. Specify Logical Port name:
Specify the WSDL link of new binding for service definition created in previous step. Specify a valid user and password for WSDL access.
Click finish button to finish logical port creation. Click Ping button and ensure it works successfully.
Consume the web service in ABAP program
Use the following source code to consume the query and read service operation. Pass the logical port name LP__TEST1 in constructor of consumer class. The data type and method signature could be easily found in class builder for consumer proxy class ZZCO_PROD_WS.
DATA: lo TYPE REF TO zzco_prod_ws, input TYPE zzcrmost__pro001prodadvsea01, output TYPE zzcrmost__pro001prodadvsea00. CREATE OBJECT lo EXPORTING logical_port_name = 'LP_TEST1'. input-input-searchforproducts-created_by-sign = 'I'. input-input-searchforproducts-created_by-option = 'EQ'. input-input-searchforproducts-created_by-low = 'WANGJER'. TRY. lo->crmost__pro001prodadvsea001d( EXPORTING input = input IMPORTING output = output ). CATCH cx_root INTO DATA(lv_text). DATA(ls) = lv_text->get_text( ). WRITE:/ ls. ENDTRY. DATA: ls_read_input TYPE zzcrmost__prod_ws_read, ls_read_result TYPE zzcrmost__prod_ws_read_respo. TRY. ls_read_input-input-prod_ws-product_id = 'ARNO_TEST004'. lo->crmost__prod_ws_read( EXPORTING input = ls_read_input IMPORTING output = ls_read_result ). CATCH cx_root INTO lv_text. ls = lv_text->get_text( ). WRITE:/ ls. ENDTRY.
program execution result: 100 results found with CREATED_BY = WANGJER:
The result is exactly the same as when we manually run the advanced search in GENIL_BOL_BROWSER:
And the result for read operation consumption: