on 04-19-2024 8:40 AM
Hello SAP Experts,
I currently have a problem that I could not find out exactly how I can read a binary value from the Partner Directory via a Groovy Script ( inside the I-Flow).
Writing, updating and reading the binary value via Postman works as desired, here I have stored the XML as Base64 in the Partner Directory
{
"Pid":"{{ _.pd_pid }}",
"Id":"TEST",
"ContentType":"xml",
"Value":"PHJvb3Q+CiAgICA8Y3VzdG9tZXI+CiAgICAgICAgPEN1c3RvbWVySUQ+dGVzdDwvQ3VzdG9tZXJJRD4KICAgICAgICA8Q3JlZGVudGlhbF9FVkVOVE0+dGVzdDwvQ3JlZGVudGlhbF9FVkVOVE0+CiAgICA8L2N1c3RvbWVyPgo8L3Jvb3Q+"
}
i followed this methods to get the data in the groovy script:
Here would be my approach how I would have read the binary value in my Groovy script
//get Value from PartnerDirectory
paramValue = partnerDirectoryService.getParameter(paramName, callerPID , com.sap.it.api.pd.BinaryData);
if (paramValue == null){
throw new IllegalStateException(paramName + " is not configured in " + paramName + " in Partner Directory");
}
message.setProperty("Test1", paramValue);
message.setProperty("Test2_Data", paramValue.getData());
message.setProperty("Test3_ContentType", paramValue.getContentType());
Reading a ContentType (with getContentType()) works fine, but it seems that a binary value is read in a strange way.
Here are the output of the Output of the Binary Value:
com.sap.esb.pd.rt.external.BinaryDataImpl@5568b8e8
Does anyone have an idea what my error is or has an example code for me?
Many thanks in advance.
Best regards
Chris. P.
Hi Chris,
Could you please add the following code to your script and make a test?
byte[] decoded = Base64.getDecoder().decode(paramValue.getData())
String content = new String(decoded, StandardCharsets.UTF_8)
message.setProperty("Test4_Decoded", content)
BR,
Andrzej
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andrzej_Filusz,
thank you very much for your answer,
i tried to implement you coding, also added the
Is there a additional coding which i need?
Best Regards.
Chris P.
Hi Andrzej_Filusz,
i changed the coding to
//byte[] decoded = Base64.getDecoder().decode(testData)
byte[] decoded = Base64.getMimeDecoder().decode(testData);
String content = new String(decoded, StandardCharsets.UTF_8)
message.setProperty("Test4_Decoded", content)
now i get no errors, but the output seems not correct
Do you have a idea how i could handle this?
Best Regards
Chris P.
User | Count |
---|---|
75 | |
8 | |
8 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.