I'm trying to pass the user context from a SOAPAsyncRequest node to a SOAPAsyncResponse node by overriding the local environment like described in the IBM documentation here and here.
In Map to N compute node (Compute Mode is set on LocalEnvironment and Message):
SET OutputLocalEnvironment = InputLocalEnvironment;
SET OutputLocalEnvironment.Variables.RequestId = InputLocalEnvironment.Destination.HTTP.RequestIdentifier;
SET OutputLocalEnvironment.Variables.Language = InputRoot.HTTPInputHeader."Accept-Language";
SET OutputLocalEnvironment.Destination.SOAP.Request.UserContext = CAST(ASBITSTREAM(OutputLocalEnvironment.Variables) as BLOB);
In SetRequestId compute node:
DECLARE UserContext BLOB;
SET UserContext = InputLocalEnvironment.Destination.SOAP.Response.UserContext;
Debug value of the LocalEnvironment after the Map to N node:
LocalEnvironment
Destination
HTTP
RequestIdentifier:BLOB:[B@54d21920
RouterList
DestinationData
labelName:CHARACTER:GET
SOAP
Request
UserContext:BLOB:[B@3d098be1
Debug value after the SOAP Async Response N node:
LocalEnvironment
SOAP
Response
MessageCorrelId:BLOB:[B@a075817
Destination
RouterList
DestinationData
labelName:CHARACTER:findXYZ
Though the LocalEnvironment is correctly set after the Map to N node (see debug above), the value of UserContext
is always null.
edit: Except for the UserContext problem, my flow is working properly. To answer the first comment, yes, the unique identifiers are correctly set.
I didn't succeed to pass the Variables tree structure but I found a workaround by concatenating the values and storing it into a BLOB. Neither it is the cleanest way to resolve it, nor is this solution easy to implement when dealing with more than two objects.
In Map To D Compute Node:
SET ConcatenatedContext = 'YourFirstString' || ';' || 'YourSecondString';
SET OutputLocalEnvironment.Destination.SOAP.Request.UserContext = CAST(ConcatenatedContext AS BLOB CCSID 1208);
In SetRequestId Compute Node:
DECLARE RawValue CHARACTER;
SET RawValue = CAST(InputLocalEnvironment.SOAP.Response.UserContext AS CHARACTER CCSID 1208);
SET FirstString = SUBSTRING(RawValue BEFORE ';');
SET SecondString = SUBSTRING(RawValue AFTER ';');