Skip to Content

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.

02_01 Integration Flow.png

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.

02_02 Rest Resources.png

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.

02_03 Browser CheckAvail Request.png

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

02_04 Browser CheckAvail Response.png

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

02_05 Browser GetDetail Request.png

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

02_06 Browser GetDetail Response.png

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.

02_07 Dynamic Attributes link.png

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

02_08 Dynamic Attributes checkavail.png

02_09 Dynamic Attributes getdetail.png

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.

To report this post you need to login first.

2 Comments

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

  1. Vipin Kanchan

    Hi Alex,

    We are trying to create Dynamic URL for REST Receiver Channel. Our Channel configuration looks like below.

    http://server:port/getData/{DYNAMIC}, and have configured the channel to populate value for parameter DYNAMIC at runtime from payload (using XPATH Expression).

    The problem is, the value that comes during runtime has reserved characters like = (equals) and ; (semicolon) . Thus these values are getting url encoded and converted to %3D and %3B. Is there a way to avoid this?

    For example, url we need is

    http://server:port/getData/partnerid=12345;partnerName=xyz

    URL generated at runtime is

    http://server:port/getData/partnerid%2012345%3BpartnerName%20xyz

    Is there any setting that we can use to avoid the url encoding for the dynamic part of the URL?

    (0) 
    1. prem desai

      Hi ,

      Have you solved the issue with the URL encoding and converting to random values ? If so, please let me know the solution. I am also facing the same issue.

       

      (0) 

Leave a Reply