This document explains us about how to pass URL path and URL Query parameter in REST Adapter.
The example that follow are based on a REST sender request calling an RFC in ECC. Only the steps relevant to using the REST adapter are shown.
Enterprise Service Repository
URL Path Parameter:
Create a dummy message type for the request message
For the request message mapping populate fields with constants where required
For fields where the data will be passed in from the URL.
REST SENDER ADAPTER Configuration for URL path parameter–
Set input data format as JSON and tick ‘Convert to XML’ and ‘Add Wrapper Element’
Enter Element Name/Namespace as per Root node of expected message (Request message)
Above settings will convert JSON to PI required format
Change output data format to JSON and tick ‘Convert XML payload to JSON’
(could leave output as xml if required)
On Channel Selection tab specify endpoint
Enter the name of resource the client will call
REST Operation Tab:
On Operation Determination tab set pointer to the interface to call (assume needs this since no payload was passed?). In the below example Operation and Namespace are set to the Name and namespace of the request Message Type respectively.
In SOAPUI
Method = ‘GET’
Endpoint = ‘http://{host}:{port}/RESTAdapter’
Resource = Endpoint value specified above in communication channel plus the URL pattern
So in the above example data is retrieved for customer 0000000002
To run for a different customer just change the last value
URL Query Parameter:
For query parameters create function to read the data from the dynamic attributes of the message
public String getASMA(String attribute, String namespace, Container container) throws StreamTransformationException{
Map map = container.getTransformationParameters();
DynamicConfiguration conf = (DynamicConfiguration)map.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key = DynamicConfigurationKey.create( namespace, attribute);
String value = conf.get(key);
return value;
}
Use UDF in mapping
Where ‘attribute’ field in UDF (constant ‘id’ in this example) = Name of Dynamic attribute in communication channel (see further down for details on setting this up)
And ‘namespace’ field in UDF is set to: http://sap.com/xi/XI/System/REST
Integration Directory:
Configure Sender REST adapter
Does not matter what the input message format is since no payload sent with GET requests
Output message can be XML or JSON
On Channel Selection tab tick specify endpoint as required
On REST Resources tab set URL Pattern to ‘Custom Pattern’ and the remaining settings as shown below
On Operation Determination tab set pointer to the interface to call (assume needs this since no payload was passed?). In the below example Operation and Namespace are set to the Name and namespace of the request Message Type respectively.
SOAP UI
Method = ‘GET’
Endpoint = ‘http://{host}:{port}/RESTAdapter’
Resource = Endpoint value specified above in communication channel plus the URL pattern
So in the above example data is retrieved for customer 0000000002
To run for a different customer just change the last value