cancel
Showing results for 
Search instead for 
Did you mean: 

SAP PO 7.5 REST Lookup - Issues in passing dynamic values in HTTP Header and custom Error handling

0 Kudos
1,712

Hi All,

I am working on a JMS to PROXY flow in which we have got a requirement to perform REST Lookup in the message mapping by passing dynamic values(some from incoming payload and some determined by small logic) in HTTP Header of the REST Lookup call. Also, I need to print the response(custom error log) from the REST Lookup in case the HTTP response code is not 200 (for any type of error code) and fail the message. I have some issues mentioned below, kindly share your inputs.

I have tried to put the incoming variables and some other logic determined values in Dynamic Config in mapping UDF and fetch them in REST Receiver channel and map them in HTTP Header section, but what I see is,

  1. The values are set properly and visible in Dynamic config in main message (incoming payload), but in the Lookup channel it shows as BLANK as shown below. So no values are passed to REST API and it returns error each time. This setup works fine in POSTMAN tool.

Lookup channel log is below,

I tried to validate if the Dynamic config is having issues or not by creating a REST to REST flow and see that the values are set properly in main message.

Below is the code from UDF,

AbstractTrace trace = container.getTrace();
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
//put header params in dynamic configuration.
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/REST","XHeaderName1");
DynamicConfigurationKey key2 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/REST","XHeaderName2");
DynamicConfigurationKey key3 = DynamicConfigurationKey.create("http:/"+"/sap.com/xi/XI/System/REST","XHeaderName3");
conf.put(key1, DocType);
conf.put(key2, msgId);
conf.put(key3, BusinessID);
return "";

And below is the config in REST Lookup channel,

2. I also need to catch the response from the REST Lookup to add it in the Audit log of main message and fail it in case of error, but the above error log is not available in main message. Below is the setup in REST Lookup channel in last tab. I only get a single string value for {http_result} in response payload. Is there any specific thing like creating the below structure as a separate external def or DT and use it?

3. Once I sort 1st issue, get error code from 2nd point, how to pass the above error log in Audit log, kindly let me know. I tried to follow this link and related notes and params in Module tab, but still no luck.

Thanks and regards,

Rajesh S.

Accepted Solutions (0)

Answers (4)

Answers (4)

0 Kudos

Hi! When you call the channel via Lookup service, SystemAccessor doesn't pass Dynamic Configuration to the channel, only payload.

Regards, Evgeniy.

0 Kudos

Thanks Evgeniy !

Muniyappan
Active Contributor
0 Kudos

You can create the separate ICO as sync interface. Call this ICO from lookup.

You can call like this: udf will call receiver channel. in the receiver channel put the ICO sender url.

Now add the header info also in the payload and use this as lookup request.

In ICO, use mapping to add only required payload and created header in the using udf.

You would need 3 channels over all.

1. sender channel for ico

2. receiver channel for ICO

3. receiver channel for lookup( put sender channel url here)

0 Kudos

Thanks Muniyappan for your suggestion ! I will give it a try.

0 Kudos

Hi Rajesh,

Are you finish this requirement, I got one just like this rencently.

It's thansful for ur reply.

regards.

stefan_grube
Active Contributor
0 Kudos

It is not possible to use dynamic parameters in a mapping lookup.

0 Kudos

stefan.grube -

Hi Stefan, Sorry for coming back very late on this ! I took another approach of performing the REST lookup in Java code itself and it worked. However, can you please confirm if the above approach wont work even now, considering a year has passed by? Maybe some further patches from SAP might help make this work now ?

Or maybe a different approach using SAP PO standard objects, please share your inputs !

Thanks, Rajesh

stefan_grube
Active Contributor

Hi Rajesh,
dynamic values are not supported for mapping lookups, no matter which adapter is used.
If the REST adapter is used for GET operation, the values could be stored in the payload.
Otherwise it is not easy

0 Kudos

Thanks a lot Stefan for your inputs ! This helps.

Regards, Rajesh

0 Kudos

I got my needs in this file.

How to Set http-Header Parameters Using the Axis Framework(NW7.0).pdf

Use UDF

I need get http-header parameter "Set-Cookie" at connect response and set http-header parameter "Cookie" at other request

It seems working.

Hope it's helpful.

Regards all.

chetan_risbud
Participant
0 Kudos

Hi Rajesh,

for 1st issue try as below

Also update here once issue is solved.

0 Kudos

Hi Chetan,

Thanks for the inputs ! I tried this approach of using same names in all places, still I don't get the HTTP Header vales from Dynamic configuration in REST Lookup channel. Whereas when I use the same channel as a proper receiver channel it works fine. Seems either I am missing something or the REST adapter channel is not picking the dynamic config vales while performing a lookup service.

Can you suggest some other pointers for me pls ?

Thanks,

Rajesh