Skip to Content

Dynamic configuration for headers is not working

Hi Experts,

I have written a REST lookup UDF to extract the "Etag" value from the endpoint and pass to headers of receiver REST channel.

Somehow I am not able to catch the "Etag" value in the headers

can anybody please tell me the mistake in the code to make adjustments.

Code:

AbstractTrace trace = container.getTrace();

String Etag = "";

try {

//instance the channel to invoke the service.

Channel channel = LookupService.getChannel("BC_ECC", "CC_REST_CRM_ETAG_RCV");

SystemAccessor accessor = LookupService.getSystemAccessor(channel);

// The Request message in XML. THIS IS THE LOOKUP SERVICE

String RESTxml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<id>" + accountID + "</id>";

InputStream inputStream =new ByteArrayInputStream(RESTxml.getBytes());

XmlPayload payload = LookupService.getXmlPayload(inputStream);

Payload RESTOutPayload = null;

//The response will be a Payload. Parse this to get the response field out. RESTOutPayload = accessor.call(payload);

/* Parse the SOAPPayload to get the SOAP Response back. The conversion rate is available under the Field Name ConversionRateResult */

InputStream inp = RESTOutPayload.getContent();

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

/* Create DOM structure from input XML */ DocumentBuilder builder = factory.newDocumentBuilder();

Document document = builder.parse(inp);

/* ConversionRate is available in the TAG ConversionRateResult in the Response XML */ NodeList list = document.getElementsByTagName("d:eTag");

Node node = list.item(0);

if (node != null) {

node = node.getFirstChild();

if (node != null) {

Etag = node.getNodeValue();

/*Dynamic configuration declaration*/

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

DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/REST","eTag"); conf.put(key, Etag);

} } }

catch (Exception e) {

trace.addWarning("Error" + e);

}

trace.addInfo("Service executed success");

return"";

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers