Sunteți pe pagina 1din 8

PI REST Adapter – Defining a dynamic

endpoint

This blog is part of a collection of blog entries that shows architectural concepts and configuration of the SAP
PI REST Adapter. We also added some sample scenarios to make it easier for you to understand how your
scenario can be implemented using the PI REST Adapter.

If you haven’t done so far, best is to start with the very first blog PI Rest Adapter - Don't be afraid
within the blog series covering the concepts of the REST adapter. A complete list of all blog
entries can be accessed from here PI REST Adapter - Blog Overview.

The current blog shows you along a sample scenario how to define a dynamic endpoint using a placeholder.

Scenario
We will enhance the flight scenario from the previous blog PI REST Adapter – JSON to XML conversion where
a travel agency gathers flight details from an airline. Besides the flight details query, the travel agency likes to
check the availability of flights. Depending on the respective service name as part of the endpoint URL, the
travel agency either calls BAPI_FLIGHT_GETDETAIL or BAPI_FLIGHT_CHECKAVAILABILITY.

In the SAP Process Integration Designer perspective of the NetWeaver Developer Studio (NWDS), we open
the existing Integration Flow and add an interface split together with the new inbound interface. Select the
interface split, and maintain the condition. In the condition, we use the adapter specific message attribute with
name service and namespace http://sap.com/xi/XI/System/REST. The attribute is set within the REST sender
channel, see below. For service equals getdetail, the request is routed to BAPI_FLIGHT_GETDETAIL. For
service equals checkavail, the request is routed to BAPI_FLIGHT_CHECKAVAILABILITY.

Generated by Jive on 2016-10-02Z


1
PI REST Adapter – Defining a dynamic endpoint

Configuring the REST sender adapter


Double-click on the sender channel of type REST, and switch to the REST Resources tab below the Adapter-
Specific tab. We would like to pass the service name as part of the endpoint URL, so we define the custom
pattern as /{service_part} whereas service_part is a placeholder which is filled during runtime.

The REST adapter comes with a set of predefined adapter specific message attributes such as resource,
service, and id which are commonly used among RESTful services. We use the service attribute to hold the
name of the service. As dynamic attribute select REST Service (service) from the drop down menu. The Value
Source is the beforehand defined URL Pattern Element service_part.

Generated by Jive on 2016-10-02Z


2
PI REST Adapter – Defining a dynamic endpoint

The rest of the configuration remains unchanged. For details, refer to the blog PI REST Adapter – JSON to
XML conversion.

Running the scenario


For testing the scenario we use the Advanced REST Client Application in the Google Chrome browser. The
endpoint URL of the RESTful service starts with http://<host>:<port>/RESTAdapter with host and port of the
SAP PI system, followed by what we have defined in the sender channel, here /demo/flight/<service>. For
either service, we enter the same request message in JSON format.

For checking the flight availability, we call the URL http://<host>:<port>/RESTAdapter/demo/flight/checkavail.

Generated by Jive on 2016-10-02Z


3
PI REST Adapter – Defining a dynamic endpoint

The response provides us the number of seats available in JSON format.

For requesting the flight details, we call the URL http://<host>:<port>/RESTAdapter/demo/flight/getdetail.

Generated by Jive on 2016-10-02Z


4
PI REST Adapter – Defining a dynamic endpoint

The response provides us the flight details such as destination and schedule in JSON format.

Generated by Jive on 2016-10-02Z


5
PI REST Adapter – Defining a dynamic endpoint

You can access the dynamic attributes values from the DynamicConfiguration message header. In the
message monitor, select the corresponding message, switch to tab Message Content, and open the
DynamicConfiguration message header.

Generated by Jive on 2016-10-02Z


6
PI REST Adapter – Defining a dynamic endpoint

Here you can see that the service attribute value is either checkavail or getdetail.

Generated by Jive on 2016-10-02Z


7
PI REST Adapter – Defining a dynamic endpoint

I hope this blog was helpful to understand the options that you have to define custom endpoints within the SAP
PI REST adapter. If you like to learn more, check out the other blogs in the series, accessible from the main
blog PI REST Adapter - Blog Overview.

Generated by Jive on 2016-10-02Z


8

S-ar putea să vă placă și