无法转换数据

时间:2014-09-18 21:51:13

标签: docusignapi

我有一个工作函数调用Docusign SOAP API,现在突然间它无法正常工作。当我调用CreateEnvelopeFromTemplatesAndForms方法时,我收到错误“数据无法转换”。这是我的代码。

Dim _userName As String = ""

Dim _apiUrl As String = "https://demo.docusign.net/api/3.0/api.asmx"

Dim _accountId As String = "d90f6802-fa06-42b4-ac3b-5959c3905002"

Dim _password As String = "WWWxyz123"

Dim _email As String = "JGarland@etgroup.net"

Dim _integratorKey As String = "ETGX-1f61c95b-06bd-400b-9604-f247fda0238c"

Sub Main()

    'GetSignatureSpot(Nothing)
    'GetPDF()
    'GetCertificate()
    'Exit Sub

    _userName = "[" + _integratorKey + "]"
    _userName = _userName & _email

    Dim _apiClient As DocuSign.DSAPIServiceSoapClient = New DocuSign.DSAPIServiceSoapClient("DSAPIServiceSoap", _apiUrl)

    _apiClient.ClientCredentials.UserName.UserName = _userName

    _apiClient.ClientCredentials.UserName.Password = _password

    Dim envelopeInfo As DocuSign.EnvelopeInformation = New DocuSign.EnvelopeInformation()

    envelopeInfo.AccountId = _accountId

    envelopeInfo.EmailBlurb = "Please Sign Your Loan Documents"

    envelopeInfo.Subject = "Please Sign Your Loan Documents"

    'Recipients
    Dim recipient1 As DocuSign.Recipient = New DocuSign.Recipient()

    recipient1.UserName = "John Doe"
    recipient1.Email = "Support@etgroup.net"
    recipient1.Type = DocuSign.RecipientTypeCode.Signer
    recipient1.RoutingOrder = 1
    recipient1.RoutingOrderSpecified = True
    recipient1.RoleName = "Borrower 1"
    recipient1.ID = "1"

    Dim recipient2 As DocuSign.Recipient = New DocuSign.Recipient()

    recipient2.UserName = "Jane Doe"
    recipient2.Email = "JGarland@etgroup.net"
    recipient2.Type = DocuSign.RecipientTypeCode.Signer
    recipient2.RoutingOrder = 2
    recipient2.RoutingOrderSpecified = True
    recipient2.RoleName = "Borrower 2"
    recipient2.ID = "2"

    Dim signers(1) As DocuSign.Recipient

    signers(0) = recipient1
    signers(1) = recipient2

    'Create draft with all the composite template information
    Dim status As DocuSign.EnvelopeStatus
    Dim compositTemplate(1) As DocuSign.CompositeTemplate

    Dim template As DocuSign.CompositeTemplate
    Dim template2 As DocuSign.CompositeTemplate

    'Template 1
    template = CreateTemplate(1, "Attorney Selection Notice", "F364E20C-D0E6-4735-89E2-8891424BA364", signers, "AttorneySelection.pdf")

    compositTemplate(0) = template

    'Template 2
    template2 = CreateTemplate(2, "Notice of No Oral", "F5A536C3-81AB-4C32-B56A-9F764624C3C4", signers, "NoticeOral.pdf")

    compositTemplate(1) = template2

    status = _apiClient.CreateEnvelopeFromTemplatesAndForms(envelopeInfo, compositTemplate, True)

End Sub

Private Function CreateTemplate(sequence As Integer, templateName As String, templateID As String, signers() As DocuSign.Recipient, docPath As String) As DocuSign.CompositeTemplate

    Dim template As DocuSign.CompositeTemplate = New DocuSign.CompositeTemplate()

    'Server Template
    Dim serverTemplate As DocuSign.ServerTemplate = New DocuSign.ServerTemplate()

    serverTemplate.Sequence = sequence
    serverTemplate.TemplateID = templateID

    Dim serverTemplates(0) As DocuSign.ServerTemplate
    serverTemplates(0) = serverTemplate

    template.ServerTemplates = serverTemplates

    'Inline Template
    Dim inlineTemplate As DocuSign.InlineTemplate = New DocuSign.InlineTemplate()

    inlineTemplate.Sequence = "1"
    inlineTemplate.Envelope = New DocuSign.Envelope()
    inlineTemplate.Envelope.Recipients = signers
    inlineTemplate.Envelope.AccountId = _accountId

    Dim inlineTemplates(0) As DocuSign.InlineTemplate
    inlineTemplates(0) = inlineTemplate

    template.InlineTemplates = inlineTemplates

    'Document.
    template.Document = New DocuSign.Document()
    template.Document.ID = "1"
    template.Document.Name = ""
    template.Document.PDFBytes = System.IO.File.ReadAllBytes(path:=docPath)
    template.Document.FileExtension = "pdf"

    Return template

End Function

1 个答案:

答案 0 :(得分:0)

根据DocuSign信托中心的说法,最近看起来DocuSign Demo环境(服务器)存在问题。这很可能是导致您的问题的原因。

目前已解决这些问题,现在您的信封应该再次正常工作。作为参考,这是DocuSign信任中心,监控DEMO环境:

https://trust.docusign.com/system-status/demo