Skip to content

Latest commit

 

History

History
190 lines (126 loc) · 7 KB

soap-communication-via-communication-arrangements-2133e15.md

File metadata and controls

190 lines (126 loc) · 7 KB

SOAP Communication via Communication Arrangements

Procedure

  1. Create a corresponding outbound service of type SOAP.

    1. In your ABAP project, select the relevant package node in the Project Explorer.
    2. Open the context menu and choose File > New > Other ABAP Repository Object > Cloud Communication Management > Outbound Service > Next to launch the creation wizard.
    3. Enter the name of the outbound service.
    4. Select SOAP in the Service Type dropdown list.
    5. Choose Next and select a transport request.
    6. 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.
    7. Save the outbound service.
  2. Add the newly created outbound service to the communication scenario. See Service Consumption via Communication Arrangements for more information.

    Note:

    You can't use the create_by_comm_arrangement method for SAP-delivered scenarios.

  3. Publish the communication scenario. The administrator can then create the required communication management objects as described in Test Your Outbound Call.

  4. 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 and service_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

Synchronous Services

Sample Code:

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.

Note:

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.

Asynchronous Services

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.

Sample Code:

 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

Communication Management

Communication Arrangement

Developing External Service Consumption (Outbound Communication)