Docusign Soap API返回未指定的错误

时间:2016-12-21 09:15:15

标签: soap salesforce docusignapi

我一直在尝试使用docusign SOAP API从Salesforce发送docusign信封。我正在使用Docusign API的CreateEnvelopeFromTemplates方法,我在我的docusign沙箱中创建了一个功能模板,但每次发送请求时,我的响应中都会出现未指定的错误。以下是我正在使用的代码

wwwDocusignNetApi30.EnvelopeInformation envelope = new wwwDocusignNetApi30.EnvelopeInformation();
envelope.Subject = 'Envelope Subject' ;     
envelope.EmailBlurb = 'Email Blurb';
envelope.AccountId = '********-****-****-****-************';

//use custom field to store the id of the record that initiated the transaction    
envelope.CustomFields = new wwwDocusignNetApi30.ArrayOfCustomField();
envelope.CustomFields.CustomField = new wwwDocusignNetApi30.CustomField[2];
wwwDocusignNetApi30.CustomField myCustomField = new wwwDocusignNetApi30.CustomField();
myCustomField.Name = 'DSFSSourceObjectId'; 
myCustomField.Value = '0012600000PQn9g'; 
myCustomField.Show = 'false';
myCustomField.Required = 'false';
myCustomField.CustomFieldType = 'Text';
envelope.CustomFields.CustomField.add(myCustomField);

wwwDocusignNetApi30.ArrayOfTemplateReference templateArray = new wwwDocusignNetApi30.ArrayOfTemplateReference();
templateArray.TemplateReference = new wwwDocusignNetApi30.TemplateReference[2];
wwwDocusignNetApi30.TemplateReference templat = new wwwDocusignNetApi30.TemplateReference();// TemplateReferences 
templat.Template = '********-****-****-****-************';
templat.TemplateLocation = 'Server';

wwwDocusignNetApi30.ArrayOfRecipient1 recArray = new wwwDocusignNetApi30.ArrayOfRecipient1();
recArray.Recipient = new wwwDocusignNetApi30.Recipient[2];
wwwDocusignNetApi30.Recipient recipient = new wwwDocusignNetApi30.Recipient();
recipient.ID = 100987;
recipient.Type_x = 'Signer';
recipient.RoutingOrder = 2;
recipient.Email = 'example@example.com';
recipient.UserName = 'Test';
recArray.Recipient.add(recipient);

wwwDocusignNetApi30.TemplateReferenceRoleAssignment trra = new wwwDocusignNetApi30.TemplateReferenceRoleAssignment();
trra.RoleName='Signer 1';
trra.RecipientID = recipient.ID;

wwwDocusignNetApi30.ArrayOfTemplateReferenceRoleAssignment roleArray = new wwwDocusignNetApi30.ArrayOfTemplateReferenceRoleAssignment();
roleArray.RoleAssignment = new wwwDocusignNetApi30.TemplateReferenceRoleAssignment[1];
roleArray.RoleAssignment.add(trra);

templat.RoleAssignments = new wwwDocusignNetApi30.ArrayOfTemplateReferenceRoleAssignment();
templat.RoleAssignments = (roleArray);
templateArray.TemplateReference.add(templat);

String auth = '<DocuSignCredentials><Username>********-****-****-****-************</Username><Password>PASSWORD</Password><IntegratorKey>********-****-****-****-************</IntegratorKey></DocuSignCredentials>';
wwwDocusignNetApi30.APIServiceSoap service = new wwwDocusignNetApi30.APIServiceSoap();
service.inputHttpHeaders_x =  new Map<String, String>();
service.inputHttpHeaders_x.put('X-DocuSign-Authentication',auth);
service.CreateEnvelopeFromTemplates(templateArray,recArray,envelope,true);

以下是我收到的回复:

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: Unspecified_Error faultcode=soap:Server faultactor=https://demo.docusign.net/api/3.0/dsapi.asmx

由于错误消息含糊不清,我无法调试此问题。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:0)

我建议您从更简单的请求开始。查看以sfdc

开头的github.com/docusign上的食谱

获取更简单的请求,然后添加功能以满足您的需求。

我注意到的一件事是您没有向您的唯一收件人提供1的路由订单。但那可能还行。

我不确定您的模板参考是否正确,因为您不应该使用复合模板进行简单的模板参考。不幸的是,我对soap api没有多少经验。 HTH。