C# 使用DocuSign TemplateReference包装InlineTemplate需要双倍的负载?

C# 使用DocuSign TemplateReference包装InlineTemplate需要双倍的负载?,c#,docusignapi,C#,Docusignapi,我试图通过结合服务器上的模板和本地PDF文档来测试DocuSign 下面的代码可以工作,但是,我担心我在InlineTemplate上发送的负载是原来的两倍 public virtual TemplateReference CreateInlineTemplate(Recipient[] recipients, AdHocTemplate adHocTemplate, int sequenceId) { var templateReference = new TemplateReferenc

我试图通过结合服务器上的模板和本地PDF文档来测试DocuSign

下面的代码可以工作,但是,我担心我在
InlineTemplate
上发送的负载是原来的两倍

public virtual TemplateReference CreateInlineTemplate(Recipient[] recipients, AdHocTemplate adHocTemplate, int sequenceId)
{
  var templateReference = new TemplateReference();
  templateReference.TemplateLocation = TemplateLocationCode.SOAP;

  var inlineTemplate = new InlineTemplate
  {
      Sequence = sequenceId.ToString(CultureInfo.InvariantCulture),
      Envelope = new Envelope
      {
          Recipients = recipients, AccountId = _apiAccountId
      }
  };

  var document = new Document
  {
      ID = sequenceId.ToString(CultureInfo.InvariantCulture),
      Name = string.IsNullOrWhiteSpace(adHocTemplate.Name)
                 ? "Contract " + sequenceId
                 : adHocTemplate.Name,
      PDFBytes = adHocTemplate.Bytes,
      FileExtension = ".pdf",
  };

  // added once
  inlineTemplate.Envelope.Documents = new[] { document };

  // added twice. Effectively doubled the size of the message.
  templateReference.Document = document;
  templateReference.Template = SerializeTemplate(inlineTemplate);
  templateReference.RoleAssignments = CreateRoleAssignments(recipients).ToArray();

  return templateReference;
}
如您所见,我正在使用本地文件创建一个
文档
,然后将其提供给
InlineTemplate
TemplateReference
。这似乎是让它成功发送的唯一方法

如果我没有将文档提供给内联模板,则会出现以下错误:

“无法加载模板。无法从中加载模板。” TemplateReference(1)。错误:对象引用未设置为实例 “一个物体的形状”

如果不将其提供给
TemplateReference
,我会收到一个错误,告诉我缓冲区不能为空

尝试仅设置空文档失败,因为它表示文档不完整

有没有一种方法可以在不发送两倍于消息字节的情况下实现此功能?


我考虑过使用
CompositeTemplate
并使用
CreateEnvelopeFromTemplates()和Forms()发送它,但是,我需要预先填充服务器模板上的数据,使用
ServerTemplate
并不能提供添加自定义字段数据的方法。

我认为这可以通过createEnvelopeFromTemplates和Forms()实现。请参阅SOAPAPI指南第76页,并仔细阅读“复合模板使用规则”一节。这一切的运作方式让我困惑了很长一段时间。但基本上,模板都是可添加的,因此您可以在任何InlineTemplate中包含一个选项卡来设置服务器模板字段值,其中TabLabel与服务器模板上的字段标签匹配。第80页的文档中提供了一个很好的例子。(搜索“来自内联模板”)

在我的示例中,我的服务器模板有一个TabLabel为“MyField”的数据字段,因此该选项卡被放入InlineTemplate中以设置值

<ns:Tab>
    <ns:RecipientID>1</ns:RecipientID>
    <ns:TabLabel>MyField</ns:TabLabel>
    <ns:Value>Value from Inline Template</ns:Value>
    <ns:Type>Custom</ns:Type>
</ns:Tab>


1.
麦菲尔德
来自内联模板的值
习俗
我附上了我在试图解决你的问题时提出的请求。它的另一个问题是,CompositeTemplate似乎只能包含一组文档。因此,您需要拆分为两个CompositeTemplate。但我肯定能够填充我的“MyField”服务器模板字段

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.docusign.net/API/3.0">
   <soapenv:Header/>
   <soapenv:Body>
      <ns:CreateEnvelopeFromTemplatesAndForms>
         <ns:EnvelopeInformation>
            <ns:AccountId>ACCOUNT ID</ns:AccountId>            
         </ns:EnvelopeInformation>
         <ns:CompositeTemplates>
            <ns:CompositeTemplate>
               <ns:ServerTemplates>
                  <ns:ServerTemplate>
                     <ns:Sequence>1</ns:Sequence>
                     <ns:TemplateID>TEMPLATE ID</ns:TemplateID>
                  </ns:ServerTemplate>
               </ns:ServerTemplates>
               <ns:InlineTemplates>
                  <ns:InlineTemplate>
                     <ns:Sequence>2</ns:Sequence>
                     <ns:Envelope>
                        <ns:Asynchronous>false</ns:Asynchronous>
                        <ns:AccountId>ACCOUNT ID</ns:AccountId>
                        <ns:Recipients>
                           <ns:Recipient>
                              <ns:ID>1</ns:ID>
                              <ns:UserName>John Q Signer</ns:UserName>
                              <ns:Email>EMAIL HERE</ns:Email>
                              <ns:Type>Signer</ns:Type>
                              <ns:RoleName>Signer1</ns:RoleName>
                              <ns:RoutingOrder>1</ns:RoutingOrder>
                           </ns:Recipient>
                        </ns:Recipients>

                        <ns:Documents>      
                           <ns:Document>
                              <ns:ID>1</ns:ID>
                              <ns:Name>Inline Document</ns:Name>
                              <ns:PDFBytes>PDF BYTES HERE</ns:PDFBytes>
                              <ns:TransformPdfFields>false</ns:TransformPdfFields>
                           </ns:Document>
                        </ns:Documents>

                        <ns:Tabs>
                           <ns:Tab>
                            <ns:RecipientID>1</ns:RecipientID>
                            <ns:TabLabel>MyField</ns:TabLabel>
                            <ns:Value>Updated by Inline Template</ns:Value>
                            <ns:Type>Custom</ns:Type>
                        </ns:Tab>

                           <ns:Tab>
                              <ns:RecipientID>1</ns:RecipientID>
                              <ns:AnchorTabItem>
                                 <ns:AnchorTabString>{{s1_sign}}</ns:AnchorTabString>
                                 <ns:XOffset>0</ns:XOffset>
                                 <ns:YOffset>0</ns:YOffset>
                                 <ns:IgnoreIfNotPresent>true</ns:IgnoreIfNotPresent>
                              </ns:AnchorTabItem>                             
                              <ns:Type>SignHere</ns:Type>
                           </ns:Tab>
                           <ns:Tab>
                              <ns:RecipientID>1</ns:RecipientID>
                              <ns:AnchorTabItem>
                                 <ns:AnchorTabString>{{s1_initial}}</ns:AnchorTabString>
                                 <ns:XOffset>0</ns:XOffset>
                                 <ns:YOffset>0</ns:YOffset>
                                 <ns:IgnoreIfNotPresent>true</ns:IgnoreIfNotPresent>
                              </ns:AnchorTabItem>                             
                              <ns:Type>InitialHere</ns:Type>
                           </ns:Tab>
                        </ns:Tabs>

                        <ns:Subject>Composite Test</ns:Subject>
                        <ns:EmailBlurb>Composite Test</ns:EmailBlurb>
                        <ns:SigningLocation>Online</ns:SigningLocation>
                          <ns:AutoNavigation>false</ns:AutoNavigation>
                          <ns:EnvelopeIdStamping>false</ns:EnvelopeIdStamping>
                          <ns:AuthoritativeCopy>false</ns:AuthoritativeCopy>
                        <ns:Notification>
                           <ns:UseAccountDefaults>false</ns:UseAccountDefaults>
                           <ns:Reminders>
                              <ns:ReminderEnabled>false</ns:ReminderEnabled>
                              <ns:ReminderDelay>1</ns:ReminderDelay>
                              <ns:ReminderFrequency>1</ns:ReminderFrequency>
                           </ns:Reminders>
                           <ns:Expirations>
                              <ns:ExpireEnabled>true</ns:ExpireEnabled>
                              <ns:ExpireAfter>2</ns:ExpireAfter>
                              <ns:ExpireWarn>1</ns:ExpireWarn>
                           </ns:Expirations>
                        </ns:Notification>                        
                        <ns:EnforceSignerVisibility>true</ns:EnforceSignerVisibility>
                        <ns:EnableWetSign>false</ns:EnableWetSign>
                        <ns:AllowMarkup>false</ns:AllowMarkup>
                        <ns:AllowReassign>false</ns:AllowReassign>
                        <ns:BrandId>BRAND ID</ns:BrandId>
                        <ns:BrandLock>true</ns:BrandLock>
                        <ns:MessageLock>true</ns:MessageLock>
                        <ns:RecipientsLock>true</ns:RecipientsLock>
                     </ns:Envelope>
                  </ns:InlineTemplate>
               </ns:InlineTemplates>               
            </ns:CompositeTemplate>
         </ns:CompositeTemplates>
         <ns:ActivateEnvelope>true</ns:ActivateEnvelope>
      </ns:CreateEnvelopeFromTemplatesAndForms>
   </soapenv:Body>
</soapenv:Envelope>

帐户ID
1.
模板ID
2.
假的
帐户ID
1.
约翰Q签名者
在此处发送电子邮件
签字人
签字人1
1.
1.
内联文档
这里是PDF字节
假的
1.
麦菲尔德
由内联模板更新
习俗
1.
{{s1_符号}
0
0
真的
签名处
1.
{{s1_initial}}
0
0
真的
首字母
综合试验
综合试验
在线 的
假的
假的
假的
假的
假的
1.
1.
真的
2.
1.
真的
假的
假的
假的
品牌标识
真的
真的
真的
真的

那么服务器模板将从内联模板中读取选项卡以填充自己的字段?我必须在周一对此进行测试,因为我们最近发现我们必须调用
createEnvelopeFromTemplates和表单来实现另一个目的。是的。其思想是,在每个模板中不需要整个信封,它们可以是部分的,就像定义收件人一样。它从每个模板中获取元素,并使用优先顺序将其组合成一个巨大的信封。有三个以上不同的地方来定义一些东西可能会让人困惑