0

I have been working on this for several days now and cannot figure it out. I am trying to create the data structure necessary to send a WSDL webservice request to EchoSign using ColdFusion. I have no problem with sending simple structures (testPing and testEchoFile work), but when I try nested structures like those required for sending a document (sendDocument) it fails saying "Web service operation sendDocument with parameters ... cannot be found. Here is one of the many attempts:

<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>

I have looked at examples using other programming languages, but that was not much help as it seems that the arrays and structures created by ColdFusion are handled differently. I want to avoid having to construct the SOAP XML. Any help would be greatly appreciated.


For clarity, here is the structure of the data that needs to be sent when using ColdFusion and communicating with EchoSign and using the sendDocument command:

<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>

For data that can contain multiple entries, like recipients and files, the data is stored in arrays of structures. In this example, there is only one recipient, so the array recipientInfo only has one array element, recipientInfo[1], but we could easily add additional recipients just by repeating this section and using recipientInfo[2], etc. Since senderInfo cannot have multiple entries it is just a struct with elements email, password and userKey. According to the documentation, userKey will override email and password entries. To use Single Sign-On, I tried sending blank data for email, password and userKey but that did not work, I also tried just sending an empty senderInfo structure and that did not work. So my question becomes, how do I send a NULL value for senderInfo so that it defaults to the API owner?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880

1 Answers1

0

After having a look at the sendDocument method of the web service in question, it appears as though you also need to include the senderInfo parameter, which is defined in the WSDL as:

<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>

So, after you create an instance of senderInfo (which could just be an empty struct), your web service call will look like this:

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

Hope that helps!

Russ
  • 1,931
  • 1
  • 14
  • 15
  • You were right! Even though the documentation says that the senderInfo is not required, when I entered my information it worked. The problem is that I'd like to use Single Sign On and not have to enter my email and password. How do I send a NULL value for SenderInfo? I tried sending blank values for email and password but that did not work. – Chuck Fennimore Aug 21 '13 at 15:31
  • can't you just send an empty struct? – Russ Aug 21 '13 at 21:06
  • No, tried that and it doesn't work. I contacted EchoSign tech support and they confirmed the fact that senderInfo is required, contrary to what is stated in the documentation. – Chuck Fennimore Aug 26 '13 at 13:46
  • Okay, so it sounds like you have to pass that information then in order for it to work. – Russ Aug 27 '13 at 02:16