我正在测试Docusign PHP API并尝试以下代码:
$envelopeId = '3e979aac-1d8d-4ab9-rand-envelopid';
$api = new APIService();
$api->setCredentials('devaccountemail', 'devaccountpassword');
$userName = 'Test Signer';
$userEmail = 'random@randor.com';
$userId = '457';
$RequestRecipientTokenParams = new RequestRecipientToken();
$RequestRecipientTokenParams->EnvelopeID = $envelopeId;
$RequestRecipientTokenParams->Username = $userName;
$RequestRecipientTokenParams->Email = $userEmail;
$RequestRecipientTokenParams->ClientUserID = $userId;
$RequestRecipientTokenParams->AuthenticationAssertion->AssertionID = rand(0, 999);
$RequestRecipientTokenParams->AuthenticationAssertion->AuthenticationInstant = date("Y")."-".date("m")."-".date("d")."T00:00:00.00";
$RequestRecipientTokenParams->AuthenticationAssertion->AuthenticationMethod = RequestRecipientTokenAuthenticationAssertionAuthenticationMethod::Email;
$RequestRecipientTokenParams->AuthenticationAssertion->SecurityDomain = "local IP Address";
$RequestRecipientTokenParams->ClientURLs->OnAccessCodeFailed = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnAccessCodeFailed";
$RequestRecipientTokenParams->ClientURLs->OnCancel = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnCancel";
$RequestRecipientTokenParams->ClientURLs->OnDecline = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnDecline";
$RequestRecipientTokenParams->ClientURLs->OnException = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnException";
$RequestRecipientTokenParams->ClientURLs->OnFaxPending = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnFaxPending";
$RequestRecipientTokenParams->ClientURLs->OnIdCheckFailed = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnIdCheckFailed";
$RequestRecipientTokenParams->ClientURLs->OnSessionTimeout ="https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnSessionTimeout";
$RequestRecipientTokenParams->ClientURLs->OnSigningComplete = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnSigningComplete";
$RequestRecipientTokenParams->ClientURLs->OnTTLExpired = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnTTLExpired";
$RequestRecipientTokenParams->ClientURLs->OnViewingComplete = "https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnViewingComplete";
$RequestRecipientTokenResponse = $api->RequestRecipientToken($RequestRecipientTokenParams);
我收到以下错误:
SoapFault : One or both of Username and Password are invalid.
我提供的凭据有效,我可以使用这些凭据登录demo.docusign.net帐户。我不确定我做错了什么。
以下是正在生成的SOAP请求:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-
ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://www.docusign.net/API/3.0"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing">
<SOAP-ENV:Header>
<wsa:Action>http://www.docusign.net/API/3.0/RequestRecipientToken</wsa:Action>
<wsa:To>https://www.docusign.net/API/3.0/api.asmx</wsa:To>
<wsa:MessageID>uudi:638fd49c-2516-12a9-8159-17a9c602975e</wsa:MessageID>
<wsa:ReplyTo>
<wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
</wsa:ReplyTo>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" SOAP-ENV:mustUnderstand="1">
<wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Created>2013-09-18T12:30:20Z</wsu:Created>
<wsu:Expires>2013-09-18T12:35:20Z</wsu:Expires>
</wsu:Timestamp>
<wsse:UsernameToken>
<wsse:Username>bhargav.bonu@somedomain.com</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-
token-profile-1.0#PasswordText">mypassword</wsse:Password>
<wsse:Nonce>0PZkAUVbHHiyjV8KZrN6x2x0S6cQ5WbAjTH4yn8dnc4=</wsse:Nonce>
<wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-
utility-1.0.xsd">2013-09-18T12:29:18Z</wsu:Created>
</wsse:UsernameToken>
</wsse:Security>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<ns1:RequestRecipientToken>
<ns1:EnvelopeID>3e979aac-1d8d-4ab9-a45c-randElem</ns1:EnvelopeID>
<ns1:Username>Test Signer</ns1:Username>
<ns1:Email>Guest</ns1:Email>
<ns1:AuthenticationAssertion>
<ns1:AssertionID>175</ns1:AssertionID>
<ns1:AuthenticationInstant>2013-09-18T00:00:00.00</ns1:AuthenticationInstant>
<ns1:AuthenticationMethod>Email</ns1:AuthenticationMethod>
<ns1:SecurityDomain>192.168.0.43</ns1:SecurityDomain></ns1:AuthenticationAssertion>
<ns1:ClientURLs>
<ns1:OnSigningComplete>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnSigningComplete</ns1:OnSigningComplete>
<ns1:OnViewingComplete>https://YourApp.com/DocuSignCallback.html?
envelopeId=YourEnvelopeId&event=OnViewingComplete</ns1:OnViewingComplete>
<ns1:OnCancel>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnCancel</ns1:OnCancel>
<ns1:OnDecline>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnDecline</ns1:OnDecline>
<ns1:OnSessionTimeout>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnSessionTimeout</ns1:OnSessionTimeout>
<ns1:OnTTLExpired>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnTTLExpired</ns1:OnTTLExpired>
<ns1:OnException>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnException</ns1:OnException>
<ns1:OnAccessCodeFailed>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnAccessCodeFailed</ns1:OnAccessCodeFailed>
<ns1:OnIdCheckFailed>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnIdCheckFailed</ns1:OnIdCheckFailed>
<ns1:OnFaxPending>https://YourApp.com/DocuSignCallback.html?envelopeId=YourEnvelopeId&event=OnFaxPending</ns1:OnFaxPending>
</ns1:ClientURLs>
</ns1:RequestRecipientToken>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
答案 0 :(得分:3)
该错误表示您在验证API调用的请求中提供的DocuSign用户凭据无效。您在此帖中包含的代码实际上是无关紧要的,因为如果您提供的用于验证请求的用户名或密码无效,则任何API调用都会导致此错误。
如果您尚未这样做,我建议您生成完整XML请求的跟踪(即包括标头),以密切检查您在请求中提供的身份验证凭据。解决这类问题的最佳方法是检查线路上的内容(而不是尝试对生成内容的代码进行故障排除) - 一旦识别出XML中的问题,就应该很容易解决问题。代码。
答案 1 :(得分:0)
关于“用户名或密码无效”错误 - 可能是因为您未在用户名中包含Integrator密钥。从DocuSign SOAP API指南(http://www.docusign.com/sites/default/files/DocuSignAPI_Guide.pdf)的第18页开始:
集成商密钥必须放在UsernameToken的Username节点中的用户ID前面。必须用括号“[和]”包装积分器键。示例格式:
<wsse:Username>[Integrator Key]2988541c-4ec7-4245-b520-f2d324062ca3</wsse:Username>
Integrator Key必须包含在所有API请求中,因为DocuSign需要它才能识别集成应用程序。