Skip to Content

Introduction: SAP PO REST Adapter provides extensive functionalities can be used to realize a wide range of scenarios for consuming or exposing REST services in SAP PO. In this article, I will provide an insight on how to expose a REST service with multiple operations within PO based on one of my projects use case.

Use case: There exists a use case where mobile apps via the SAP Mobile Platform needs to consume some backend services in a legacy application. However, between SMP and the legacy system, an orchestration needs to be performed and this is implemented in Java Proxy Orchestration. In this article, these various services available in the legacy application will be combined into a single interface with multiple operations.

Figure_1.gif

Figure 1: Use case overview with systems involved in orchestration

Implementation steps:

  • v Create a service interface with four operations
  • v Configure the REST Sender Adapter for the four operations
  • v Test with SOAP UI to call different operations
  1. Service Interface: The steps for creating a service interface is not highlighted here as it is assumed this is known
  2. Configure the Sender REST Adapter: The focus of this article is essentially on configuring the sender REST adapter to be able to receive multiple messages using different operations from the consumer application. Perform the steps outlined below

1) Create a Sender REST Adapter as shown below, selecting the options as seen on the screen in the “General tab”

Figure_2.gif

Figure 2: Overview of the REST Sender Adapter

2) Proceed to the “Channel Selection” tab, choose the option specify endpoint and provide a name that can be used as a unique point of entry to this service (channel) by the consumer application;

Figure_3.gif

Figure 3: REST Sender Adapter Channel Selection Configuration

3) Proceed to the third tab; “REST Resources”, within the URL Pattern option, select “Custom Pattern” and put a forward slash “/” as the pattern.  Also, select the XI Dynamic Attribute “REST Service (service)”, Here provide the value for your “HTTP Header Element ” that would be passed from the consumer application

N:B-The first Dynamic Attribute shown in the screen is not relevant here.

Figure_4.gif

Figure 4: REST Sender Adapter Resource configuration and HTTP Header element

NB: The optional field can be ticked if you want to make this attribute option

4) In the 4th tab “REST Operation”, select HTTP Operation as the “Value Source”

Figure_5.gif

Figure 5: REST Sender Adapter operation configuration

5) A very important step in this configuration is the 5th tab “Operation Determination”, here the Sender REST Adapter maps the incoming message with the appropriate service interface operation.

  • In the column variable, provide the value {service} as configured earlier in step 3.
  • In the “Expression” column provide the name/value of choice for this operation (this is the value that would be passed by consumer to determine which operation to be called).
  • In the Operation column, provide the exact name of “Request Message” as well as the corresponding namespace in the Namespace column.
  • The quality of service for each operation can be specified also in the last column “QOS”

Figure_6.gif

Figure 6: REST Sender Adapter Operation Determination configuration

Once all the configuration steps described above have been implemented, then save and activate your channel.

6) Testing from a consumer: In this case the SOAP UI client tool is used, other REST client tools can be used as well. Perform the following actions to test,

  • Create a New REST Project in SOAP UI;

Figure_7.gif

Figure 7: Creating REST Project in SOAP UI Tool

  • In the request editor, make the following settings;

Method =POST

Endpoint: http//:<hostname>:port

Resource: /CalculatorService_2015 (as specified in step 2)

Figure_8.gif

Figure 8: Endpoint settings in REST Project Request message

Media Type: application/json

Request: JSON request message

HTTP Header Information:

i) Header = Calculator_Operation (as specified in step 3)

ii) Value = name of operation to be called e.g Add operation (as specified in step 5)

Figure_9.gif

Figure 9: Input JSON Message and HTTP Header element input

Conclusion: With the  steps described in this blog, you can easily expose a multi-operation service interface in SAP Process Orchestration as REST service using the sender REST Adapter. Consumer applications/client tools are able to consume the different services in the service interface operations by providing the configurable parameters set on the channel.

To report this post you need to login first.

5 Comments

You must be Logged on to comment or reply to a post.

    1. A. Olatunbosun Post author

      Well, this blog is different because it provides a complete end-2-end overview in implementing this functionality for beginners as well as experienced SAP PO developers.

      (0) 
  1. Ashutosh R

    Hi,

    Could your share us the details, what exactly you were having in your

    outbound service interfaces,  was it having 4 operations, for 4 different MessageTypes.

    i.e  1 service Interface (Outbound)

             operation1     ->  Divide MT

             operation2     -> Add     MT

             operation3     -> multiply  MT

             operation4     -> subtract.  MT


    regards,

    AR

    (0) 

Leave a Reply