0

我已经为此工作了几天,无法弄清楚。我正在尝试创建使用 ColdFusion 向 EchoSign 发送 WSDL Web 服务请求所需的数据结构。我对发送简单结构(testPing 和 testEchoFile 工作)没有任何问题,但是当我尝试发送文档所需的嵌套结构(sendDocument)时,它失败说“无法找到带有参数的 Web 服务操作 sendDocument ...。这是众多尝试之一:

<cfset strFilePath = "#ExpandPath("tempupload/file.pdf")#" />
<cffile action="readbinary" file="#strFilePath#" variable="FileData" >
<cfscript>
apiKey = "MY_API_KEY";

documentCreationInfo = structNew();
documentCreationInfo.recipients = structNew();
    documentCreationInfo.recipients.recipientInfo = arrayNew(1);
    documentCreationInfo.recipients.recipientInfo[1] = structNew();
    documentCreationInfo.recipients.recipientInfo[1].email = "myemail@gmail.com";
    documentCreationInfo.recipients.recipientInfo[1].role = "SIGNER";
documentCreationInfo.name = "test";
documentCreationInfo.fileInfos = structNew();
    documentCreationInfo.fileInfos.fileInfo = arrayNew(1);
    documentCreationInfo.fileInfos.fileInfo[1] = structNew();
    documentCreationInfo.fileInfos.fileInfo[1].fileName = "file.pdf";
    documentCreationInfo.fileInfos.fileInfo[1].file = #FileData#;
documentCreationInfo.signatureType = "ESIGN";
documentCreationInfo.signatureFlow = "SENDER_SIGNATURE_NOT_REQUIRED";

ws = createObject("webservice", "https://secure.echosign.com/services/EchoSignDocumentService16?wsdl");

response = ws.sendDocument(apiKey = '#apiKey#', documentCreationInfo = #documentCreationInfo#);
</cfscript>

我查看了使用其他编程语言的示例,但这并没有太大帮助,因为 ColdFusion 创建的数组和结构的处理方式似乎不同。我想避免构建 SOAP XML。任何帮助将不胜感激。


为清楚起见,以下是使用 ColdFusion 并与 EchoSign 通信以及使用 sendDocument 命令时需要发送的数据结构:

<cfset strFilePath = "#ExpandPath("tempupload/file.pdf")#" />
<cffile action="readbinary" file="#strFilePath#" variable="FileData" >

    <cfscript>
        apiKey = "MY_API_KEY";

            documentCreationInfo = structNew();
            documentCreationInfo.recipients = structNew();
                documentCreationInfo.recipients.recipientInfo = arrayNew(1);
                documentCreationInfo.recipients.recipientInfo[1] = structNew();
                documentCreationInfo.recipients.recipientInfo[1].email = "recipient@gmail.com";
                documentCreationInfo.recipients.recipientInfo[1].role = "SIGNER";
            documentCreationInfo.name = "test";
            documentCreationInfo.fileInfos = structNew();
                documentCreationInfo.fileInfos.fileInfo = arrayNew(1);
                documentCreationInfo.fileInfos.fileInfo[1] = structNew();
                documentCreationInfo.fileInfos.fileInfo[1].fileName = "file.pdf";
                documentCreationInfo.fileInfos.fileInfo[1].file = #FileData#;
            documentCreationInfo.signatureType = "ESIGN";
            documentCreationInfo.signatureFlow = "SENDER_SIGNATURE_NOT_REQUIRED";

            senderInfo = structNew();
                senderInfo.email = "sender@gmail.com";
                senderInfo.password = "password";
                senderInfo.userKey = "";

        ws = createObject("webservice", "https://secure.echosign.com/services/EchoSignDocumentService16?wsdl");
        response = ws.sendDocument(apiKey = '#apiKey#', senderInfo = #senderInfo#, documentCreationInfo = #documentCreationInfo#);
    </cfscript>

对于可以包含多个条目的数据,例如收件人和文件,数据存储在结构数组中。在这个例子中,只有一个收件人,所以数组recipientInfo只有一个数组元素,recipientInfo[1],但是我们可以通过重复本节并使用recipientInfo[2]等轻松添加其他收件人。由于senderInfo不能有多个条目它只是一个包含电子邮件、密码和用户密钥元素的结构。根据文档,userKey 将覆盖电子邮件和密码条目。要使用单点登录,我尝试发送电子邮件、密码和用户密钥的空白数据,但没有成功,我还尝试只发送空的 senderInfo 结构,但没有成功。所以我的问题变成了,如何为 senderInfo 发送一个 NULL 值,使其默认为 API 所有者?

4

1 回答 1

0

在查看了相关Web 服务sendDocument的方法后,您似乎还需要包含参数,该参数在 WSDL 中定义为:senderInfo

<xsd:complexType name="SenderInfo">
  <xsd:sequence>
    <xsd:element minOccurs="0" name="email" nillable="true" type="xsd:string"/>
    <xsd:element minOccurs="0" name="password" nillable="true" type="xsd:string"/>
    <xsd:element minOccurs="0" name="userKey" nillable="true" type="xsd:string"/>
  </xsd:sequence>
</xsd:complexType>

因此,在您创建一个实例senderInfo(可能只是一个空结构)之后,您的 Web 服务调用将如下所示:

response = ws.sendDocument(apiKey = '#apiKey#', documentCreationInfo = documentCreationInfo, senderInfo = senderInfo);

希望有帮助!

于 2013-08-21T03:56:33.980 回答