Using DynamicConfiguration to Receiver HTTP_AAE (IDOC to HTTP_AAE)
Objective
An interface should be created to send an IDOC to a legacy system using HTTP, post request method with three key fields (in this order):
- request: fixed value
- directory: fixed value
- filename: value will be dynamically configured using IDOC number
HTTP_AAE Communication Channel
To accomplish that we need to create a Receiver HTTP_AAE Communication Channel, setting Message Protocol = POST and all the Destination and Security information.
After that, in “Advanced” tab, scrolling down, in the Adapter-Specific Message Properties, we mark “Set Adapter-Specific Message Properties” and “URL Parameters”:
- Parameter 1 (URLParamOne): request
- Parameter 2 (URLParamTwo): directory
- Parameter 3 (URLParamThree): filename
DynamicConfiguration
To dynamically set all three parameters, I use Message Mapping and UDF, but it is possible to use the same code for Java Mapping as well.
The UDF should have three input parameters that will be used to dynamically set HTTP_AAE parameters values:
public String setDynamicURLParameters(String request, String directory, String filename, Container container) throws StreamTransformationException{
//Get the dynamic configuration from the container
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
//Create the URLParamOne key in namespace http://sap.com/xi/XI/System. This key will hold the dynamically created request parameter
DynamicConfigurationKey keyParam1 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System", "URLParamOne");
//Create the URLParamTwo key in namespace http://sap.com/xi/XI/System. This key will hold the dynamically created directory parameter
DynamicConfigurationKey keyParam2 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System", "URLParamTwo");
//Create the URLParamThree key in namespace http://sap.com/xi/XI/System. This key will hold the dynamically created filename parameter
DynamicConfigurationKey keyParam3 = DynamicConfigurationKey.create("http://sap.com/xi/XI/System", "URLParamThree");
//Put the parameters values from the input in the configuration under the specified key
conf.put(keyParam1, request);
conf.put(keyParam2, directory);
conf.put(keyParam3, filename);
return filename;
}
To use the UDF, we create a Variable by right clicking the root element and choosing “Add Variable”:
Finally, for this Variable mapping we create two Constants to set the first two Parameters that will have fixed values and push DOCNUM of IDOC structure from source message to use as the third parameter, filename.
We can check in SXI_MONITOR the parameters set in DynamicConfiguration.
Thank You for the blog.
Nice Blog Diogo..... Keep Posting
Hi Diogo,
This is exactly what I need. I have my parameters in the DynamicConfiguration, but I do not know how to define the path in the channel. I have 4 URLParm parameters: login, password, method and order_ref. I tried many things, but I was not able to figure this out.
my path looks like:
?/login=username&password=pw123456&method=accept_order&order_ref=M12345678
Example: URLParamOne contains value login=username
Any help is appreciated,
Wilbert
Hi WLAF,
The format is as follows:
http(s)://host:port/path?queryStringParams
Take the SOAP sender for example:
http://test.com:50000/XISOAPAdapterMessageServlet?channel=p:s:c
host: test.com
port: 50000
path: /XISOAPAdapterMessageServlet
queryString: channel=p:s:c
Regards,
Mark
Hi Mark
(I use my new scn account).
This is not a SOAP channel. I use the exact same adapter as mentioned in this blog. Any ideas?
Wilbert
Hi W,
It was just an example. Here is an example where a query string is used
www.webservicex.net/stockquote.asmx/GetQuote?symbol=HPQ
The URL above points to a webservice that returns the stocks based on the symbol value, in this case HPQ. Based on that, the settings for the HTTP_AAE should be
Host: www.webservicex.net
Port: 80
Path: /stockquote.asmx/GetQuote
symbol should be placed in URLParamOne.
Regards,
Mark
Hi Mark
I am not using the SOAP adapter. I use the HTTP (Post) adapter as shown in the blog.
Any help is welcome regarding to the setup for the path. I am able to see the values for my 4 parameters in DynamicConfiguration.
Wilbert
With the help of Mark I found the correct solution. We are running PI 7.30 SP5.
First of all, I mentioned in my example the path like:
?/login=username&password=pw123456&method=accept_order&order_ref=M12345678
That must be:
/?login=username&password=pw123456&method=accept_order&order_ref=M12345678
When passing my parameters dynamically, the following was successful:
1) path name contains only a / (do not put ? or &)
2) pass only the values for the parameter in the UDF (in the beginning I passed both keyword and value).
3) Within the ASMP you specify the keywords
In my example:
Parameter 1 (URLParamOne): login
Parameter 2 (URLParamTwo): password
Parameter 3 (URLParamThree): method
Parameter 4 (URLParamFour): order_ref
I found out that it is does not support a password containing a &. Even when a use %26 instead of a & it did not work. I have to avoid using a & in the password.
Wilbert
Hello! Diogo Awaihara
I have the same scenario IDOC sender to HTTP_AAE Receiver, but I do not know how to design in ESR, should have the same structure xml either side? i must use java mapping ? Please can you help me with esta scenario.
Danisay.
Hello Danisay.
That depends on the requirements from the receiver side.
In my case, I kept the same structure, so no special mapping here (besides the Variable + UDF).
Regards,
Diogo
Hello I need to send request parameters in URL. My UDF is the below , But it does not working.
DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
DynamicConfigurationKey parmValue;
//the url below is not the one in the real coding due to security reason
String url = "http://production.shippingapis.com/ShippingAPI.dll?API=RateV4";
// TargetURL
parmValue = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/HTTP_AAE", "TargetURL");
conf.put(parmValue, url);
parmValue = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/HTTP_AAE","UrlParamOne");
conf.put(parmValue, var1);
parmValue = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/HTTP_AAE", "UrlParamTwo");
conf.put(parmValue, var2);
parmValue = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/HTTP_AAE", "UrlParamThree");
conf.put(parmValue, var3);
parmValue = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/HTTP_AAE","UrlParamFour");
conf.put(parmValue, var4);
parmValue = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/HTTP_AAE","UrlParamFive");
conf.put(parmValue, var5);
parmValue = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/HTTP_AAE","UrlParamSix");
conf.put(parmValue, var6);
String extension = "urlext";
// Additional field
parmValue = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/HTTP_AAE","SAP_URL_EXTENSION");
conf.put(parmValue, extension);
parmValue = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/HTTP_AAE", "urlext01=");
conf.put(parmValue, var7);
parmValue = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/HTTP_AAE", "urlext02=");
conf.put(parmValue, var8);
parmValue = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/HTTP_AAE", "urlext03=");
conf.put(parmValue, var9);
parmValue = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/HTTP_AAE", "urlext04=");
conf.put(parmValue, var10);
parmValue = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/HTTP_AAE", "urlext05=");
conf.put(parmValue, var11);
parmValue = DynamicConfigurationKey.create( "http://sap.com/xi/XI/System/HTTP_AAE", "urlext06=");
conf.put(parmValue, var12);
return "";
Hi Ceren,
Did your configuration work? I have similar scenario like i have to add 10 parameters dynamically but its giving below error.
"Transmitting the message using connection SOAP_http://sap.com/xi/XI/System failed, due to: com.sap.aii.adapter.http.api.HttpAdapterException: ERROR_OUTBOUND_PROCESSING, while trying to load from index 1 of an object array with length 1, loaded from local variable params".