0
votes

While debugging my Connect listener (REST, Java), I am trying to create a PDF document based on xml in the Connect log for Demo. (I have to emulate Docusign POST request while security issues are being resolved.) I have DocuSign Connect Service activated with “Include Documents” and "Include Certificate of Completion" checked. I can see Attachment element in the log’s xml but not DocumentPDF element. When saving content as a byte array into PDF file and then trying to open it, it cannot be opened in Acrobat. Is Attachment element in the Connect Log supposed to be a PDF document?

Here is my code to convert to pdf file:

String documentName = parseXMLDoc(xmlDoc, "DocumentStatus[1]/Name");

SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd HHmmsss");
String nowTime = fmt.format(new Date());
OutputStream out = new FileOutputStream("c:\\temp\\"+documentName.replaceAll(".pdf","_"+nowTime+".pdf"));

BASE64Decoder decoder = new BASE64Decoder();
String encodedBytes = parseXMLDoc(xmlDoc, "Attachment/Data");
byte[] decodedBytes = decoder.decodeBuffer(encodedBytes);   
out.write(decodedBytes);
out.close();

where parseXMLDoc is

public static String parseXMLDoc(Document xmlDoc, String searchToken) {
    String xPathExpression;
    try {
        XPath xPath = XPathFactory.newInstance().newXPath();
        xPathExpression = "//" + searchToken;
        return (xPath.evaluate(xPathExpression, xmlDoc));
    } catch (Exception e) {
            throw new RuntimeException(e);
    }
}
2
Can you show your code that is doing the conversion from bytes to pdf file? - Andrew
Hi Andrew, I added my code to the question; I just realized that the resulting file is not a PDF file but a normal XML for <FormData><xfdf><fields>. So my question "Is Attachment element in the Connect Log supposed to be a PDF document?" still stands. - GalaNY
If your connect settings are set to Include Document, then it should return in the Documents node as bytes - Andrew
My Demo Connect settings have “Include Documents” and “Include Certificate of Completion” checked but there is no Documents node in the log. There is no <DocumentPDFs> node either. Are they supposed to be present in the Connect Log (as opposed to the Connect Message which is unavailable to me right now)? - GalaNY
<DocumentPDFs> <DocumentPDF> <Name>documentName.pdf</Name> <PDFBytes>{omitted}</PDFBytes> <DocumentType>CONTENT</DocumentType> </DocumentPDF> </DocumentPDFs> Is what you should be seeing - Andrew

2 Answers

0
votes

No the Connect log does NOT contain the actual document bytes... the documents are only included in the actual Connect pushes to your external listener. The log files simply contain metadata around the transaction, not the actual content.

0
votes

You can possibly get a full response from DocuSign by using https://Webhook.site where you will be given a temporary URL for listening. Plug the temporary URL into the DocuSign Connection (create a new connection for testing), and open the XML packet from the dashboard on the webhook site dashboard when it arrives from DocuSign.