我正在尝试使用 Ruby on Rails 创建对EchoSign API的 SOAP 请求,但我收到一条错误消息,指出其中一个字段为空白:
{http://dto14.api.echosign}RecipientRole: cannot accept ''
这是我正在使用的代码:
require 'soap/wsdlDriver'
require 'base64'
filename = 'quote'
recipient = 'martin@domain.co.uk'
quote_id = params[:id]
$S = SOAP::WSDLDriverFactory.new("https://secure.echosign.com/services/EchoSignDocumentService16?wsdl").create_rpc_driver
r = $S.sendDocument(
:apiKey => 'XXXXXXXXXXX',
:senderInfo => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
:documentCreationInfo => {
:fileInfos => [{
:file => RAILS_ROOT + '/pdfs/' + quote_id + '.pdf',
:fileName => filename,
}],
:recipients =>
[{ :RecipientInfo => [{
:email => 'martin@domain.co.uk',
:fax => SOAP::SOAPNil.new,
:role => 'SIGNER'
}]
}],
:message => "This is neat.",
:name => "Test from SOAP-Lite: " + filename,
:reminderFrequency => "WEEKLY_UNTIL_SIGNED",
:signatureFlow => "SENDER_SIGNATURE_NOT_REQUIRED",
:signatureType => "ESIGN",
:callbackInfo => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
:ccs => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
:externalId => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
:securityOptions => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
}
)
我这样做的方式显然有问题
:recipients =>
[{ :RecipientInfo => [{
:email => 'martin@domain.co.uk',
:fax => SOAP::SOAPNil.new,
:role => 'SIGNER'
}]
}],
但是我发现仅从文档中找到内容非常困难,我认为这会很愚蠢,但无法发现。
更新
在仔细查看示例请求后,我尝试了以下操作,但没有任何区别:
require 'soap/wsdlDriver'
require 'base64'
filename = 'quote'
quote_id = params[:id]
$S = SOAP::WSDLDriverFactory.new("https://secure.echosign.com/services/EchoSignDocumentService16?wsdl").create_rpc_driver
r = $S.sendDocument(
:apiKey => 'XXXXXXXXXXX',
:senderInfo => SOAP::SOAPNil.new,
:documentCreationInfo => {
:fileInfos => {
:FileInfo => {
:file => RAILS_ROOT + '/pdfs/' + quote_id + '.pdf',
:fileName => filename
}
},
:recipients => {
:RecipientInfo => {
:email => 'martin@domain.co.uk',
:fax => SOAP::SOAPNil.new,
:role => 'SIGNER'
}
},
:mergeFieldInfo => SOAP::SOAPNil.new,
:tos => SOAP::SOAPNil.new,
:message => "This is neat.",
:name => "Test from SOAP-Lite: " + filename,
:reminderFrequency => "WEEKLY_UNTIL_SIGNED",
:signatureFlow => "SENDER_SIGNATURE_NOT_REQUIRED",
:signatureType => "ESIGN",
:callbackInfo => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
:ccs => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
:externalId => SOAP::SOAPNil.new, # we need to explicitly set elements to nil
:securityOptions => SOAP::SOAPNil.new # we need to explicitly set elements to nil
}
)