1

我正在使用以下代码来调用docusign api。我从这个链接得到了信息。

<soap:Body>
    <ns:CreateEnvelopeFromTemplates>
      <ns:TemplateReferences>
        <ns:TemplateReference>
          <ns:TemplateLocation>Server</ns:TemplateLocation>
          <ns:Template>XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX</ns:Template>
          <ns:RoleAssignments>
            <ns:RoleAssignment>
              <ns:RoleName>Company</ns:RoleName>
              <ns:RecipientID>1</ns:RecipientID>
            </ns:RoleAssignment>
          </ns:RoleAssignments>
        </ns:TemplateReference>
      </ns:TemplateReferences>
      <ns:Recipients>
        <ns:Recipient>
          <ns:ID>1</ns:ID>
          <ns:UserName>Fred Flintstone</ns:UserName>
          <ns:Email>fred.flintstone@...</ns:Email>
          <ns:Type>Signer</ns:Type>
          <ns:RoleName>Caveman</ns:RoleName>
          <ns:RoutingOrder>1</ns:RoutingOrder>
        </ns:Recipient>
      </ns:Recipients>
      <ns:EnvelopeInformation>
        <ns:AccountId>XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX</ns:AccountId>
        <ns:EmailBlurb>This Envelope was sent through the DocuSign API using ColdFusion</ns:EmailBlurb>
        <ns:Subject>DocuSign it! using ColdFusion</ns:Subject>
      </ns:EnvelopeInformation>
      <ns:ActivateEnvelope>true</ns:ActivateEnvelope>
    </ns:CreateEnvelopeFromTemplates>
  </soap:Body>

我无法理解 Template 下的 RoleAssignment 标签的用途。我已经浏览了这里的文档,但不明白。

我认为这是我没有得到回应的唯一原因。我在我的代码中评论了这部分,但在更改所有凭据后我得到了以下输出。

An error occurred!
struct
Charset  [empty string]
ErrorDetail  Unknown host: demo.docusign.net
Filecontent  Connection Failure
Header   [empty string]
Mimetype     Unable to determine MIME type of file.
Responseheader  
struct [empty]
Statuscode   Connection Failure. Status code unavailable.
Text     YES

谁能帮我解决这个问题?

4

3 回答 3

2

我认为这RoleAssignment与该特定错误无关。您需要结合他们示例中的 SOAP Header 和 SOAP Body。SOAP Body 应该包含在 SOAP Header 块中。

请注意,他们的 SOAP Header 示例包含该<soap:Body>块。<soap:Body>然后他们的 SOAP Body 示例也被块包围了。它们应该像这样组合以供您<cfhttp>调用:

<cfset UserName = "[XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX]XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXX" />
<cfset Password = "SuperSecret" />

<cfscript>
  strNonce = ToBase64(createUUID());
</cfscript>

<!--- create the request body XML block --->
<cfsavecontent variable="request_xml">
<cfoutput>
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:ns="http://www.docusign.net/API/3.0">
  <soap:Header>
    <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
        <wsse:UsernameToken wsu:Id="UsernameToken-1" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            <wsse:Username>#UserName#</wsse:Username>
            <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0##PasswordText">#Password#</wsse:Password>
            <wsse:Nonce EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0##Base64Binary">#strNonce#</wsse:Nonce>
        </wsse:UsernameToken>
    </wsse:Security>
  </soap:Header>  
  <soap:Body>
    <ns:CreateEnvelopeFromTemplates>
      <ns:TemplateReferences>
    <ns:TemplateReference>
      <ns:TemplateLocation>Server</ns:TemplateLocation>
      <ns:Template>XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX</ns:Template>
      <ns:RoleAssignments>
        <ns:RoleAssignment>
          <ns:RoleName>Company</ns:RoleName>
          <ns:RecipientID>1</ns:RecipientID>
        </ns:RoleAssignment>
      </ns:RoleAssignments>
    </ns:TemplateReference>
      </ns:TemplateReferences>
      <ns:Recipients>
    <ns:Recipient>
      <ns:ID>1</ns:ID>
      <ns:UserName>Fred Flintstone</ns:UserName>
      <ns:Email>fred.flintstone@...</ns:Email>
      <ns:Type>Signer</ns:Type>
      <ns:RoleName>Caveman</ns:RoleName>
      <ns:RoutingOrder>1</ns:RoutingOrder>
    </ns:Recipient>
      </ns:Recipients>
      <ns:EnvelopeInformation>
    <ns:AccountId>XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX</ns:AccountId>
    <ns:EmailBlurb>This Envelope was sent through the DocuSign API using ColdFusion</ns:EmailBlurb>
    <ns:Subject>DocuSign it! using ColdFusion</ns:Subject>
      </ns:EnvelopeInformation>
      <ns:ActivateEnvelope>true</ns:ActivateEnvelope>
    </ns:CreateEnvelopeFromTemplates>
  </soap:Body>
</soap:Envelope>
</cfoutput>
</cfsavecontent>

(这个例子直接取自他们的文档。我只结合了这两个块。)

然后发送该请求(来自他们的示例):

<!--- send the request to the DocuSign service --->
<cfhttp url="https://demo.docusign.net/api/3.0/api.asmx" method="post" result="http_response">

  <!--- make sure you set this correctly for the call you are making --->
  <cfhttpparam type="header" name="SOAPAction" value="http://www.docusign.net/API/3.0/CreateEnvelopeFromTemplates" />
  <cfhttpparam type="header" name="accept-encoding" value="no-compression" />
  <cfhttpparam type="xml" value="#trim(request_xml)#" />
</cfhttp>

最后处理响应(来自他们的示例):

<!--- if we received a successful response --->
<cfif find("200", http_response.statusCode)>
  <cfscript>
    response_xml = xmlParse(http_response.fileContent);

    // use XPath to get the top level element you want from the SOAP response
    result_node = xmlSearch(response_xml, "//*[local-name() = 'CreateEnvelopeFromTemplatesResult']")[1];

    // use dot notation to navigate the XML structure
    envelope_id = result_node.EnvelopeID.xmlText;
  </cfscript>

  <cfoutput>
    EnvelopeID: #envelope_id#
  </cfoutput>
<cfelse>
  <cfoutput>
    An error occurred!
  </cfoutput>
  <cfdump var="#http_response#">
</cfif>
于 2013-07-03T18:22:25.773 回答
0

如果这是一个 POST 请求(提交数据),看起来好像 web 服务没有识别实际 SOAP XML 文件的提交。

您是否将 XML 作为文档中所示的 XML 类型发送?

<cfhttpparam type="xml" value="#trim(request_xml)#" />
于 2012-06-29T08:24:33.250 回答
0

RoleAssignment 标签用于将收件人分配给特定的模板角色。当您发送使用模板的信封时,您将引用通过 DocuSign 控制台 (demo.docusign.net) 创建的模板。创建模板时,您必须为模板指定至少一个模板角色,其中包含角色名称、收件人姓名和收件人电子邮件。您在此处为角色使用的值需要与您在 api 调用中提供的角色名称相匹配。因此,例如,如果您将角色称为“Signer1”,则需要

<ns:RoleName>Signer1</ns:RoleName>

如果您将角色命名为“公司”,那么您将拥有它。

于 2013-07-05T06:00:28.320 回答