Quantcast
Channel: Process Integration (PI) & SOA Middleware
Viewing all articles
Browse latest Browse all 741

Copy value from Request message to Response message using DynamicConfigurationBean and dynamic header fields

$
0
0

Recently I worked on a scenario with two Idocs that are used as asynchronous request and response messages for ERP and a synchronous webservice.

For this scenario, I used SOAP adapter with async-sync brigde with help of RequestResponseBean and ResponseOnewayBean.

 

I wanted to populate fields in the response Idoc from the request Idoc. Here I had the challenge that the required values were only available in the Idocs, but not part of the request and response message of the web service, so I could not use the option with GetPayloadValueBean and PutPayloadValueBean, as it is described in this blog of Beena Thekdi:

Insert value from Request message to Response message using GetPayloadValueBean and PutPayloadValueBean

 

I wanted to use the dynamical header fields of the PI message to store the vales. Unfortunately, the SOAP adapter removes dynamic header field from request message, so the response message would not be able to access them. So I needed to find a way to keep the values.

 

I found the solution with the DynamicConfigurationBean that allows copying values form dynamical header fields to the module context and back. All adapter modules within the same module chain of the communication channel can access the parameter values in the module context.

 

I have already described this feature in this blog:

Unknown use case of DynamicConfigurationBean: Store file name to JMS header without mapping

 

Now the module chain of my SOAP adapter receiver channel looks like this:

 

ModuleTypeModule Key
AF_Modules/DynamicConfigurationBeanLocal Enterprise BeanDC1
AF_Modules/RequestResponseBeanLocal Enterprise BeanRRB
sap.com/com.sap.aii.af.soapadapter/XISOAPAdapterBeanLocal Enterprise BeanSOAP
AF_Modules/DynamicConfigurationBeanLocal Enterprise BeanDC2
AF_Modules/ResponseOnewayBeanLocal Enterprise BeanROB

 

I will not go into the configuration for RequestResponseBean and ResponseOnewayBean, as this is described in other blogs.

 

The module parameters for the DynamicConfigurationBean are following. In my scenario, I used the dynamic value "Value" with namespace "strDocNum".

Those values might not be the best choices, however it works anyway.

 

Module KeyParameter NameParameter Value
DC1key.1write strDocNum Value
DC1value.1module.strDocNum
DC2key.2read strDocNum Value
DC2value.2module.strDocNum

 

For the graphical mapping tool, it is necessary to create user-defined functions to store the values in the dynamical header fields and read them from there. Here are the functions that are used in my scenario:

 

PutDocNum

public String PutDocNum(String docnum, String username, Container container) throws StreamTransformationException{

DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey keySource1 = DynamicConfigurationKey.create("strDocNum","Value");

 

if (conf != null) {

  conf.put(keySource1, docnum);

}

 

return username;

 

Note: as the value DocNum was not part of the target message, the UDF was tied to another target field called username.

 

GetDocNum

public String GetDocNum(Container container) throws StreamTransformationException{

DynamicConfiguration conf = (DynamicConfiguration)container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

if (conf != null) {

    DynamicConfigurationKey keySource1 = DynamicConfigurationKey.create("strDocNum","Value");

    return conf.get(keySource1);

} else

    return "";

 

 

Here is the link to the online help, the parameter value module.nn is still not mentioned:

Adding DynamicConfigurationBean in the Module Processor


Viewing all articles
Browse latest Browse all 741

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>