Use Base64 encoding to send PDF files or images in a SOAP message
A developer asks: We want to send a SOAP request to our Process Commander application that will call a service. Our application then needs to create a PDF form (filled in with the value of properties received in the SOAP request), and send the resulting PDF document to the caller in the SOAP response.
The PDF document, created by eForm rules, is stored in the pyEForm property, which is of mode
What is the recommended way to return this PDF document as the SOAP response?
Property pyEForm holds the binary image of the PDF file. You need to make a Base64-encoded version of the image to send as characters over SOAP. Speaking strictly, you need to text-encode it; and Base64 is the recommended technique.
The receiving application needs to decode it, and then it would be back to the binary image of the PDF.
For an example of Base64 encoding, review the standard activity Work-. AttachEForm, which calls PublicAPI methods in
com.pega.pegarules.pub.util.Base64Util to perform such encoding.