- You have created a communication scenario as described in Defining a Communication Scenario Including Authorization Values.
- You have a service meta data file (WSDL file) for the service you want to consume.
- You have created and activated a service consumption model (SRVC) of type
Web Service
. See Generating Proxies for Remote Web Service for more information.
-
Create a corresponding outbound service of type
SOAP
.- In your ABAP project, select the relevant package node in the Project Explorer.
- Open the context menu and choose File > New > Other ABAP Repository Object > Cloud Communication Management > Outbound Service > Next to launch the creation wizard.
- Enter the name of the outbound service.
- Select SOAP in the Service Type dropdown list.
- Choose Next and select a transport request.
- In field Service Interface, enter the name of the relevant consumer proxy. You can choose the consumer proxy from the list of the value help.
- Save the outbound service.
-
Add the newly created outbound service to the communication scenario. See Service Consumption via Communication Arrangements for more information.
You can't use the
create_by_comm_arrangement
method for SAP-delivered scenarios. -
Publish the communication scenario. The administrator can then create the required communication management objects as described in Test Your Outbound Call.
-
Call the SOAP service as described in the example. Copy the code snippet from the Overview tab in your SRVC and add the
comm_system_id
andservice_id
parameters if necessary. Note the difference between synchronous and asynchronous services. According to your developed communication scenario, add the following:comm_scenario
mandatory
ID of the developed communication scenario
comm_system_id
optional
ID of the configured communication system
service_id
optional
ID of the developed outbound service
TRY. DATA(soap_destination) = cl_soap_destination_provider=>create_by_comm_arrangement( comm_scenario = '<demo scenario>' service_id = '<service id>' comm_system_id = '<comm system>' ). DATA(proxy) = NEW zsc_co_epm_product_soap( destination = soap_destination ). DATA(request) = VALUE zsc_req_msg_type( req_msg_type-product = '<product name>' ). proxy->get_price( EXPORTING input = request IMPORTING output = DATA(response) ). "handle response CATCH cx_soap_destination_error. "handle error CATCH cx_ai_system_fault. "handle error CATCH zsc_cx_fault_msg_type. "handle error ENDTRY.
We recommend to retrieve the correct destination reference based on the communication scenario and a customer-defined property as described in Service Consumption via Communication Arrangements.
For asynchronous services, follow the same procedure as for synchronous services. The only differences in the code are the following:
- The
IMPORTING
parameter is missing since the service doesn't return any value. - A
COMMIT WORK
triggers the SOAP call.
TRY. DATA(destination) = cl_soap_destination_provider=>create_by_comm_arrangement( comm_scenario = '<demo scenario>' * service_id = '<service id>' * comm_system_id = '<comm system>' ). DATA(proxy) = NEW zco_appointment_activity_reque( destination = destination ). DATA(request) = VALUE zappointment_activity_request1( ). proxy->appointment_activity_request_i( EXPORTING input = request ). COMMIT WORK. "to trigger async call CATCH cx_soap_destination_error. "handle error CATCH cx_ai_system_fault. "handle error ENDTRY.
To test your outbound call, you have to provide a configuration for the outbound service you want to call in your code.
Create a communication system and communication arrangement for the communication scenario in the Communication Systems and Communication Arrangements apps and maintain the required data.
To check if an asynchronous call was successfully sent to the provider system, see SOAP Monitoring.
These tasks are performed by the administrator. For more information, see Set Up SOAP Communication and SOAP Monitoring.
Related Information
Enable SOAP Communication in Your ABAP Code
Developing External Service Consumption (Outbound Communication)