【问题标题】:eventNotification XML structure事件通知 XML 结构
【发布时间】:2013-10-29 13:20:25
【问题描述】:

我正在按照 docusign rest api v2,第 93 页中的“发送信封或创建草稿信封”发送文档​​以供签名。

文档已发送并签名,但我在使用事件通知功能时遇到了问题。

我对此功能的 xml 结构有点困惑。我尝试了很多不同的组合,但我无法弄清楚。有什么帮助吗?

这是我尝试过的众多方法之一......

<eventNotification>
    <url>xxxxxx</url>
    <includeDocuments>false</includeDocuments>
    <loggingEnabled>true</loggingEnabled>
    <envelopeEvents>
        <envelopeEvent>
            <envelopeEventStatusCode>completed</envelopeEventStatusCode>
        </envelopeEvent>
    </envelopeEvents>
</eventNotification>

【问题讨论】:

  • 当您说您无法弄清楚时,这是否意味着您遇到了错误?如果是的话,它是怎么说的?
  • 对不起,我离开了一个星期才回来!我没有收到错误,但 docusign 只是不发送消息。你的xml格式和我的差不多,但我会匹配大写字母,看看是否有区别

标签: xml envelope docusignapi


【解决方案1】:

Kim 说得对,DocuSign 目前没有很好的 XML 格式请求正文文档。然而,有时由于技术限制、您不想重新编写解析代码或其他原因,JSON 不是一个选项,并且开发人员被 XML 格式卡住了。

话虽如此,以下是 eventNotifications 对象的正确 XML 格式,以及您可以在其上设置的所有可能属性:

<eventNotification>
   <EnvelopeEvents>
      <envelopeEvent>
         <envelopeEventStatusCode>sample string 1</envelopeEventStatusCode>
         <includeDocuments>sample string 2</includeDocuments>
      </envelopeEvent>
      <envelopeEvent>
         <envelopeEventStatusCode>sample string 1</envelopeEventStatusCode>
         <includeDocuments>sample string 2</includeDocuments>
      </envelopeEvent>
   </EnvelopeEvents>
   <includeCertificateWithSoap>sample string 6</includeCertificateWithSoap>
   <includeDocuments>sample string 8</includeDocuments>
   <includeEnvelopeVoidReason>sample string 9</includeEnvelopeVoidReason>
   <includeSenderAccountAsCustomField>sample string 11</includeSenderAccountAsCustomField>
   <includeTimeZone>sample string 10</includeTimeZone>
   <loggingEnabled>sample string 2</loggingEnabled>
   <recipientEvents>
      <recipientEvent>
         <includeDocuments>sample string 2</includeDocuments>
         <recipientEventStatusCode>sample string 1</recipientEventStatusCode>
      </recipientEvent>
      <recipientEvent>
         <includeDocuments>sample string 2</includeDocuments>
         <recipientEventStatusCode>sample string 1</recipientEventStatusCode>
      </recipientEvent>
   </recipientEvents>
   <requireAcknowledgment>sample string 3</requireAcknowledgment>
   <signMessageWithX509Cert>sample string 7</signMessageWithX509Cert>
   <soapNameSpace>sample string 5</soapNameSpace>
   <url>sample string 1</url>
   <useSoapInterface>sample string 4</useSoapInterface>
</eventNotification>

【讨论】:

  • 谢谢,埃尔金!似乎让这个工作的关键是为 EnvelopeEvents 元素使用正确的“案例”——即,将“信封”和“事件”都大写。如果您改用“envelopeEvents”(小写“envelope”和大写“Events”),它就不起作用。通常与 DocuSign REST API 元素的命名不一致(通常以小写字母开头),但很高兴知道它是这样工作的。我将更新我之前的响应以包含一个成功触发 Connect 通知的 XML 请求。
【解决方案2】:

虽然从技术上讲,DocuSign REST API 支持 XML 格式和 JSON 格式,但大多数 DocuSign REST API 文档、代码示例和开发人员资源都是 JSON 格式。不幸的是,这意味着尝试将 XML 格式与 DocuSign REST API 一起使用(执行非常基本的任务之外的任何事情)可能会非常令人沮丧——因为当您的 XML 请求无法按预期工作时,您几乎没有资源来弄清楚什么正确的格式是。

因此,我建议您考虑在 DocuSign REST API 中使用 JSON 而不是 XML。这是一个成功创建信封通知的 JSON 请求。

POST https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes
{
  "templateId": "TEMPLATE_ID",
  "templateRoles": [
   {
      "roleName": "Signer1",
      "name": "John Doe",
      "email": "johnsemail@outlook.com"
    }
  ],
  "eventNotification":       {
    "url": "http://www.google.com",
    "loggingEnabled": "true",
    "requireAcknowledgement": "true",
    "includeDocuments" : "false",
    "envelopeEvents" : [{
      "envelopeEventStatusCode" : "completed"     
    }]
  },
  "status": "sent"
}

更新:使用下面 Ergin 提供的信息,我能够使用 XML 来实现这一点——关键是 中的“信封”和“事件”都使用大写>EnvelopeEvents 元素。下面是一个成功触发 Connect 通知的请求示例:

POST https://{{env}}.docusign.net/restapi/{{version}}/accounts/{{acctId}}/envelopes
<envelopeDefinition xmlns="http://www.docusign.com/restapi">
   <accountId>ACCOUNT_ID</accountId>
   <status>sent</status>
   <templateId>TEMPLATE_ID</templateId>
   <templateRoles>
      <templateRole>
         <email>johnsemail@outlook.com</email>
         <name>John Doe</name>
         <roleName>Signer1</roleName>
      </templateRole>
   </templateRoles>
   <eventNotification>
    <EnvelopeEvents>
      <envelopeEvent>
        <envelopeEventStatusCode>completed</envelopeEventStatusCode>
      </envelopeEvent>
    </EnvelopeEvents>
    <includeDocuments>false</includeDocuments>
    <loggingEnabled>true</loggingEnabled>
    <requireAcknowledgement>true</requireAcknowledgement>
    <url>http://www.google.com</url>
   </eventNotification>
</envelopeDefinition>

【讨论】:

  • 我不想在代码中使用json和xml,也不想把我所有的xml代码都转换成json。我要等着看有没有人知道答案。我了解 json 有更多示例,但我认为他们需要记录 xml 结构。他们所有的 java api 演练都使用 xml...
  • 是的,AFAIK “演练”示例是您可以找到使用 REST API 的 XML 格式示例的唯一地方。不幸的是,这些演练仅说明了非常基本的场景,请求中使用了最少的参数(元素)。完全同意,DocuSign 用 REST 实际记录 XML 的完整请求/响应结构会很棒。祝你好运!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多