/// <summary>
        /// <c>AssembleDocument</c> assembles (creates) a document from the given template, answers and settings.
        /// </summary>
        /// <param name="template">An instance of the Template class, from which the document will be assembled.</param>
        /// <param name="answers">The set of answers that will be applied to the template to assemble the document</param>
        /// <param name="settings">settings that will be used to assemble the document. 
        /// These settings include the assembled document format (file extension), markup syntax, how to display fields with unanswered variables, etc</param>
        /// <param name="logRef">A string to display in logs related to this request.</param>
        /// <returns>returns information about the assembled document, the document type, the unanswered variables, the resulting answers, etc.</returns>
        public AssembleDocumentResult AssembleDocument(Template template, TextReader answers, AssembleDocumentSettings settings, string logRef)
        {
            // Validate input parameters, creating defaults as appropriate.
            string logStr = logRef == null ? string.Empty : logRef;

            if (template == null)
                throw new ArgumentNullException("template", string.Format(@"WebService.Services.AssembleDocument: the ""template"" parameter passed in was null, logRef: {0}", logStr));

            if (settings == null)
                settings = new AssembleDocumentSettings();

            AssembleDocumentResult result = null;
            AssemblyResult asmResult = null;

            using (Proxy client = new Proxy(_endPointName))
            {
                OutputFormat outputFormat = ConvertFormat(settings.Format);
                AssemblyOptions assemblyOptions = ConvertOptions(settings);
                string fileName = GetRelativePath(template.GetFullPath());
                asmResult = client.AssembleDocument(
                    fileName,
                    answers == null ? null : new BinaryObject[] { Util.GetBinaryObjectFromTextReader(answers) }, // answers
                    outputFormat,
                    assemblyOptions,
                    null);
                SafeCloseClient(client, logRef);
            }

            if (asmResult != null)
            {
                result = Util.ConvertAssemblyResult(template, asmResult, settings.Format);
            }

            return result;
        }