Show TOC

Procedure documentationConsuming a TU&C/C Web Service Locate this document in the navigation structure

 

The interface patterns stateless (XI 3.0 compatible), stateless, stateful, and TU&C/C assign the type of communication to be performed for each service interface.

A TU&C/C scenario (Tentative Update and Compensate or Confirm) could look like this:

The consumer sends requests to the server. The client then first performs the changes in his or her system. Only when an order, for example, has definitely been made on the client side will the changes be retained in the database. If there is any error, the changes will be rolled back. This type of communication requires special procedures in the application.

In a TUCC scenario, several operations are required: at least one operation that undertakes the changes in the target system, an operation that confirms the changes if –for example –an order has definitely been placed, and an operation that triggers a rollback if a change has not been confirmed. Beforehand, an operation can be executed that does not make any changes in the target system, but merely reads the values.

For more information, refer to Tentative Update & Confirm / Compensate (TU&C/C) in the section called Interface Pattern.

Prerequisites

Procedure

Create a program to call a service with the interface pattern TU&C/C.

Beispiel

DATA:

  l_proxy       TYPE REF TO my_proxy_class,

  l_seq_prot    TYPE REF TO if_wsprotocol_sequence,

  l_seq_comp    TYPE REF TO if_ws_client_sequence,

  l_seq_conf    TYPE REF TO if_ws_client_sequence,

  l_lp_name     TYPE prx_logical_port_name,

  l_tucc_id     TYPE sysuuid_x16,

  l_output_comp TYPE my_comp_req_struct,

  l_output_m1   TYPE my_m1_req_struct,

  l_output_m2   TYPE my_m2_req_struct,

  l_output_conf TYPE my_conf_req_struct,

  l_input_m1    TYPE my_m1_resp_struct,

  l_input_m2    TYPE my_m2_resp_struct.

TRY.

* determine logical port:

    l_lp_name = ...

* create proxy object:

    CREATE OBJECT l_proxy

        EXPORTING logical_port_name = l_lp_name.

* get sequence protocol:

    l_seq_prot ?= l_proxy->get_protocol( if_wsprotocol=>sequence ).

* create TU&C/C ID:

    l_tucc_id = cl_system_uuid=>if_system_uuid_static~create_uuid_x16( ).

* register compensate method for reliable execution

* if the LUW fails (rollback, dump, shutdown). This needs to be done

* before sending any other messages of the LUW, as a shutdown

* could happen at any time:

    l_seq_comp = l_seq_prot->create_transient_sequence( on_failure = 'X' ).

    l_seq_comp->begin( ).

    l_seq_prot->set_client_sequence( l_seq_comp ).

    l_output_comp-my_comp_req_struct-id = l_tucc_id.

    l_proxy->compensate( output = l_output_comp ).

    l_seq_comp->end( ).

* call synchronous methods:

    l_output_m1-my_m1_req_struct-id = l_tucc_id.

    l_output_m1-... = ...

    l_proxy->method1(

        EXPORTING output = l_output_m1

        IMPORTING input = l_input_m1 ).

    ...

    l_output_m2-my_m2_req_struct-id = l_tucc_id.

    l_output_m2-... = ...

    l_proxy->method2(

        EXPORTING output = l_output_m2

        IMPORTING input = l_input_m2 ).

    ...

* register confirm method for reliable execution if the

* LUW succeeds (commit):

    l_seq_conf = l_seq_prot->create_transient_sequence( ).

    l_seq_conf->begin( ).

    l_seq_prot->set_client_sequence( l_seq_conf ).

    l_output_conf-my_conf_req_struct-id = l_tucc_id.

    l_proxy->confirm( output = l_output_conf ).

    l_seq_conf->end( ).

* success, commit the LUW:

    COMMIT WORK.

      CATCH cx_root.

* failure, rollback of LUW:

    ROLLBACK WORK.

  ENDTRY.

For more information, refer to the section Programming with Sequences.