on 06-21-2016 2:49 AM
Hi Experts on SCN:
In my integration scenario I need to use REST receiver adapter to inquiry an external system to get some values.
The problem is, two different urls for two types of search:
As you can see the only difference is {subobject} in the uri,
I want to use only one REST receiver adapter, very likely is adapter for Type 1, to rule both cases but I can't.
Because, if I don't give value to {subobject} when inquiry is type 2, system gave me below error
...Transmitting the message using connection REST_http://sap.com/xi/XI/System failed, due to: com.sap.engine.interfaces.messaging.api.exception.MessagingException: com.sap.aii.adapter.rest.ejb.receiver.PlaceholderMissingException: URL placeholder fromunit is not configured, or has an empty value...
I tried to use adapter for type 2 and give value like "products/product" to {object}, but "/" will be encoded to %2F, then the whole url became an invalid one. What SAP online help said about "URL Pattern" is:
Is there any way I can achieve what I want? Thanks.
Kind Regards,
Nick
Hi Nick,
If you can determine the call type in mapping, you can define and set the URI dynamically using ASMA, like below.
Use this code in a UDF to set this URL:
DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http:/" + "/sap.com/xi/XI/System/REST", "id");
conf1.put(key1, url_path);
It worked fine for me.
Regarding the URL encoding, you can use: java.net.URLEncoder and encode the URL in the UDF. Although, I feel that shouldn't be required.
Regards,
Sanjeev.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sanjeev,
Thanks for your suggestion.
I used this REST communication channel as a lookup channel. I mean I used it in a Java mapping to get order status from a given order id.
Part of my Java mapping program is shown in the below.
DynamicConfigurationKey doesn't work when I call that REST communication channel. Any idea or API I can set parameter dynamically?
Thanks.
Kind Regards,
Nick
Hi Nick,
Can you try to set the dynamic parameter using standard parameter "id" of rest adapter:
DynamicConfigurationKey key1 = DynamicConfigurationKey.create("http:/" + "/sap.com/xi/XI/System/REST", "id");
conf1.put(key1, uri_path);
It worked for me, though I was not performing the call as a lookup. Also, you may want to write some traces in Java mapping to see if the dynamic attribute is being set or not.
Regards,
Sanjeev.
Hi Sanjeev,
I tried with following REST receiver settings but still not work. I got a feeling, when program calls communication channel, it is running in another context, if I can create or get that context. Maybe there is a chance I can set my own dynamic configuration value. Thanks.
Kind Regards,
Nick
Dynamic configuration from a Lookup UDF will not work. I had tried this to perform a SOAP Axis HTTP REST call and had the same issue.
If you definitely want to do this using a UDF where the REST Adapter is called via a UDF with a Dynamic URL you would need to tweak this a little. I typically use what I call is a SOAP Loopback scenario,
Basically you use a Loopback call to get the Dynamic URL working..
Regards
Bhavesh
Hi Yang,
1. One solution definitely is to use two separate interfaces but if you want in a single ID you can create only one ICO for two different OMs.
2. Second one is to create interface for type 1 I mean for URL -
https://external-system/api/{object}/{subobject}/search?{search_part1}={search_part2}
Now problem is when type 2 request will come your url will be like -
https://external-system/api/{object}//search?{search_part1}={search_part2}
So you can use one custom module in your receiver CC so that this request pattern is corrected before sending it to the target side. You can refer this blog for the custom module development -
And you need to use module parameters like below so that before sending it to target end your "//" in the url will be replaced with "/"
separator = ;
param1 = //;/
Thanks,
Apu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Apu,
Thanks for your reply and suggestion, I will try Adapter Module: ReplaceString to see if it worked as expected.
Kind Regards,
Nick
User | Count |
---|---|
70 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.