Situation:- In this use case, web service calls a process flow which encrypts the file. This web service URL or API call is used in another flow where the decryption of the file takes place. This flow decrypts the payload and converts it into the actual output file.
Error:- The decryption of the encrypted file fails with an error:-
unknown object in stream: 47
Solution:- In the process flow where the file is getting encrypted, instead of the ContextTarget activity, there is a need to use the Custom Plugin activity which captures the restResponse. So, the key point is that the encapsulation of encrypted data in Rest Response should be through the custom plugin and not directly into the context target.
Below is the custom plugin code for the same:-
ByteArrayOutputStream baosKey = new ByteArrayOutputStream();
Also, in the WebPD, set the generate stream to false for this custom plugin activity :-
After following the above steps, the flow will execute as expected.