After the signing process is complete for a document envelope, the DownloadEnvelopeDocuments operation may be used to retrieve the final signed PDF documents for each document in the envelope. By default each completed document will be returned as a separate element in the response, but it is also possible to request that all of the completed documents be merged into a single PDF. This operation will also return the Envelope Completion Report.
The DownloadEnvelopeDocuments operation requires knowledge of the following:
- The EnvelopeId of the envelope to cancel (this is returned as an element in the returned XML from an envelope creation operation)
- The AuthToken of the envelope to cancel (this is returned as an element in the returned XML from an envelope creation operation)
- The AssureSign account ContextIdentifier (this is exposed in the AssureSign administrative application account settings and serves to provide some security to the transaction)
- A MergeCompletedDocuments Boolean flag indicating whether or not to merge all of the completed documents into a single PDF.
- If the envelope is protected by an envelope password, it will be necessary to provide that password as the value for the optional EnvelopePassword attribute.
Sample XML
<?xml version="1.0" encoding="utf-8"?>
<DownloadEnvelopeDocuments xmlns="https://www.assuresign.net/Services/DocumentNOW/Envelopes">
<DownloadEnvelopeDocumentsRequest ContextIdentifier="06C4A84A-693C-46CB-8DF2-40A8215AA056" EnvelopeId="2CE11EF1-8938-DD11-8735-00065B8CE99B" AuthToken="8CC9A84B-693C-46CC-4342-40A8215AD76A" MergeCompletedDocuments="false" EnvelopePassword="Password" />
</DownloadEnvelopeDocuments>
The SOAP Action header is
https://www.assuresign.net/Services/DocumentNOW/Envelopes/IEnvelopeService/DownloadEnvelopeDocuments
The returned result will include the EnvelopeId and either a single MergedDocument element (if theMergeCompletedDocuments flag was set to true in the request) or a Documents element containing an array of all the completed documents in the envelope. Each document will contain the binary data for both the final document and the completion report.
The DownloadEnvelopeDocuments Operation exposes two endpoints allowing it to be executed using either the W3C standard Message Transmission Optimization Mechanism (MTOM) protocol or not. If the MTOM endpoint is used, the returned completed documents (or the single merged document) will be passed in their original raw binary form using XML-binary Optimized Packaging (XOP). If the non-MTOM endpoint is used, these documents will be Base64-encoded and included directly in the response XML itself.
Sample XML (non-MTOM) returned by the DownloadEnvelopeDocuments operation is presented here:
<?xml version="1.0" encoding="utf-8"?>
<DownloadEnvelopeDocumentsResponse xmlns="https://www.assuresign.net/Services/DocumentNOW/Envelopes">
<DownloadEnvelopeDocumentsResult EnvelopeId="2CE11EF1-8938-DD11-8735-00065B8CE99B">
<Documents>
<EnvelopeDocument DocumentId="19c1a800-42e8-df11-9b14-0022195a8cb4" AuthToken="f4aaf447-8cfa-4701-9951-b4a063653c04" Name="Document 1" OrderId="1234">
<CompletedDocument>
<Data>RG9jdW1lbnQgMQ==</Data>
</CompletedDocument>
</EnvelopeDocument>
<EnvelopeDocument DocumentId="28b1a800-42e8-df11-9b14-0022195a8cb4" AuthToken="cd33f44a-4cff-3301-aa5c-cdf0636ddc0b" Name="Document 2" OrderId="5678">
<CompletedDocument>
<Data>RG9jdW1lbnQgMg==</Data>
</CompletedDocument>
</EnvelopeDocument>
</Documents>
<CompletionReport>
<Data>Q29tcGxldGlvblJlcG9ydA==</Data>
</CompletionReport>
</DownloadEnvelopeDocumentsResult>
</DownloadEnvelopeDocumentsResponse>
The DownloadEnvelopeDocumentsResult should be checked for the presence of an Exceptions element, which may contain multiple EnvelopeException items.