Show TOC

Consuming A Stateless Web ServiceLocate this document in the navigation structure

Prerequisites

  • The Web service runtime is configured (for more information, refer to the section Configuring the Web Service Runtime).

  • You have generated a proxy (refer also to Generating a Consumer Proxy).

  • You have configured the consumer proxy.

    For more information, refer to the section Configuring a Consumer Proxy.

  • The role SAP_BC_WEBSERVICE_CONSUMER was assigned to the user master data of the user that processes the call at the provider (refer to Authorizations). The user at the provider depends on the logon settings of the provider endpoint and/or of the configuration of the consumer proxy. Either the user at the consumer is passed to the provider, a generic user as specified in the consumer proxy configuration is used, or a generic user as specified at the provider endpoint is used.

Context

The interface patterns stateless (XI 3.0 compatible), stateless, stateful, and TU&C/C assign the type of communication to be performed to each service interface. Stateless communication means that the messaging runtime does not support the saving of a status at the provider once the messaging runtime has completed the message exchange successfully.

Depending on the interface pattern, the service interface editor provides you with different operation patterns and modes. Read the explanations on Interface Patterns and Operations in the section Service Interface in the documentation for the Enterprise Services Repository.

Procedure

  1. To call a synchronous service from an application, instantiate the proxy class.

    DATA: lv_<client proxy name> TYPE REF TO <client proxy name>.

        CREATE OBJECT lv_<client proxy name>

          EXPORTING

              LOGICAL_PORT_NAME = ...

    If no standard port has been agreed, the logical port must be specified.

  2. Fill in the query data structure.

        DATA: lv_<request data> TYPE <request data>.

              lv_<response data> TYPE <response data>.

  3. Call the service.

        CALL METHOD lv_<client proxy name>-><name of method / operation>

            EXPORTING

              INPUT = lv_<request data>

            IMPORTING

              OUTPUT = lv_<response data>

  4. Wrap the proxy instantiation and the web service call into a TRY – CATCH block and perform error handling.

    TRY.

    ... CATCH cx_ai_system_fault INTO DATA(lx_ai_system_fault).

    <process error>

    CATCH <application error> INTO DATA(lx_<application_error>)

    <process error>

    ENDTRY

  5. Evaluate the received data.

            <process the data>

Next Steps

The runtime supports protocols for the purpose of more specialist services. For more information, see Protocols.

For calling an asynchronous service from an Application, read the section Programming with Sequences.

You can test how the Web service behaves when it is called by an application. Select the proxy that you have generated and choose Test (F8).

For more information, see Types of Message Transmission